forked from turbot/steampipe
-
Notifications
You must be signed in to change notification settings - Fork 0
879 lines (750 loc) · 26.3 KB
/
release_cli_and_assets.yml
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
name: Steampipe Release (CLI and Assets)
on:
workflow_dispatch:
inputs:
version:
description: "The version to release (must be prefixed with 'v')"
required: true
env:
PROJECT_ID: steampipe
CORE_REPO: us-docker.pkg.dev/steampipe/steampipe
ORG: turbot
ASSET_IMAGE_NAME: assets
CONFIG_SCHEMA_VERSION: "2020-11-18"
VERSION: ${{ github.event.inputs.version }}
STEAMPIPE_UPDATE_CHECK: false
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
SPIPETOOLS_PG_CONN_STRING: ${{ secrets.SPIPETOOLS_PG_CONN_STRING }}
SPIPETOOLS_TOKEN: ${{ secrets.SPIPETOOLS_TOKEN }}
jobs:
verify_input:
name: Verify Inputs
runs-on: ubuntu-latest
steps:
- name: Trim asset version prefix and Validate
run: |-
echo $VERSION
trim=${VERSION#"v"}
echo $trim
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
echo "Version OK: $trim"
else
echo "Invalid version: $trim"
exit 1
fi
echo "VERSION=${trim}" >> $GITHUB_ENV
- name: Validate Branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.ref }}
verify_asset_unreleased:
name: Verify Assets Unreleased
needs: [verify_input]
runs-on: ubuntu-latest
outputs:
status: ${{ steps.verify.conclusion }}
steps:
- name: Trim asset version prefix and Validate
run: |-
echo $VERSION
trim=${VERSION#"v"}
echo $trim
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
echo "Version OK: $trim"
else
echo "Invalid version: $trim"
exit 1
fi
echo "VERSION=${trim}" >> $GITHUB_ENV
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
service_account: ${{ secrets.GCP_GITHUB_ACTION_PUSH_ARTIFACTS }}
credentials_json: ${{ secrets.GCP_GITHUB_ACTION_PUSH_ARTIFACTS_CREDENTIAL_JSON }}
- name: Get GCloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{ env.PROJECT_ID }}
- name: Setup GCloud CLI
run: |-
gcloud config list
gcloud components install beta
gcloud components install alpha --quiet
gcloud beta auth configure-docker us-docker.pkg.dev
- name: Delete the tag if it already exists
id: verify
continue-on-error: true
run: |-
[ $(gcloud beta artifacts docker tags list ${{ env.CORE_REPO }}/${{ env.ASSET_IMAGE_NAME }} --project ${{ env.PROJECT_ID }} --format=json | jq 'map(select(.tag | endswith("${{ env.VERSION }}"))) | length') -eq 1 ]
gcloud beta artifacts docker tags delete ${{ env.CORE_REPO }}/${{ env.ASSET_IMAGE_NAME }}:"${{ env.VERSION }}"
build_and_release_assets:
name: Build and Release Assets
needs: [verify_input,verify_asset_unreleased]
if: needs.verify_asset_unreleased.outputs.status == 'success'
runs-on: ubuntu-latest
steps:
- name: Trim asset version prefix and Validate
run: |-
echo $VERSION
trim=${VERSION#"v"}
echo $trim
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
echo "Version OK: $trim"
else
echo "Invalid version: $trim"
exit 1
fi
echo "VERSION=${trim}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.ref }}
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
service_account: ${{ secrets.GCP_GITHUB_ACTION_PUSH_ARTIFACTS }}
credentials_json: ${{ secrets.GCP_GITHUB_ACTION_PUSH_ARTIFACTS_CREDENTIAL_JSON }}
- name: Get GCloud CLI
uses: google-github-actions/[email protected]
with:
project_id: ${{ env.PROJECT_ID }}
- name: Setup GCloud CLI
run: |-
gcloud config list
gcloud components install beta
gcloud components install alpha --quiet
gcloud beta auth configure-docker us-docker.pkg.dev
- name: Verify ORAS
run: |-
gcloud beta auth configure-docker us-docker.pkg.dev
oras version
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '16'
- name: Setup Yarn
working-directory: ./ui/dashboard
run: |-
rm -rf ./build
- name: YARN Install
working-directory: ./ui/dashboard
run: |-
unset CI
yarn install
- name: Generate dashboard UI icons
working-directory: ./ui/dashboard
run: |-
make setup
- name: Run Unit Tests
working-directory: ./ui/dashboard
run: |
yarn install
CI=true yarn test
- name: YARN Build
working-directory: ./ui/dashboard
run: |-
unset CI
yarn build
env:
REACT_APP_HEAP_ID: ${{ secrets.HEAP_ANALYTICS_PRODUCTION_ID }}
REACT_APP_VERSION: ${{ env.VERSION }}
- name: Move Build Assets
run: |-
mkdir -p dashboard_ui_build
mv ./ui/dashboard/build/* dashboard_ui_build/
ls -la dashboard_ui_build
- name: Create a version file
run: |-
JSON_STRING=$( jq -n \
--arg version "$VERSION" \
'{
"version":$version,
}' )
echo $JSON_STRING > ./dashboard_ui_build/versions.json
- name: Create Image Config File
run: |-
JSON_STRING=$( jq -n \
--arg name "${{ env.ASSET_IMAGE_NAME }}" \
--arg organization "$ORG" \
--arg version "$VERSION" \
--arg schemaVersion "$CONFIG_SCHEMA_VERSION" \
'{schemaVersion: $schemaVersion, assets: { name: $name, organization: $organization, version: $version} }' )
echo $JSON_STRING > config.json
- name: Create Image Annotations File
run: |-
JSON_STRING=$( jq -n \
--arg title "${{ env.ASSET_IMAGE_NAME }}" \
--arg desc "$ORG" \
--arg version "$VERSION" \
--arg timestamp "$(date +%FT%TZ)" \
--arg vendor "Turbot HQ, Inc." \
'{
"$manifest": {
"org.opencontainers.image.title": $title,
"org.opencontainers.image.description": $desc,
"org.opencontainers.image.version": $version,
"org.opencontainers.image.created": $timestamp,
"org.opencontainers.image.vendor": $vendor
}
}' )
echo $JSON_STRING > annotations.json
- name: Generate Image REF
id: image_ref
run: |
cat config.json
cat annotations.json
cat dashboard_ui_build/versions.json
REF="${{ env.CORE_REPO }}/${{ env.ASSET_IMAGE_NAME }}:${{ env.VERSION }}"
echo "REF=$REF" >> $GITHUB_OUTPUT
- name: Push to registry
run: |-
oras push ${{ steps.image_ref.outputs.REF }} \
--config config.json:application/vnd.turbot.steampipe.config.v1+json \
--annotation-file annotations.json \
dashboard_ui_build:application/vnd.turbot.steampipe.assets.report.layer.v1+tar \
create_test_build:
name: Create Test Build
runs-on: ubuntu-latest
needs: [verify_input]
steps:
- name: Trim asset version prefix and Validate
run: |-
echo $VERSION
trim=${VERSION#"v"}
echo $trim
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
echo "Version OK: $trim"
else
echo "Invalid version: $trim"
exit 1
fi
echo "VERSION=${trim}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.ref }}
- name: Unshallow
run: git fetch
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Run CLI Unit Tests
run: |
go clean -testcache
go test -timeout 30s ./... -test.v
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --snapshot --clean --skip=publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Move build artifacts
run: |
mkdir ~/artifacts
mv $GITHUB_WORKSPACE/dist/steampipe_linux_amd64.tar.gz ~/artifacts/linux.tar.gz
mv $GITHUB_WORKSPACE/dist/steampipe_linux_arm64.tar.gz ~/artifacts/linux-arm.tar.gz
mv $GITHUB_WORKSPACE/dist/steampipe_darwin_amd64.zip ~/artifacts/darwin.zip
mv $GITHUB_WORKSPACE/dist/steampipe_darwin_arm64.zip ~/artifacts/darwin-arm.zip
- name: List Build Artifacts
run: ls -l ~/artifacts
- name: Save Linux Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact-linux
path: ~/artifacts/linux.tar.gz
if-no-files-found: error
overwrite: true
- name: Save Linux ARM Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact-linux-arm
path: ~/artifacts/linux-arm.tar.gz
if-no-files-found: error
overwrite: true
- name: Save MacOS Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact-darwin
path: ~/artifacts/darwin.zip
if-no-files-found: error
overwrite: true
- name: Save MacOS ARM Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact-darwin-arm
path: ~/artifacts/darwin-arm.zip
if-no-files-found: error
overwrite: true
run_acceptance_tests:
name: Acceptance tests
needs: [create_test_build,build_and_release_assets]
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-13]
test_block:
- "migration"
- "brew"
- "installation"
- "plugin"
- "service"
- "settings"
- "ssl"
- "blank_aggregators"
- "search_path"
- "chaos_and_query"
- "dynamic_schema"
- "dynamic_aggregators"
- "cache"
- "mod_install"
- "mod_vars"
- "mod"
- "mod_require"
- "check"
- "performance"
- "config_precedence"
- "introspection"
- "cloud"
- "snapshot"
- "dashboard"
- "dashboard_parsing_validation"
- "schema_cloning"
- "exit_codes"
- "force_stop"
exclude:
- platform: macos-13
test_block: migration
- platform: macos-13
test_block: force_stop
- platform: ubuntu-latest
test_block: chaos_and_query
runs-on: ${{ matrix.platform }}
steps:
- name: Trim asset version prefix and Validate
run: |-
echo $VERSION
trim=${VERSION#"v"}
echo $trim
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
echo "Version OK: $trim"
else
echo "Invalid version: $trim"
exit 1
fi
echo "VERSION=${trim}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
ref: ${{ github.event.ref }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Setup BATS
uses: mig4/setup-bats@v1
with:
bats-version: 1.2.1
- name: Prepare for downloads
id: prepare-for-downloads
run: |
mkdir ~/artifacts
- name: Download Linux Build Artifacts
uses: actions/download-artifact@v4
if: ${{ matrix.platform == 'ubuntu-latest' }}
with:
name: build-artifact-linux
path: ~/artifacts
- name: Download Darwin Build Artifacts
uses: actions/download-artifact@v4
if: ${{ matrix.platform == 'macos-13' }}
with:
name: build-artifact-darwin
path: ~/artifacts
- name: Extract Ubuntu Artifacts and Install Binary
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
mkdir ~/build
tar -xf ~/artifacts/linux.tar.gz -C ~/build
- name: Extract Darwin Artifacts and Install Binary
if: ${{ matrix.platform == 'macos-13' }}
run: |
mkdir ~/build
unzip ~/artifacts/darwin.zip -d ~/build
- name: Set PATH
run: |
echo "PATH=$PATH:$HOME/build:$GTIHUB_WORKSPACE/tests/acceptance/lib/bats-core/libexec" >> $GITHUB_ENV
- name: Go install jd
run: |
go install github.com/josephburnett/jd@latest
- name: Install DB
id: install-db
continue-on-error: false
run: |
steampipe service start
steampipe plugin install chaos chaosdynamic
steampipe service stop
- name: Run Test Suite
id: run-test-suite
timeout-minutes: 15
run: |
chmod +x $GITHUB_WORKSPACE/tests/acceptance/run.sh
$GITHUB_WORKSPACE/tests/acceptance/run.sh ${{ matrix.test_block }}.bats
steampipe service stop --force
smoke_test_ubuntu_24:
name: Smoke test (Ubuntu 24, x86_64)
runs-on: ubuntu-latest
needs: [create_test_build, build_and_release_assets]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Linux Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-linux
path: ./artifacts
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Pull Ubuntu latest Image
run: docker pull ubuntu:latest
- name: Create and Start Ubuntu latest Container
run: |
docker run -d --name ubuntu-24-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts ubuntu:latest tail -f /dev/null
- name: Get runner/container info
run: |
docker exec ubuntu-24-test /scripts/linux_container_info.sh
- name: Install dependencies, create user, and assign necessary permissions
run: |
docker exec ubuntu-24-test /scripts/prepare_ubuntu_container.sh
- name: Run smoke tests
run: |
docker exec -u steampipe ubuntu-24-test /scripts/smoke_test.sh
- name: Stop and Remove Container
run: |
docker stop ubuntu-24-test
docker rm ubuntu-24-test
smoke_test_centos_9:
name: Smoke test (Centos stream 9, x86_64)
runs-on: ubuntu-latest
needs: [create_test_build, build_and_release_assets]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Linux Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-linux
path: ./artifacts
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Pull CentOS Stream 9 image
run: docker pull quay.io/centos/centos:stream9
- name: Create and Start CentOS stream9 Container
run: |
docker run -d --name centos-stream9-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts quay.io/centos/centos:stream9 tail -f /dev/null
- name: Get runner/container info
run: |
docker exec centos-stream9-test /scripts/linux_container_info.sh
- name: Install dependencies, create user, and assign necessary permissions
run: |
docker exec centos-stream9-test /scripts/prepare_centos_container.sh
- name: Run smoke tests
run: |
docker exec -u steampipe centos-stream9-test /scripts/smoke_test.sh
- name: Stop and Remove Container
run: |
docker stop centos-stream9-test
docker rm centos-stream9-test
smoke_test_amazonlinux:
name: Smoke test (Amazonlinux 2023, x86_64)
runs-on: ubuntu-latest
needs: [create_test_build, build_and_release_assets]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Linux Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-linux
path: ./artifacts
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Pull Amazon Linux 2023 Image
run: docker pull amazonlinux:2023
- name: Create and Start Amazon Linux 2023 Container
run: |
docker run -d --name amazonlinux-2023-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts amazonlinux:2023 tail -f /dev/null
- name: Get runner/container info
run: |
docker exec amazonlinux-2023-test /scripts/linux_container_info.sh
- name: Install dependencies, create user, and assign necessary permissions
run: |
docker exec amazonlinux-2023-test /scripts/prepare_amazonlinux_container.sh
- name: Run smoke tests
run: |
docker exec -u steampipe amazonlinux-2023-test /scripts/smoke_test.sh
- name: Stop and Remove Container
run: |
docker stop amazonlinux-2023-test
docker rm amazonlinux-2023-test
smoke_test_ubuntu_24_arm64:
name: Smoke test (Ubuntu 24, ARM64)
runs-on: ubuntu-latest
needs: [create_test_build, build_and_release_assets]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Linux Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-linux-arm
path: ./artifacts
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Create Buildx Builder
run: |
docker buildx create --use --name mybuilder
docker buildx inspect --bootstrap
- name: Pull Ubuntu 24 ARM64 Image
run: docker pull arm64v8/ubuntu:latest
- name: Create and Start Ubuntu 24 ARM64 Container
run: |
docker run -d --name ubuntu-24-arm64-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts arm64v8/ubuntu:latest tail -f /dev/null
- name: Get runner/container info
run: |
docker exec ubuntu-24-arm64-test /scripts/linux_container_info.sh
- name: Install dependencies, create user, and assign necessary permissions
run: |
docker exec ubuntu-24-arm64-test /scripts/prepare_ubuntu_arm_container.sh
- name: Run smoke tests
run: |
docker exec -u steampipe ubuntu-24-arm64-test /scripts/smoke_test.sh
- name: Stop and Remove Container
run: |
docker stop ubuntu-24-arm64-test
docker rm ubuntu-24-arm64-test
smoke_test_darwin_arm:
name: Smoke test (MacOS 14, ARM64)
runs-on: macos-latest
needs: [create_test_build, build_and_release_assets]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Darwin Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact-darwin-arm
path: ~/artifacts
- name: Extract Darwin Artifacts and Install Binary
run: |
unzip ~/artifacts/darwin-arm.zip -d /usr/local/bin
- name: Install jq
run: |
brew install jq
- name: Get runner/container info
run: |
uname -a
sw_vers
- name: Run Smoke tests
run: |
ls -al $GITHUB_WORKSPACE/scripts
chmod +x $GITHUB_WORKSPACE/scripts/smoke_test.sh
$GITHUB_WORKSPACE/scripts/smoke_test.sh
create_release_tag:
name: Tag Release
needs: [run_acceptance_tests, smoke_test_ubuntu_24, smoke_test_amazonlinux, smoke_test_centos_9, smoke_test_ubuntu_24_arm64, smoke_test_darwin_arm]
runs-on: ubuntu-latest
steps:
- name: Trim asset version prefix and Validate
run: |-
echo $VERSION
trim=${VERSION#"v"}
echo $trim
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
echo "Version OK: $trim"
else
echo "Invalid version: $trim"
exit 1
fi
echo "VERSION=${trim}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.ref }}
- name: Unshallow
run: git fetch --prune --unshallow
- name: Tag Release
run: |
git config user.name "Steampipe GitHub Actions Bot"
git config user.email [email protected]
git tag ${{ github.event.inputs.version }}
git push origin ${{ github.event.inputs.version }}
ensure_branch_in_homebrew:
name: Ensure branch exists in homebrew-tap
needs: [create_release_tag]
runs-on: ubuntu-latest
steps:
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ github.event.inputs.version }}
- name: Checkout
if: steps.semver_parser.outputs.prerelease == ''
uses: actions/checkout@v4
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: [create_release_tag, ensure_branch_in_homebrew]
runs-on: ubuntu-latest
steps:
- name: Trim asset version prefix and Validate
run: |-
echo $VERSION
trim=${VERSION#"v"}
echo $trim
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
echo "Version OK: $trim"
else
echo "Invalid version: $trim"
exit 1
fi
echo "VERSION=${trim}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.version }}
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
# - name: 'Authenticate to Google Cloud'
# uses: 'google-github-actions/auth@v2'
# with:
# service_account: ${{ secrets.GCP_GITHUB_ACTION_PUSH_ARTIFACTS }}
# credentials_json: ${{ secrets.GCP_GITHUB_ACTION_PUSH_ARTIFACTS_CREDENTIAL_JSON }}
# - name: Get GCloud CLI
# uses: google-github-actions/[email protected]
# with:
# project_id: ${{ env.PROJECT_ID }}
# - name: Setup GCloud CLI
# run: |-
# gcloud config list
# gcloud components install beta
# gcloud components install alpha --quiet
# gcloud beta auth configure-docker us-docker.pkg.dev
# - name: Upload rpm and deb packages to artifact registry
# run: |
# gcloud beta artifacts yum upload steampipe-yum-repo --location=us --source=$GITHUB_WORKSPACE/dist/steampipe_linux_amd64.rpm --project steampipe
# gcloud beta artifacts apt upload steampipe-apt-repo --location=us --source=$GITHUB_WORKSPACE/dist/steampipe_linux_amd64.deb --project steampipe
create_pr_in_homebrew:
name: Create PR in homebrew-tap
needs: [ensure_branch_in_homebrew, build_and_release_cli]
runs-on: ubuntu-latest
env:
Version: ${{ github.event.inputs.version }}
steps:
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ github.event.inputs.version }}
- name: Checkout
if: steps.semver_parser.outputs.prerelease == ''
uses: actions/checkout@v4
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 "$Version" --body "Update formula"
update_pr_for_versioning:
name: Update PR
needs: [create_pr_in_homebrew]
runs-on: ubuntu-latest
env:
Version: ${{ github.event.inputs.version }}
steps:
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ github.event.inputs.version }}
- name: Checkout
if: steps.semver_parser.outputs.prerelease == ''
uses: actions/checkout@v4
with:
repository: turbot/homebrew-tap
token: ${{ secrets.GH_ACCESS_TOKEN }}
ref: ${{ github.event.inputs.version }}
- name: Update live version
if: steps.semver_parser.outputs.prerelease == ''
run: |
scripts/formula_versioning.sh
git config --global user.email "[email protected]"
git config --global user.name "Puskar Basu"
git add .
git commit -m "Versioning brew formulas"
git push origin $VERSION
clean_up:
# let's clean up the artifacts.
# in case this step isn't reached,
# artifacts automatically expire after 90 days anyway
# refer:
# https://docs.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts#downloading-and-deleting-artifacts-after-a-workflow-run-is-complete
name: Clean Up Artifacts
needs: update_pr_for_versioning
runs-on: ubuntu-latest
steps:
- name: Clean up Linux Build
uses: geekyeggo/delete-artifact@v5
with:
name: build-artifact-linux
- name: Clean up Darwin Build
uses: geekyeggo/delete-artifact@v5
with:
name: build-artifact-darwin