fix: release workflow #3
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: Version Preview | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| types: [opened, synchronize] | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| jobs: | |
| preview: | |
| name: Preview Next Version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup | |
| run: | | |
| go install github.com/caarlos0/svu@v1.12.0 | |
| echo "$HOME/go/bin" >> $GITHUB_PATH | |
| - name: Calculate versions | |
| id: calc | |
| run: | | |
| CURRENT=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | |
| NEXT=$(svu next) | |
| echo "current=$CURRENT" >> $GITHUB_OUTPUT | |
| echo "next=$NEXT" >> $GITHUB_OUTPUT | |
| - name: Post PR comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const body = `## 📋 Version Preview | |
| **Current:** ${{ steps.calc.outputs.current }} | |
| **Next:** ${{ steps.calc.outputs.next }} | |
| *Version will be applied when PR is merged and release triggered.*`; | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const botComment = comments.find(c => | |
| c.user.type === 'Bot' && c.body.includes('Version Preview')); | |
| if (botComment) { | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body | |
| }); | |
| } |