🚀 Restore Go v2.0.0 implementation to main branch #26
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: Auto Tag on Merge | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| paths-ignore: | |
| - "**/*.md" | |
| - "docs/**" | |
| - "LICENSE" | |
| jobs: | |
| create-tag: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Git | |
| run: | | |
| git config --global user.name 'GitHub Actions' | |
| git config --global user.email 'actions@github.com' | |
| - name: Get current date | |
| id: date | |
| run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | |
| - name: Get PR title and number | |
| id: pr_info | |
| run: | | |
| PR_TITLE="${{ github.event.pull_request.title }}" | |
| PR_NUMBER="${{ github.event.pull_request.number }}" | |
| # Convert PR title to a tag-friendly format | |
| TAG_SUFFIX=$(echo "$PR_TITLE" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//' | sed 's/-$//' | cut -c1-30) | |
| echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT | |
| echo "tag_suffix=$TAG_SUFFIX" >> $GITHUB_OUTPUT | |
| - name: Create tag | |
| id: tag | |
| run: | | |
| # Get the latest version tag | |
| LATEST_TAG=$(git tag -l "v*" | grep -v "-" | sort -V | tail -n 1) | |
| # If no tag exists, start with v1.0.0 | |
| if [ -z "$LATEST_TAG" ]; then | |
| LATEST_TAG="v1.0.0" | |
| fi | |
| # Extract version components | |
| MAJOR=$(echo $LATEST_TAG | sed 's/v\([0-9]*\)\..*/\1/') | |
| MINOR=$(echo $LATEST_TAG | sed 's/v[0-9]*\.\([0-9]*\)\..*/\1/') | |
| PATCH=$(echo $LATEST_TAG | sed 's/v[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/') | |
| # Increment patch version | |
| PATCH=$((PATCH + 1)) | |
| # Create new version tag | |
| NEW_TAG="v$MAJOR.$MINOR.$PATCH" | |
| # Add PR info to tag message | |
| TAG_MESSAGE="Release $NEW_TAG from PR #${{ steps.pr_info.outputs.pr_number }}: ${{ github.event.pull_request.title }}" | |
| # Create and push tag | |
| git tag -a "$NEW_TAG" -m "$TAG_MESSAGE" | |
| git push origin "$NEW_TAG" | |
| echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.tag.outputs.new_tag }} | |
| name: Release ${{ steps.tag.outputs.new_tag }} | |
| body: | | |
| ## Release ${{ steps.tag.outputs.new_tag }} | |
| This release was automatically generated from PR #${{ steps.pr_info.outputs.pr_number }}: ${{ github.event.pull_request.title }} | |
| ### Changes included: | |
| ${{ github.event.pull_request.body }} | |
| ### Merged by: | |
| @${{ github.event.pull_request.merged_by.login }} | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |