|
a |
|
b/.github/workflows/bump_version.yml |
|
|
1 |
--- |
|
|
2 |
name: Bump version |
|
|
3 |
on: |
|
|
4 |
push: |
|
|
5 |
branches: |
|
|
6 |
- master |
|
|
7 |
|
|
|
8 |
jobs: |
|
|
9 |
build: |
|
|
10 |
runs-on: ubuntu-latest |
|
|
11 |
steps: |
|
|
12 |
- name: Checkout main branch |
|
|
13 |
uses: actions/checkout@v4 |
|
|
14 |
|
|
|
15 |
- name: Update changelog |
|
|
16 |
uses: release-drafter/release-drafter@v5 |
|
|
17 |
id: release-drafter |
|
|
18 |
env: |
|
|
19 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
|
20 |
|
|
|
21 |
# Can replace the below with (until pipeline description) with |
|
|
22 |
# khanlab/actions/.github/workflows/workflow-version_task-semverGithub.yml |
|
|
23 |
# after adding PAT token |
|
|
24 |
- name: Get previous release version |
|
|
25 |
run: | |
|
|
26 |
echo "PREV_VER=$(cat pyproject.toml | grep -o -E '(version\s=\s)([[:punct:]])([0-9]+\.[0-9]+\.[0-9]+.+)([[:punct:]])' | cut -d ' ' -f 3 | tr -d '"')" >> $GITHUB_ENV |
|
|
27 |
|
|
|
28 |
- name: Get previous bump version |
|
|
29 |
env: |
|
|
30 |
PREV_VER: ${{ env.PREV_VER }} |
|
|
31 |
run: | |
|
|
32 |
if [[ "$PREV_VER" != *"-pre."* ]]; then |
|
|
33 |
echo "OLD_BUMP=0" >> $GITHUB_ENV |
|
|
34 |
else |
|
|
35 |
echo "OLD_BUMP=$(echo $PREV_VER | cut -d '.' -f 4)" >> $GITHUB_ENV |
|
|
36 |
fi |
|
|
37 |
|
|
|
38 |
- name: Bump version |
|
|
39 |
env: |
|
|
40 |
BUMP_VER: ${{ env.OLD_BUMP }} |
|
|
41 |
run: | |
|
|
42 |
echo "NEW_BUMP=$(($BUMP_VER + 1))" >> $GITHUB_ENV |
|
|
43 |
|
|
|
44 |
- name: Update version in pyproject.toml |
|
|
45 |
uses: jacobtomlinson/gha-find-replace@v3 |
|
|
46 |
with: |
|
|
47 |
include: "pyproject.toml" |
|
|
48 |
find: 'version = "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"' |
|
|
49 |
replace: 'version = "${{ steps.release-drafter.outputs.name }}-pre.${{ env.NEW_BUMP }}"' |
|
|
50 |
|
|
|
51 |
- name: Update version in pipeline_description (not actually used) |
|
|
52 |
uses: jacobtomlinson/gha-find-replace@v3 |
|
|
53 |
with: |
|
|
54 |
include: "hippunfold/pipeline_description.json" |
|
|
55 |
find: '"Version": "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"' |
|
|
56 |
replace: '"Version": "${{ steps.release-drafter.outputs.name }}-pre.${{ env.NEW_BUMP }}"' |
|
|
57 |
|
|
|
58 |
- name: Update version in config/snakebids.yml |
|
|
59 |
uses: jacobtomlinson/gha-find-replace@v3 |
|
|
60 |
with: |
|
|
61 |
include: "hippunfold/config/snakebids.yml" |
|
|
62 |
find: 'version: "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"' |
|
|
63 |
replace: 'version: "${{ steps.release-drafter.outputs.name }}-pre.${{ env.NEW_BUMP }}"' |
|
|
64 |
|
|
|
65 |
- name: Commit updates |
|
|
66 |
env: |
|
|
67 |
SNAKEBIDS_VERSION: ${{ steps.release-drafter.outputs.name }}-pre.${{ env.NEW_BUMP }} |
|
|
68 |
run: | |
|
|
69 |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" |
|
|
70 |
git config --local user.name "github-actions[bot]" |
|
|
71 |
git diff-index --quiet HEAD || git commit -m "Bump version to $SNAKEBIDS_VERSION" -a |
|
|
72 |
|
|
|
73 |
- name: Push changes |
|
|
74 |
uses: ad-m/github-push-action@v0.8.0 |
|
|
75 |
with: |
|
|
76 |
github_token: ${{ secrets.GITHUB_TOKEN }} |
|
|
77 |
tags: false |