Skip to content

Update examples

Update examples #50

Workflow file for this run

name: 'Update examples'
on:
push:
tags: [ '*' ]
workflow_dispatch:
inputs:
old:
description: |
git ref of version to be replaced with 'new'. Defaults to the first git tag lower than 'new' in v:refname sorting.
required: false
new:
description: |
git ref of version to replace 'old'. Defaults to the current git tag.
required: false
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: |
old="${{ inputs.old }}"
new="${{ inputs.new || github.ref_name }}"
echo "NEW_VERSION=$new" | tee -a $GITHUB_ENV
if [[ "$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 <github-actions@github.com>"
committer: "github-actions <github-actions@github.com>"
body: "Bump versions from ${{ env.OLD_VERSION }} to ${{ env.NEW_VERSION }}."