diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9207a54f..7c31a1a0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,10 +49,29 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} release-type: simple bump-minor-pre-major: true - # Checkout and test + # Checkout - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 + # Tag + # If a release was created, tag `vX.Y.Z` synchronously which: + # 1. Triggers release-please to create draft release, allowing manual + # proofreading (and probably editing) of release notes. + # (often raw commit messages are a bit overwhelming, overly granular + # or at least could use some context when included as release notes). + # 2. Ensures the tag exists for subsequent action tasks which rely on + # this metadata, such as including version in release binaries. + # The release-please action does add this tag, but asynchronously. + # Note that tag is created annotated such that it shows tagging metadata + # when queried rather than just the associated commit metadata. + - name: tag + if: ${{ steps.release.outputs.release_created }} + run: | + git config user.name github-actions[bot] + git tag -d v${{steps.release.outputs.major}}.${{steps.release.outputs.minor}}.${{steps.release.outputs.patch}} || true + git push origin :v${{steps.release.outputs.major}}.${{steps.release.outputs.minor}}.${{steps.release.outputs.patch}} || true + git tag -a v${{steps.release.outputs.major}}.${{steps.release.outputs.minor}}.${{steps.release.outputs.patch}} -m "Release v${{steps.release.outputs.major}}.${{steps.release.outputs.minor}}.${{steps.release.outputs.patch}}" + git push origin v${{steps.release.outputs.major}}.${{steps.release.outputs.minor}}.${{steps.release.outputs.patch}} || true + - uses: actions/setup-go@v2 - name: Install pkger run: | curl -s -L -o pkger.tgz ${{ needs.test.outputs.pkger }} @@ -63,7 +82,14 @@ jobs: run: make cross-platform env: PKGER: "./pkger" - VERS: ${{ steps.release.outputs.tag_name }} + # NOTE: + # release-please adds the version asynchronously. Without using the + # synchonous tagging step above, the version can be explicitly passed + # to the build using the following environment variable. However this + # has the side-effect of causing inter-relese binaries to not include + # verbose version information, because the special version `tip` is + # overriden with a blank string in those cases. + # VERS: ${{ steps.release.outputs.tag_name }} # Upload all build artifacts whether it's a release or not - uses: actions/upload-artifact@v2 diff --git a/Makefile b/Makefile index b57fb626..c0556512 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,8 @@ DATE := $(shell date -u +"%Y%m%dT%H%M%SZ") HASH := $(shell git rev-parse --short HEAD 2>/dev/null) VTAG := $(shell git tag --points-at HEAD) # a VERS environment variable takes precedence over git tags -# due to issues with release-please-action tagging not working -# as expected in CI +# and is necessary with release-please-action which tags asynchronously +# unless explicitly, synchronously tagging as is done in ci.yaml VERS ?= $(shell [ -z $(VTAG) ] && echo 'tip' || echo $(VTAG) ) TEMPLATE_DIRS=$(shell find templates -type d)