fix(ci): resolve debaser version dynamically in release workflow #8
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: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine next version | |
| id: version | |
| run: | | |
| latest=$(git tag -l 'v*' --sort=-v:refname | head -n1) | |
| if [ -z "$latest" ]; then | |
| next="v0.1.0" | |
| else | |
| # Strip leading 'v', increment patch | |
| base="${latest#v}" | |
| major=$(echo "$base" | cut -d. -f1) | |
| minor=$(echo "$base" | cut -d. -f2) | |
| patch=$(echo "$base" | cut -d. -f3) | |
| next="v${major}.${minor}.$((patch + 1))" | |
| fi | |
| echo "tag=$next" >> "$GITHUB_OUTPUT" | |
| echo "Next version: $next" | |
| - name: Create release tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}" | |
| git push origin "${{ steps.version.outputs.tag }}" | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24" | |
| - name: Install debaser | |
| run: | | |
| tmp=$(mktemp -d) | |
| # Resolve the latest debaser tag dynamically so the pinned asset | |
| # name never drifts out of sync with the "latest" release. | |
| ver=$(curl -fsSLI -o /dev/null -w '%{url_effective}' \ | |
| https://github.com/nficano/debaser/releases/latest | sed 's#.*/tag/##') | |
| echo "debaser version: $ver" | |
| curl -fsSL "https://github.com/nficano/debaser/releases/download/${ver}/debaser-${ver}-x86_64-unknown-linux-gnu.tar.gz" | tar xz -C "$tmp" | |
| sudo mv "$tmp"/debaser-*/debaser /usr/local/bin/ | |
| rm -rf "$tmp" | |
| - name: Generate release name | |
| id: release-name | |
| run: echo "name=$(debaser --sha ${{ github.sha }})" >> "$GITHUB_OUTPUT" | |
| - name: Login to GHCR | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Run GoReleaser | |
| uses: goreleaser/goreleaser-action@v6 | |
| with: | |
| version: latest | |
| args: release --clean | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} | |
| RELEASE_NAME: ${{ steps.release-name.outputs.name }} |