[200_69] fix ci_bump_version.yml #17
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: '新版本号 (当前版本是 17.11.47)' | ||
| required: true | ||
| permissions: | ||
| contents: write | ||
| workflows: write | ||
| jobs: | ||
| bump: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Get current version | ||
| run: | | ||
| CURRENT_VERSION=$(grep -oP 'set_version \("\K[^"]+' xmake.lua) | ||
| echo "Current version: $CURRENT_VERSION" | ||
| echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV | ||
| - 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 '^[0-9]+\.[0-9]+\.[0-9]+$'; then | ||
| echo "版本格式错误,应为 17.11.35 格式" | ||
| exit 1 | ||
| fi | ||
| - name: Update version in files | ||
| run: | | ||
| # Update xmake.lua | ||
| sed -i "s/^set_version (\"[^\"]*\")/set_version (\"${{ env.NEW_VERSION }}\")/" xmake.lua | ||
| # Update ci_bump_version.yml description | ||
| sed -i 's/当前版本是 [0-9]\+\.[0-9]\+\.[0-9]\+/当前版本是 ${{ env.NEW_VERSION }}/' .github/workflows/ci_bump_version.yml | ||
| # Update src/goldfish.hpp | ||
| sed -i "s/#define GOLDFISH_VERSION \"[^\"]*\"/#define GOLDFISH_VERSION \"${{ env.NEW_VERSION }}\"/" src/goldfish.hpp | ||
| # Update README.md | ||
| sed -i -E "s/Goldfish Scheme [0-9]+\.[0-9]+\.[0-9]+/Goldfish Scheme ${{ env.NEW_VERSION }}/g" README.md | ||
| # Update README_ZH.md | ||
| sed -i -E "s/Goldfish Scheme [0-9]+\.[0-9]+\.[0-9]+/Goldfish Scheme ${{ env.NEW_VERSION }}/g" README_ZH.md | ||
| # Update pkgs/goldfish.nix | ||
| sed -i "s/version = \"[^\"]*\"/version = \"${{ env.NEW_VERSION }}\"/" pkgs/goldfish.nix | ||
| - name: Update devel/200_1.md | ||
| run: | | ||
| header="## ${{ env.NEW_VERSION_DATE }} Goldfish Scheme v${{ env.NEW_VERSION }}" | ||
| sed -i "3i$header" devel/200_1.md | ||
| - name: Git commit and tag | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git add . | ||
| git commit -m "[200_1] Bump version to ${{ env.NEW_VERSION }}" | ||
| # 打 Tag (带 v 前缀) | ||
| git tag v${{ env.NEW_VERSION }} | ||
| git push origin ${{ github.ref_name }} | ||
| git push origin v${{ env.NEW_VERSION }} | ||