release.yml

 1---
 2name: Build release binaries
 3
 4on:
 5  push:
 6    tags:
 7      - "v*"
 8
 9concurrency:
10  group: release-${{ github.ref }}
11  cancel-in-progress: true
12
13permissions:
14  contents: read
15
16jobs:
17  build-and-release:
18    runs-on: "ubuntu-latest"
19    permissions:
20      # unfortunately, this is necessary for creating the release. there is a
21      # comnunity discussion tracking a request to implement a more granular
22      # permission that as of writing, has not seen any activity since 2023 [0].
23      #
24      # [0]: https://github.com/orgs/community/discussions/68252
25      contents: write
26    steps:
27      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28        with:
29          persist-credentials: false
30
31      - name: Setup minimal git config
32        run: |
33          git config --global user.email "bot@git-bug.org"
34          git config --global user.name "git-bug"
35
36      - name: Test with go
37        run: nix-shell --run "go test -v -bench=. ./..."
38
39      - name: Determine version string
40        id: version-string
41        run: |
42          v=$(git describe --match='v*' --always --dirty --broken)
43          echo "value=${v}" >> "$GITHUB_OUTPUT"
44
45      - name: Build release binaries
46        env:
47          VERSION: ${{ steps.version-string.outputs.value }}
48        run: |
49          nix-build -A release --argstr version "$VERSION"
50
51          # this is the symlink to the native output artifact, built by the
52          # `default` derivation when the host system is linux or macos. because
53          # this job runs on 64-bit linux, we manually rename it so that the
54          # artifact uploaded to the GitHub Release is appropriately named for
55          # end users
56          mv ./result/bin/git-bug ./result/bin/git-bug-linux-amd64
57          echo '- version built: `${VERSION}`' >> "$GITHUB_STEP_SUMMARY"
58
59      - uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
60        with:
61          files: result/*
62