-rw-r--r-- .github/workflows/release.yaml
1 name: Release 2 3 on: 4 push: 5 branches: [ master ] 6 7 jobs: 8 release: 9 runs-on: ubuntu-latest 10 permissions: 11 contents: write 12 13 steps: 14 - uses: actions/checkout@v4 15 with: 16 fetch-depth: 0 17 18 - uses: haskell-actions/setup@v2 19 with: 20 enable-stack: true 21 22 - uses: actions/cache@v4 23 with: 24 path: | 25 ~/.stack 26 .stack-work 27 key: ${{ runner.os }}-stack-release-${{ hashFiles('stack.yaml.lock', 'gitja.cabal') }} 28 restore-keys: | 29 ${{ runner.os }}-stack-release- 30 31 - name: Build release binary 32 run: | 33 stack build --ghc-options="-O2" --copy-bins --local-bin-path ./dist 34 35 - name: Strip binary 36 run: | 37 strip ./dist/gitja 38 mv ./dist/gitja ./dist/gitja-linux-x86_64 39 40 - name: Determine version 41 id: version 42 env: 43 GH_TOKEN: ${{ github.token }} 44 run: | 45 VERSION=$(grep -m1 '^version:' gitja.cabal | awk '{print $2}') 46 TAG="v${VERSION}" 47 if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then 48 # Version wasn't bumped since the last release: disambiguate with 49 # the short SHA so this commit still gets its own release. 50 TAG="${TAG}-$(git rev-parse --short HEAD)" 51 fi 52 echo "tag=$TAG" >> "$GITHUB_OUTPUT" 53 54 - name: Create release 55 env: 56 GH_TOKEN: ${{ github.token }} 57 TAG: ${{ steps.version.outputs.tag }} 58 run: | 59 gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" \ 60 --title "$TAG" --generate-notes 61 gh release upload "$TAG" --repo "$GITHUB_REPOSITORY" \ 62 ./dist/gitja-linux-x86_64 63