chore(release): 0.5.0 #41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker publish | |
| # Builds the multi-arch (amd64 + arm64) image from the repo Dockerfile. | |
| # * PR → build only (catches cross-arch build breaks early, e.g. an | |
| # amd64-only step slipping back in). Nothing is pushed. | |
| # * push to main → push `:edge` + `:sha-<short>` (bleeding edge). | |
| # * push a `vX.Y.Z` tag → push `:X.Y.Z`, `:X.Y`, and `:latest`, then cut a GitHub | |
| # Release. So `:latest` always tracks the newest *release*, | |
| # never raw main. | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*.*.*'] | |
| pull_request: | |
| concurrency: | |
| group: docker-publish-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| REGISTRY: ghcr.io | |
| # Hardcoded lowercase — GHCR tags reject the repo's actual "Calnode/calnode" | |
| # casing (${{ github.repository }} would break the push). | |
| IMAGE_NAME: calnode/calnode | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-qemu-action@v3 | |
| - uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GHCR | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # Computes the tag set from the git ref: | |
| # main → edge, sha-<short> | |
| # vX.Y.Z tag → X.Y.Z, X.Y, and latest (latest=auto only fires on a semver tag) | |
| - name: Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=edge,branch=main | |
| type=sha,enable={{is_default_branch}} | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| - name: Build (push on main and on tags) | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| VERSION=${{ steps.meta.outputs.version }} | |
| release: | |
| # Only on a version tag, and only once the image built + pushed. | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Pull the matching version's section out of CHANGELOG.md for the release body, | |
| # so the GitHub Release and the CHANGELOG stay identical. Index-based (not a `\[` | |
| # regex) so it's portable across awk flavours. Falls back to GitHub's | |
| # auto-generated notes if there's no CHANGELOG entry for the tag. | |
| - name: Extract release notes from CHANGELOG | |
| id: notes | |
| run: | | |
| version="${GITHUB_REF_NAME#v}" | |
| awk -v tag="## [${version}]" ' | |
| index($0, tag)==1 {cap=1; next} | |
| index($0, "## [")==1 && cap==1 {cap=0} | |
| substr($0,1,1)=="[" && cap==1 {exit} | |
| cap {print} | |
| ' CHANGELOG.md > release-notes.md | |
| if [ -s release-notes.md ]; then | |
| echo "have_notes=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "have_notes=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| # Preinstalled gh CLI + GITHUB_TOKEN (no third-party action — keeps the | |
| # supply-chain surface small). | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if [ "${{ steps.notes.outputs.have_notes }}" = "true" ]; then | |
| gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" \ | |
| --notes-file release-notes.md --verify-tag | |
| else | |
| gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" \ | |
| --generate-notes --verify-tag | |
| fi |