Update examples #49
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: 'Update examples' | |
| on: | |
| push: | |
| tags: [ '*' ] | |
| workflow_dispatch: | |
| inputs: | |
| old: | |
| description: 'Git ref of version to replace. Leave empty for auto-detect from git tags.' | |
| required: false | |
| new: | |
| description: 'Branch or tag' | |
| required: true | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| update-examples: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 'Checkout' | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - run: pip install -r .github/scripts/requirements.txt | |
| - name: 'Get versions' | |
| run: | | |
| new="${{ inputs.new || github.ref_name }}" | |
| echo "NEW_VERSION=$new" | tee -a $GITHUB_ENV | |
| if [[ "${{ inputs.old }}" == "" ]]; then | |
| echo "Auto-detecting old version from git tags" | |
| # Get previous version from descending tag list | |
| old="$(git tag --sort=-v:refname | grep -A1 "$new" | tail -1)" | |
| fi | |
| echo "OLD_VERSION=$old" | tee -a $GITHUB_ENV | |
| - name: 'Update version in all files' | |
| run: ./.github/scripts/replace_string.py ./ "$OLD_VERSION" "$NEW_VERSION" | |
| - name: 'Create PR' | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| base: 'main' | |
| branch: "replace-${{ env.OLD_VERSION }}-${{ env.NEW_VERSION }}" | |
| title: "Bump examples and badges to ${{ env.NEW_VERSION }}" | |
| author: "github-actions <[email protected]>" | |
| committer: "github-actions <[email protected]>" | |
| body: "Bump versions from ${{ env.OLD_VERSION }} to ${{ env.NEW_VERSION }}." |