From 45eea50f712783aab5d389b82e685800684f9c4a Mon Sep 17 00:00:00 2001 From: Dimitri Koshkin Date: Mon, 10 Apr 2023 19:48:40 -0700 Subject: [PATCH] build: Tag release with a stable version (#12) --- .../status-writer-released}/action.yaml | 2 +- .github/workflows/checks.yml | 2 +- .../workflows/release-checks.yaml | 26 +++++++------------ README.md | 6 ++--- hack/retag-release.sh | 11 +++----- make/goreleaser.mk | 9 ++++--- 6 files changed, 25 insertions(+), 31 deletions(-) rename {.github-sample/composite-actions/status-writer => .github/composite-actions/status-writer-released}/action.yaml (97%) rename .github-sample/workflows/influxdb-checks.yaml => .github/workflows/release-checks.yaml (73%) diff --git a/.github-sample/composite-actions/status-writer/action.yaml b/.github/composite-actions/status-writer-released/action.yaml similarity index 97% rename from .github-sample/composite-actions/status-writer/action.yaml rename to .github/composite-actions/status-writer-released/action.yaml index c63585d..1b3fe0b 100644 --- a/.github-sample/composite-actions/status-writer/action.yaml +++ b/.github/composite-actions/status-writer-released/action.yaml @@ -36,7 +36,7 @@ runs: using: "composite" steps: - name: Push job status and other metadata to a remote backend - uses: dkoshkin/status-writer-action@v0.1.0 + uses: dkoshkin/status-writer-action@alpha with: # select the backend to use backend: "${{ inputs.backend }}" diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 67e720e..121e133 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -118,5 +118,5 @@ jobs: influxdb_bucket: "${{ secrets.INFLUXDB_BUCKET }}" # set the status and additional metadata tags repository: "${{ github.repository }}" - status: ${{ job.status }} + status: "${{ job.status }}" tags: "workflow=${{ github.workflow }},job=${{ github.job }},ref=${{ github.ref_name }}" diff --git a/.github-sample/workflows/influxdb-checks.yaml b/.github/workflows/release-checks.yaml similarity index 73% rename from .github-sample/workflows/influxdb-checks.yaml rename to .github/workflows/release-checks.yaml index 13e693a..2eceee5 100644 --- a/.github-sample/workflows/influxdb-checks.yaml +++ b/.github/workflows/release-checks.yaml @@ -1,32 +1,26 @@ # Copyright 2023 Dimitri Koshkin. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -name: checks +name: release-checks on: push: - branches: - - main - pull_request: - types: - - opened - - synchronize - - reopened - branches: - - main + # run on stable tags only + tags: + - alpha + - v1 + workflow_dispatch: + workflow_call: jobs: - unit-test: + test-with-influxdb: runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v3 - - name: Run unit tests - run: make test - - name: Run status-writer-action action locally - uses: ./.github/composite-actions/status-writer + uses: ./.github/composite-actions/status-writer-released if: always() with: # select the backend to use @@ -38,5 +32,5 @@ jobs: influxdb_bucket: "${{ secrets.INFLUXDB_BUCKET }}" # set the status and additional metadata tags repository: "${{ github.repository }}" - status: ${{ job.status }} + status: "${{ job.status }}" tags: "workflow=${{ github.workflow }},job=${{ github.job }},ref=${{ github.ref_name }}" diff --git a/README.md b/README.md index 7dd4a8c..d2a40ba 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Write GitHub Action job status to a remote backend. This project currently supports: -- [InfluxDB](https://www.influxdata.com/). +- [InfluxDB](https://www.influxdata.com/) ## Prerequisites @@ -21,7 +21,7 @@ Add the following step to your GitHub Action workflows for all jobs that you wou ```yaml - name: Push job status and other metadata to a remote backend # always run this step, even if previous steps fail - uses: dkoshkin/status-writer-action@v0.1.0 + uses: dkoshkin/status-writer-action@alpha # always run this step, even if previous steps fail if: always() with: @@ -38,7 +38,7 @@ Add the following step to your GitHub Action workflows for all jobs that you wou tags: "workflow=${{ github.workflow }},job=${{ github.job }},ref=${{ github.ref_name }}" ``` -See sample workflows in [./.github-sample](./.github-sample) +See sample workflows in [.github/workflows/release-checks.yaml](.github/workflows/release-checks.yaml) that use this GitHub Action as a [composite action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action). There will be a sample workflow for each supported backend. diff --git a/hack/retag-release.sh b/hack/retag-release.sh index ae68ead..4918c10 100755 --- a/hack/retag-release.sh +++ b/hack/retag-release.sh @@ -2,17 +2,14 @@ set -euo pipefail IFS=$'\n\t' -# This script re-tags a release branch after the binaries have been committed. -# It is intended to be run by the CI system after a successful release +# This script re-tags a release branch with a stable version after the binaries have been committed. +# It is intended to be run by the CI system after a successful release. -# Usage: retag-release.sh +# Usage: retag-release.sh +# Example: retag-release.sh v1 echo "Re-tagging ${1}" # Use -f as the tag will already exist git tag -a -m "${1}" "${1}" -f git push origin "${1}" -f - -# Tag on main so the next release can calculate release notes. -git tag -a -m "Will be used by the next release to calculate the release notes" "${1}-rn" HEAD~"${2}" -git push origin "${1}-rn" diff --git a/make/goreleaser.mk b/make/goreleaser.mk index 33d0889..7a47ec4 100644 --- a/make/goreleaser.mk +++ b/make/goreleaser.mk @@ -10,6 +10,9 @@ ifndef GORELEASER_CURRENT_TAG export GORELEASER_CURRENT_TAG=$(GIT_TAG) endif +# a stable tag to re-tag the release branches +STABLE_TAG="alpha" + .PHONY: build-snapshot build-snapshot: ## Builds a snapshot with goreleaser build-snapshot: install-tool.goreleaser install-tool.golang ; $(info $(M) building snapshot $*) @@ -30,10 +33,10 @@ release: install-tool.goreleaser install-tool.golang ; $(info $(M) building rele --parallelism=$(GORELEASER_PARALLELISM) \ --timeout=60m \ $(GORELEASER_FLAGS) - # force push the tag on the release branch after committing binaries + # force push a stable tag on the release branch after committing binaries # GoReleaser after hooks are a paid feature, doing it here instead - # 4 is the number of commits (e.g. binaries) in the release branch - ./hack/retag-release.sh $(GORELEASER_CURRENT_TAG) 4 + ./hack/retag-release.sh $(STABLE_TAG) + ./hack/retag-release.sh "$(GORELEASER_CURRENT_TAG)-action" .PHONY: release-snapshot release-snapshot: ## Builds a snapshot release with goreleaser