-
Notifications
You must be signed in to change notification settings - Fork 3
293 lines (275 loc) · 11.4 KB
/
release-cli.yaml
File metadata and controls
293 lines (275 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
name: Release CLI
on:
workflow_dispatch:
inputs:
release_type:
description: 'Release type'
required: true
default: 'auto'
type: choice
options:
- auto
- patch
- minor
- major
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
OPENTAINT_DEPENDENCIES_VERSION: 2026.03.19.adeb616
jobs:
release:
runs-on: ubuntu-latest
container: ghcr.io/catthehacker/ubuntu:act-latest
defaults:
run:
shell: bash
permissions:
contents: write
packages: write
steps:
-
name: Install GitHub CLI
run: |
(type -p wget >/dev/null || apt-get install -yqq wget) \
&& mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& apt-get update \
&& apt-get install -yqq gh
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Manual release
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release_type != 'auto' }}
id: manual_release
uses: ./.github/actions/manual-version-bump
with:
tag-prefix: 'v'
bump-type: ${{ github.event.inputs.release_type }}
-
name: Write manual release version
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release_type != 'auto' }}
run: |
echo "${{ steps.manual_release.outputs.new-version }}" > cli/release_version.txt
-
name: Create release tag (manual)
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release_type != 'auto' }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag "v${{ steps.manual_release.outputs.new-version }}"
git push origin "v${{ steps.manual_release.outputs.new-version }}"
-
name: Force-update tags
run: git fetch --tags --force
-
name: 'Release (auto)'
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.release_type == 'auto' }}
id: semantic_release
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
semantic_version: 23.0.0
working_directory: cli
extra_plugins: |
@semantic-release/commit-analyzer@11.1.0
@semantic-release/exec@6.0.3
conventional-changelog-conventionalcommits@7.0.2
-
name: 'Get release_version and pass to next job'
id: release_version
working-directory: cli
run: |
if [ -f release_version.txt ]; then
echo "status=succeeded" >>"$GITHUB_OUTPUT"
echo "RELEASE_VERSION=$(cat release_version.txt)" >> $GITHUB_OUTPUT
else
echo "status=skipped" >>"$GITHUB_OUTPUT"
fi
rm -f release_version.txt
-
name: Login to GitHub Container Registry
if: ${{ steps.release_version.outputs.status == 'succeeded' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ secrets.SEQRA_GITHUB_ACTOR }}
password: ${{ secrets.SEQRA_GITHUB_TOKEN }}
-
name: Set up QEMU
if: ${{ steps.release_version.outputs.status == 'succeeded' }}
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
if: ${{ steps.release_version.outputs.status == 'succeeded' }}
uses: docker/setup-buildx-action@v3
-
name: Set up Go
if: ${{ steps.release_version.outputs.status == 'succeeded' }}
uses: actions/setup-go@v5
with:
go-version: '>=1.25.0'
-
name: Docker meta
id: meta
if: ${{ steps.release_version.outputs.status == 'succeeded' }}
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}},value=${{ steps.release_version.outputs.RELEASE_VERSION }}
-
name: Download bundled artifacts
if: ${{ steps.release_version.outputs.status == 'succeeded' }}
working-directory: cli
env:
GH_TOKEN: ${{ secrets.SEQRA_GITHUB_TOKEN }}
run: |
ANALYZER_TAG=$(grep '^analyzer:' internal/globals/versions.yaml | awk '{print $2}' | tr -d '"')
AUTOBUILDER_TAG=$(grep '^autobuilder:' internal/globals/versions.yaml | awk '{print $2}' | tr -d '"')
RULES_TAG=$(grep '^rules:' internal/globals/versions.yaml | awk '{print $2}' | tr -d '"')
mkdir -p lib
echo "Downloading analyzer ${ANALYZER_TAG}..."
gh release download "$ANALYZER_TAG" \
--repo ${{ github.repository }} \
--pattern "opentaint-project-analyzer.jar" \
--dir lib
echo "Downloading autobuilder ${AUTOBUILDER_TAG}..."
gh release download "$AUTOBUILDER_TAG" \
--repo ${{ github.repository }} \
--pattern "opentaint-project-auto-builder.jar" \
--dir lib
echo "Downloading rules ${RULES_TAG}..."
gh release download "$RULES_TAG" \
--repo ${{ github.repository }} \
--pattern "opentaint-rules.tar.gz" \
--dir /tmp
mkdir -p lib/rules
tar -xzf /tmp/opentaint-rules.tar.gz -C lib/rules
echo "Bundled artifacts:"
ls -la lib/
-
name: Run GoReleaser
if: ${{ steps.release_version.outputs.status == 'succeeded' }}
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
workdir: cli
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: v${{ steps.release_version.outputs.RELEASE_VERSION }}
HOMEBREW_TAP_OWNER: ${{ github.repository_owner }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
-
name: Bundle JREs into release archives
if: ${{ steps.release_version.outputs.status == 'succeeded' }}
working-directory: cli
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bash scripts/bundle-jre.sh dist
RELEASE_TAG="v${{ steps.release_version.outputs.RELEASE_VERSION }}"
for archive in dist/opentaint-full_*.tar.gz dist/opentaint-full_*.zip; do
[ -f "$archive" ] || continue
echo "Re-uploading $archive..."
gh release upload "$RELEASE_TAG" "$archive" --clobber
done
# Regenerate checksums covering all three variants
cd dist
sha256sum opentaint-cli_*.{tar.gz,zip} opentaint_*.{tar.gz,zip} opentaint-full_*.{tar.gz,zip} 2>/dev/null > checksums.txt
cd ..
if [ -s dist/checksums.txt ]; then
gh release upload "$RELEASE_TAG" dist/checksums.txt --clobber
else
echo "No checksums to upload"
fi
-
name: Check Homebrew token availability
if: ${{ steps.release_version.outputs.status == 'succeeded' }}
id: check_homebrew
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
run: |
if [ -n "$HOMEBREW_TAP_TOKEN" ]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
fi
-
name: Update package manager manifests
if: ${{ steps.check_homebrew.outputs.available == 'true' && steps.release_version.outputs.status == 'succeeded' && (steps.semantic_release.outputs.new_release_channel == '' || steps.manual_release.outputs.new-version != '') }}
working-directory: cli
env:
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
HOMEBREW_TAP_OWNER: ${{ github.repository_owner }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
run: |
RELEASE_TAG="v${{ steps.release_version.outputs.RELEASE_VERSION }}"
# Import GPG key for signed commits
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
# Fix SHA256 values in GoReleaser-generated cask file
CASK_FILE="dist/homebrew/Casks/opentaint.rb"
for f in dist/opentaint-full_*.tar.gz dist/opentaint-full_*.zip; do
[ -f "$f" ] || continue
name="$(basename "$f")"
sha="$(sha256sum "$f" | awk '{print $1}')"
escaped_name="${name//./\\.}"
sed -i "/${escaped_name}/{ n; s/sha256 \"[a-f0-9]\{64\}\"/sha256 \"${sha}\"/; }" "$CASK_FILE"
done
# Push updated cask to Homebrew tap
git clone "https://x-access-token:${HOMEBREW_TAP_TOKEN}@github.com/${{ github.repository_owner }}/homebrew-tap.git" /tmp/homebrew-tap
mkdir -p /tmp/homebrew-tap/Casks
cp "$CASK_FILE" /tmp/homebrew-tap/Casks/opentaint.rb
cd /tmp/homebrew-tap
git config user.name "seqradev"
git config user.email "seqradev@gmail.com"
git config user.signingkey "6000887370B8C08E"
git config commit.gpgsign true
git add -A
if ! git diff --cached --quiet; then
git commit -m "Update opentaint to ${RELEASE_TAG}"
git push
fi
cd -
-
name: Build and push Docker image
if: ${{ steps.release_version.outputs.status == 'succeeded' && (steps.semantic_release.outputs.new_release_channel == '' || steps.manual_release.outputs.new-version != '') }}
uses: docker/build-push-action@v6
with:
context: cli
build-contexts: |
opentaint-dependencies:latest=docker-image://ghcr.io/${{ github.repository_owner }}/opentaint/infra:${{ env.OPENTAINT_DEPENDENCIES_VERSION }}
platforms: linux/amd64, linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
secrets: |
github_token=${{ secrets.SEQRA_GITHUB_TOKEN }}
build-args: |
OPENTAINT_OWNER=${{ github.repository_owner }}
OPENTAINT_BUILD_FLAGS=-s -w -X github.com/${{ github.repository_owner }}/opentaint/internal/version.Version=${{ steps.release_version.outputs.RELEASE_VERSION }}
-
name: Update floating version tags
if: ${{ steps.release_version.outputs.status == 'succeeded' }}
uses: ./.github/actions/update-floating-tags
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release-version: ${{ steps.release_version.outputs.RELEASE_VERSION }}
tag-prefix: ''
component-name: 'CLI'
copy-assets-from: v${{ steps.release_version.outputs.RELEASE_VERSION }}
outputs:
release_version: ${{ steps.release_version.outputs.RELEASE_VERSION }}