Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[re-post][SARC-373] incrémenter la version de SARC pour pip (incrementer z dans x.y.z à chaque PR mergée) #157

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Inspired from:
# https://gist.github.com/Broxzier/1ed980b8b3822d213e98042fc6a92040

name: Update package version number "z" in "x.y.z" on PR merge
on:
pull_request:
branches:
- master
types:
- closed

jobs:
update_package_version:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: checkout
uses: actions/checkout@v4
with:
# Fetch full depth, otherwise the last step overwrites the last commit parent, essentially removing the graph.
fetch-depth: 0

- name: Update pyproject version
run: |
echo prev_package_version=$(grep -E "version = \"[0-9+]\.[0-9+]\.[0-9]+\"" pyproject.toml | sed 's/version = //g') >> $GITHUB_ENV

sed -ri 's/(version = )\"([0-9]+)\.([0-9]+)\.([0-9]+)\"/echo "\1\\\"\2.\3.$((\4+1))\\\""/ge' pyproject.toml

echo next_package_version=$(grep -E "version = \"[0-9+]\.[0-9+]\.[0-9]+\"" pyproject.toml | sed 's/version = //g') >> $GITHUB_ENV

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: master
commit_message: "Update package version: ${{ env.prev_package_version }} -> ${{ env.next_package_version }}"
file_pattern: 'pyproject.toml'