Merge pull request #27 from jfjrh2014/feat/compliance-policy-and-output #19
Workflow file for this run
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: | |
| push: | |
| tags: | |
| - "v*" | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| name: Test before release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Run tests | |
| run: go test -v -race ./... | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: go.mod | |
| - name: Get version info | |
| id: version | |
| run: | | |
| # Extract version from tag (remove 'v' prefix) | |
| VERSION=${GITHUB_REF_NAME#v} | |
| COMMIT=$(git rev-parse --short HEAD) | |
| DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "commit=$COMMIT" >> $GITHUB_OUTPUT | |
| echo "date=$DATE" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION, Commit: $COMMIT, Date: $DATE" | |
| - name: Update version.go | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| COMMIT="${{ steps.version.outputs.commit }}" | |
| DATE="${{ steps.version.outputs.date }}" | |
| # Update version.go with release values | |
| sed -i "s/Version = \"dev\"/Version = \"$VERSION\"/" internal/version/version.go | |
| sed -i "s/Commit = \"none\"/Commit = \"$COMMIT\"/" internal/version/version.go | |
| sed -i "s/Date = \"unknown\"/Date = \"$DATE\"/" internal/version/version.go | |
| sed -i "s/BuildSource = \"source\"/BuildSource = \"release\"/" internal/version/version.go | |
| echo "Updated version.go:" | |
| cat internal/version/version.go | |
| - name: Vendor dependencies | |
| run: go mod vendor | |
| - name: Install Syft | |
| uses: anchore/sbom-action/download-syft@v0 | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| distribution: goreleaser | |
| version: "~> v2" | |
| args: release --clean --skip=validate | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} |