Update CI to generate release notes from tag #7
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ["v*"] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - run: go test ./... | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Build doubletake | |
| run: CGO_ENABLED=0 go build -ldflags='-s -w -extldflags=-static' -o doubletake ./cmd/doubletake | |
| - name: Build doubletake-ctl | |
| run: CGO_ENABLED=0 go build -ldflags='-s -w -extldflags=-static' -o doubletake-ctl ./cmd/doubletake-ctl | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries | |
| path: | | |
| doubletake | |
| doubletake-ctl | |
| release: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: binaries | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract release notes from tag | |
| id: notes | |
| run: | | |
| # Get the annotated tag message (or commit message for lightweight tags) | |
| NOTES=$(git tag -l --format='%(contents)' "${GITHUB_REF_NAME}") | |
| if [ -z "$NOTES" ]; then | |
| NOTES=$(git log -1 --format='%B' "${GITHUB_REF_NAME}") | |
| fi | |
| { | |
| echo 'RELEASE_NOTES<<EOF' | |
| echo "$NOTES" | |
| echo 'EOF' | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| body: ${{ steps.notes.outputs.RELEASE_NOTES }} | |
| files: | | |
| doubletake | |
| doubletake-ctl |