Version #14
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: Version | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version number (e.g., 1.1.1)' | |
| required: true | |
| target_branch: | |
| description: 'Target branch for the PR' | |
| required: false | |
| default: 'main' | |
| jobs: | |
| update_docs_version: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT_TOKEN }} | |
| fetch-depth: 1 | |
| - name: Update version | |
| run: | | |
| CONFIG_FILE="docs/.vitepress/config.ts" | |
| VERSION="${{ github.event.inputs.version }}" | |
| sed -i "s/text: \"[0-9]\+\.[0-9]\+\.[0-9]\+\",/text: \"${VERSION}\",/" "$CONFIG_FILE" | |
| grep -q "text: \"${VERSION}\"," "$CONFIG_FILE" || { | |
| echo "failed to update version" | |
| exit 1 | |
| } | |
| - name: Create Pull Request | |
| id: create_docs_pr | |
| uses: peter-evans/[email protected] | |
| with: | |
| token: ${{ secrets.PAT_TOKEN }} | |
| commit-message: "chore(release): update version to ${{ github.event.inputs.version }}" | |
| branch: update-docs-version/${{ github.event.inputs.version }} | |
| title: "Update docs version to ${{ github.event.inputs.version }}" | |
| body: | | |
| update the version in config to ${{ github.event.inputs.version }}. | |
| base: ${{ github.event.inputs.target_branch }} | |
| delete-branch: false | |
| - name: Install GitHub CLI | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gh | |
| - name: Merge PR | |
| if: steps.create_docs_pr.outputs.pull-request-number != '' | |
| run: | | |
| gh pr merge update-docs-version/${{ github.event.inputs.version }} --squash --delete-branch | |
| env: | |
| GH_TOKEN: ${{ secrets.PAT_TOKEN }} |