Release #9
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: Release | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Compute next version | |
| id: version | |
| run: | | |
| source .ci/release.sh | |
| LAST_TAG="$(get_last_tag)" | |
| CHANGELOG="$(get_changelog "$LAST_TAG")" | |
| NEXT_VERSION="$(compute_next_version "$LAST_TAG" "$CHANGELOG")" | |
| echo "version=$NEXT_VERSION" >> "$GITHUB_OUTPUT" | |
| # Multiline changelog output | |
| echo "changelog<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$CHANGELOG" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| echo "Next version: $NEXT_VERSION" | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.26' | |
| - name: Cross-compile binaries | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| LDFLAGS: -s -w -X main.version=${{ steps.version.outputs.version }} | |
| run: | | |
| mkdir -p dist | |
| targets=( | |
| "darwin amd64 " | |
| "darwin arm64 " | |
| "linux amd64 " | |
| "linux arm64 " | |
| "windows amd64 .exe" | |
| ) | |
| for target in "${targets[@]}"; do | |
| read -r os arch ext <<< "$target" | |
| output="dist/hourgit-${os}-${arch}-${VERSION}${ext}" | |
| echo "Building $output ..." | |
| CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" \ | |
| go build -ldflags="$LDFLAGS" -o "$output" ./cmd/hourgit | |
| done | |
| - name: Generate checksums | |
| run: | | |
| cd dist | |
| sha256sum * > SHA256SUMS | |
| cat SHA256SUMS | |
| - name: Create tag | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "$VERSION" -m "Release $VERSION" | |
| git push origin "$VERSION" | |
| - name: Create GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| VERSION: ${{ steps.version.outputs.version }} | |
| CHANGELOG: ${{ steps.version.outputs.changelog }} | |
| run: | | |
| gh release create "$VERSION" dist/* \ | |
| --title "$VERSION" \ | |
| --notes "$CHANGELOG" |