Bump Version #2
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: Bump Version | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: '新版本号 (如 v2026.2.1)' | |
| required: true | |
| jobs: | |
| bump: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT_TOKEN }} # 需要一个具有写权限的个人访问令牌 | |
| - name: Set new version to env | |
| run: | | |
| echo "NEW_VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV | |
| echo "NEW_VERSION_DATE=$(date +'%Y/%m/%d')" >> $GITHUB_ENV | |
| - name: Validate version format | |
| run: | | |
| VERSION="${{ github.event.inputs.version }}" | |
| if ! echo "$VERSION" | grep -qE '^v[0-9]{4}\.[0-9]{1,2}(\.[0-9]+)?(-rc[0-9]+)?$'; then | |
| echo "版本格式错误,应为 v2026.2.1 或 v2026.2.1-rc1" | |
| exit 1 | |
| fi | |
| - name: Set version without v | |
| run: | | |
| VERSION="${{ github.event.inputs.version }}" | |
| echo "NEW_VERSION_WITHOUT_V=${VERSION#v}" >> $GITHUB_ENV | |
| - name: Update devel/200_22.md | |
| run: | | |
| sed -i "3i## ${{ env.NEW_VERSION_DATE }} ${{ env.NEW_VERSION }} 打包" devel/200_22.md | |
| - name: Update xmake/vars.lua and Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| sed -i 's/^XMACS_VERSION="[^"]*"/XMACS_VERSION="${{ env.NEW_VERSION_WITHOUT_V }}"/' xmake/vars.lua | |
| git add . | |
| git commit -m "[200_22] bump to Mogan STEM ${{ env.NEW_VERSION }}" | |
| # 打 Tag | |
| git tag ${{ env.NEW_VERSION }} | |
| git push origin ${{ github.ref_name }} | |
| git push origin ${{ env.NEW_VERSION }} |