-
Notifications
You must be signed in to change notification settings - Fork 3
66 lines (66 loc) · 2.43 KB
/
bump_version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
name: Bump version
on:
pull_request_target:
types: [closed]
jobs:
build:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout master branch
uses: actions/checkout@master
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Update changelog
uses: release-drafter/release-drafter@v5
id: release-drafter
with:
commitish: ${{ github.event.pull_request.base.ref }}
env:
GITHUB_TOKEN: ${{ secrets.BP_PAT_TOKEN }}
- name: Get previous release version
run: |
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
- name: Get previous bump version
env:
PREV_VER: ${{ env.PREV_VER }}
run: |
if [[ "$PREV_VER" != *"-pre."* ]]; then
echo "OLD_BUMP=0" >> $GITHUB_ENV
else
echo "OLD_BUMP=$(echo $PREV_VER | cut -d '.' -f 4)" >> $GITHUB_ENV
fi
- name: Bump version
env:
BUMP_VER: ${{ env.OLD_BUMP }}
run: |
echo "NEW_BUMP=$(($BUMP_VER + 1))" >> $GITHUB_ENV
- name: Set new release version
env:
RD_RELEASE: ${{ steps.release-drafter.outputs.name }}
run: |
if [ ! -z "$RD_RELEASE" ]; then
echo "NEW_RELEASE=$RD_RELEASE" >> $GITHUB_ENV
else
echo "NEW_RELEASE=0.1.0" >> $GITHUB_ENV
fi
- name: Update version in pyproject.toml
uses: jacobtomlinson/gha-find-replace@master
with:
include: pyproject.toml
find: version = "(?:([0-9]+\.[0-9]+\.[0-9]+.+)|([0-9]+\.[0-9]+\.[0-9]+))"
replace: version = "${{ env.NEW_RELEASE }}-pre.${{ env.NEW_BUMP }}"
- name: Commit updates
env:
SNAKEBIDS_VERSION: ${{ env.NEW_RELEASE }}-pre.${{ env.NEW_BUMP }}
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git diff-index --quiet HEAD || git commit -m "Bump version to $SNAKEBIDS_VERSION" -a
- name: Push changes
uses: CasperWA/push-protected@v2
with:
branch: ${{ github.event.pull_request.base.ref }}
token: ${{ secrets.BP_PAT_TOKEN }}
unprotect_reviews: true