-
Notifications
You must be signed in to change notification settings - Fork 338
325 lines (287 loc) · 11.5 KB
/
Copy path01-steampipe-release.yaml
File metadata and controls
325 lines (287 loc) · 11.5 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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
name: "01 - Steampipe: Release"
on:
workflow_dispatch:
inputs:
environment:
type: choice
description: "Select Release Type"
options:
# to change the values in this option, we also need to update the condition test below in at least 3 location. Search for github.event.inputs.environment
- Development (alpha)
- Development (beta)
- Final (RC and final release)
required: true
version:
description: "Version (without 'v')"
required: true
default: 0.2.\invalid
confirmDevelop:
description: Confirm running on develop branch
required: true
type: boolean
permissions:
contents: write
env:
# Version number from user input, used throughout the workflow for tagging, branching, and release operations
VERSION: ${{ github.event.inputs.version }}
# GitHub personal access token for authenticated API operations like creating releases, managing PRs, and repository access
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
# PostgreSQL connection string used in acceptance tests (tests/acceptance/test_files/cloud.bats)
SPIPETOOLS_PG_CONN_STRING: ${{ secrets.SPIPETOOLS_PG_CONN_STRING }}
# Authentication token for Steampipe Cloud services used in acceptance tests (tests/acceptance/test_files/cloud.bats and snapshot.bats)
SPIPETOOLS_TOKEN: ${{ secrets.SPIPETOOLS_TOKEN }}
# Disable update checks during CI runs to avoid unnecessary network calls and delays
STEAMPIPE_UPDATE_CHECK: false
jobs:
ensure_branch_in_homebrew:
name: Ensure branch exists in homebrew-tap
runs-on: ubuntu-latest
steps:
- name: Calculate version
id: calculate_version
run: |
echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7
with:
input_string: ${{ github.event.inputs.version }}
- name: Checkout
if: steps.semver_parser.outputs.prerelease == ''
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: turbot/homebrew-tap
token: ${{ secrets.GH_ACCESS_TOKEN }}
ref: main
- name: Delete base branch if exists
if: steps.semver_parser.outputs.prerelease == ''
run: |
git fetch --all
git push origin --delete bump-brew
git push origin --delete $VERSION
continue-on-error: true
- name: Create base branch
if: steps.semver_parser.outputs.prerelease == ''
run: |
git checkout -b bump-brew
git push --set-upstream origin bump-brew
build_and_release_cli:
name: Release CLI
needs: [ensure_branch_in_homebrew]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
path: steampipe
ref: ${{ github.event.ref }}
- name: Checkout Pipe Fittings Components repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: turbot/pipe-fittings
path: pipe-fittings
ref: v1.6.x
- name: Calculate version
id: calculate_version
run: |
if [ "${{ github.event.inputs.environment }}" = "Development (alpha)" ]; then
echo "VERSION=v${{ github.event.inputs.version }}-alpha.$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV
elif [ "${{ github.event.inputs.environment }}" = "Development (beta)" ]; then
echo "VERSION=v${{ github.event.inputs.version }}-beta.$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV
else
echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV
fi
- name: Tag Release
run: |
cd steampipe
git config user.name "Steampipe GitHub Actions Bot"
git config user.email noreply@github.com
git tag $VERSION
git push origin $VERSION
- name: Set up Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: 1.26.1
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
with:
install-only: true
- name: Run GoReleaser
run: |
cd steampipe
goreleaser release --clean
env:
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
create_pr_in_homebrew:
name: Create PR in homebrew-tap
if: ${{ github.event.inputs.environment == 'Final (RC and final release)' }}
needs: [ensure_branch_in_homebrew, build_and_release_cli]
runs-on: ubuntu-latest
env:
Version: ${{ github.event.inputs.version }}
steps:
- name: Calculate version
id: calculate_version
run: |
echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7
with:
input_string: ${{ github.event.inputs.version }}
- name: Checkout
if: steps.semver_parser.outputs.prerelease == ''
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: turbot/homebrew-tap
token: ${{ secrets.GH_ACCESS_TOKEN }}
ref: main
- name: Create a new branch off the base branch
if: steps.semver_parser.outputs.prerelease == ''
run: |
git fetch --all
git checkout bump-brew
git checkout -b $VERSION
git push --set-upstream origin $VERSION
- name: Close pull request if already exists
if: steps.semver_parser.outputs.prerelease == ''
run: |
gh pr close $VERSION
continue-on-error: true
- name: Create pull request
if: steps.semver_parser.outputs.prerelease == ''
run: |
gh pr create --base main --head $VERSION --title "Steampipe $Version" --body "Update formula"
update_pr_for_versioning:
name: Update PR
if: ${{ github.event.inputs.environment == 'Final (RC and final release)' }}
needs: [create_pr_in_homebrew]
runs-on: ubuntu-latest
env:
Version: ${{ github.event.inputs.version }}
steps:
- name: Calculate version
id: calculate_version
run: |
echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7
with:
input_string: ${{ github.event.inputs.version }}
- name: Checkout
if: steps.semver_parser.outputs.prerelease == ''
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: turbot/homebrew-tap
token: ${{ secrets.GH_ACCESS_TOKEN }}
ref: v${{ github.event.inputs.version }}
- name: Update live version
if: steps.semver_parser.outputs.prerelease == ''
run: |
scripts/formula_versioning.sh
git config --global user.email "puskar@turbot.com"
git config --global user.name "Puskar Basu"
git add .
git commit -m "Versioning brew formulas"
git push origin $VERSION
update_homebrew_tap:
name: Update homebrew-tap formula
if: ${{ github.event.inputs.environment == 'Final (RC and final release)' }}
needs: update_pr_for_versioning
runs-on: ubuntu-latest
steps:
- name: Calculate version
id: calculate_version
run: |
echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7
with:
input_string: ${{ github.event.inputs.version }}
- name: Checkout
if: steps.semver_parser.outputs.prerelease == ''
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
repository: turbot/homebrew-tap
token: ${{ secrets.GH_ACCESS_TOKEN }}
ref: main
- name: Get pull request title
if: steps.semver_parser.outputs.prerelease == ''
id: pr_title
run: >-
echo "PR_TITLE=$(
gh pr view $VERSION --json title | jq .title | tr -d '"'
)" >> $GITHUB_OUTPUT
- name: Output
if: steps.semver_parser.outputs.prerelease == ''
run: |
echo ${{ steps.pr_title.outputs.PR_TITLE }}
echo ${{ env.VERSION }}
- name: Fail if PR title does not match with version
if: steps.semver_parser.outputs.prerelease == ''
run: |
if [[ "${{ steps.pr_title.outputs.PR_TITLE }}" == "Steampipe ${{ github.event.inputs.version }}" ]]; then
echo "Correct version"
else
echo "Incorrect version"
exit 1
fi
- name: Merge pull request to update brew formula
if: steps.semver_parser.outputs.prerelease == ''
run: |
git fetch --all
gh pr merge $VERSION --squash --delete-branch
git push origin --delete bump-brew
trigger_smoke_tests:
name: Trigger Smoke Tests
if: ${{ github.event.inputs.environment == 'Final (RC and final release)' }}
needs: update_homebrew_tap
runs-on: ubuntu-latest
steps:
- name: Calculate version
id: calculate_version
run: |
echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7
with:
input_string: ${{ github.event.inputs.version }}
- name: Trigger smoke test workflow
if: steps.semver_parser.outputs.prerelease == ''
run: |
gh workflow run "12-test-post-release-linux-distros.yaml" \
--ref ${{ github.ref }} \
--field version=$VERSION \
--repo ${{ github.repository }}
env:
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
- name: Get smoke test workflow run URL
if: steps.semver_parser.outputs.prerelease == ''
run: |
echo "Waiting for smoke test workflow to start..."
sleep 10
# Get the most recent run of the smoke test workflow
RUN_ID=$(gh run list \
--workflow="12-test-post-release-linux-distros.yaml" \
--repo ${{ github.repository }} \
--limit 1 \
--json databaseId \
--jq '.[0].databaseId')
if [ -n "$RUN_ID" ]; then
WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/$RUN_ID"
echo "✅ Smoke test workflow triggered successfully!"
echo "🔗 Monitor progress at: $WORKFLOW_URL"
echo ""
echo "Workflow details:"
echo " - Version: $VERSION"
echo " - Workflow: 12-test-post-release-linux-distros.yaml"
echo " - Run ID: $RUN_ID"
else
echo "⚠️ Could not retrieve workflow run ID. Check manually at:"
echo "https://github.com/${{ github.repository }}/actions/workflows/12-test-post-release-linux-distros.yaml"
fi
env:
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}