From 1bb249e4ed649c75adaca9c4479694762385f532 Mon Sep 17 00:00:00 2001 From: Brad Lugo Date: Mon, 8 Jul 2024 00:01:20 -0700 Subject: [PATCH] fix(ci): handle release builds in GHA CI workflow --- .github/actions/handle-tagged-build/action.yaml | 10 ++++++++++ .github/workflows/ci.yaml | 6 ++++++ scripts/ci/lib.sh | 15 +++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 .github/actions/handle-tagged-build/action.yaml diff --git a/.github/actions/handle-tagged-build/action.yaml b/.github/actions/handle-tagged-build/action.yaml new file mode 100644 index 000000000..3a95ccfff --- /dev/null +++ b/.github/actions/handle-tagged-build/action.yaml @@ -0,0 +1,10 @@ +name: Handle tagged build +description: Handle tagged build +runs: + using: composite + steps: + - name: Handle tagged build + run: | + source ./scripts/ci/lib.sh + handle_gha_tagged_build + shell: bash diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 171a1ca7f..8227e04c4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -52,6 +52,8 @@ jobs: - name: Cache Go dependencies uses: ./.github/actions/cache-go-dependencies + - uses: ./.github/actions/handle-tagged-build + - name: Build updater (amd64) run: make build-updater @@ -83,6 +85,8 @@ jobs: - name: Cache Go dependencies uses: ./.github/actions/cache-go-dependencies + - uses: ./.github/actions/handle-tagged-build + - name: Build Scanner run: make GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} scanner-build-nodeps @@ -371,6 +375,8 @@ jobs: - uses: ./.github/actions/job-preamble + - uses: ./.github/actions/handle-tagged-build + - name: Set up QEMU uses: docker/setup-qemu-action@v3 diff --git a/scripts/ci/lib.sh b/scripts/ci/lib.sh index 1902dd205..366bb31ba 100755 --- a/scripts/ci/lib.sh +++ b/scripts/ci/lib.sh @@ -705,6 +705,21 @@ handle_release_runs() { fi } +handle_gha_tagged_build() { + if [[ -z "${GITHUB_REF:-}" ]]; then + echo "No GITHUB_REF in env" + exit 0 + fi + echo "GITHUB_REF: ${GITHUB_REF}" + if [[ "${GITHUB_REF:-}" =~ ^refs/tags/ ]]; then + tag="${GITHUB_REF#refs/tags/*}" + echo "This is a tagged build: $tag" + echo "RELEASE_TAG=$tag" >> "$GITHUB_ENV" + else + echo "This is not a tagged build" + fi +} + store_test_results() { if [[ "$#" -ne 2 ]]; then die "missing args. usage: store_test_results "