github.heygears.com/openimsdk/tools@v0.0.49/.github/workflows/auto-tag.yml (about)

     1  # Copyright © 2023 OpenIM. All rights reserved.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #     http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  
    15  name: OpenIM Create Tag
    16  
    17  on:
    18    issue_comment:
    19      types: [created]
    20    pull_request_review_comment:
    21      types: [created]
    22  
    23  jobs:
    24    create_tag:
    25      runs-on: ubuntu-latest
    26      if: startsWith(github.event.comment.body, '/create tag')
    27      steps:
    28        - name: Checkout code
    29          uses: actions/checkout@v4
    30  
    31        - name: Validate version number and get comment
    32          id: validate
    33          run: |
    34            COMMENT="${{ github.event.comment.body }}"
    35            VERSION=$(echo $COMMENT | cut -d ' ' -f 3)
    36            TAG_COMMENT=$(echo $COMMENT | cut -d '"' -f 2)
    37            if [[ $VERSION =~ ^v([0-9]+\.){2}[0-9]+$ ]]; then
    38              echo "version=$VERSION" >> $GITHUB_STATE
    39              echo "tag_comment=$TAG_COMMENT" >> $GITHUB_STATE
    40            else
    41              echo "Invalid version number."
    42              exit 1
    43            fi
    44  
    45        - name: Create a new tag
    46          env:
    47            GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
    48          run: |
    49            source $GITHUB_STATE
    50            git tag -a $VERSION -m "$tag_comment"
    51            git push origin $VERSION
    52            echo "tag_created=$VERSION" >> $GITHUB_OUTPUT