Merge pull request #20 from chatbotkit/next #4
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
| # Auto-tag when merging to main | |
| # | |
| # Reads the version from the VERSION file and, if the matching tag does not | |
| # already exist, creates and pushes it. For a Go module the tag *is* the | |
| # release, so this is what makes `go get @latest` / pinned versions resolve. | |
| name: Tag Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| tag: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| actions: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get version from VERSION file | |
| id: version | |
| run: | | |
| if [ -f VERSION ]; then | |
| VERSION=$(cat VERSION) | |
| else | |
| VERSION="0.0.0" | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Version: $VERSION" | |
| - name: Check if tag exists | |
| id: check_tag | |
| run: | | |
| if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "Tag v${{ steps.version.outputs.version }} already exists" | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| echo "Tag v${{ steps.version.outputs.version }} does not exist" | |
| fi | |
| - name: Create and push tag | |
| if: steps.check_tag.outputs.exists == 'false' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}" | |
| git push origin "v${{ steps.version.outputs.version }}" | |
| - name: Trigger release workflow | |
| if: steps.check_tag.outputs.exists == 'false' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'release.yml', | |
| ref: 'v${{ steps.version.outputs.version }}' | |
| }) |