-
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (68 loc) · 2.56 KB
/
versionBump.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#---------------------------------------------------------
# - Create a semantical release
# - Set latest tag
#---------------------------------------------------------
name: Bump version
on:
workflow_dispatch:
push:
branches:
- next
- next-major
jobs:
build:
runs-on: ubuntu-latest
steps:
# required antecedent
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: '20.9.0'
- name: Install npm dev dependencies
run: npm install
- name: Get current version
id: current_version
run: |
echo "CURRENT_VERSION=$(python -c 'from __version__ import __version__; print(__version__)')" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Get next version
id: next_version
run: |
echo "NEXT_VERSION=$(npx semantic-release --dry-run --no-ci | awk '/The next release version is/{print $NF}')" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: null step
id: null_step
run: echo "i ensure that NEXT_VERSION is set."
- name: Check versions
id: check_versions
run: |
if [ "$CURRENT_VERSION" != "$NEXT_VERSION" ]; then
echo "VERSION_CHANGED=true" >> $GITHUB_ENV
else
echo "VERSION_CHANGED=false" >> $GITHUB_ENV
fi
env:
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
NEXT_VERSION: ${{ env.NEXT_VERSION }}
- name: another null step
id: another_null_step
run: echo "i ensure that CURRENT_VERSION, NEXT_VERSION and VERSION_CHANGED are set."
- name: Update __version__
if: env.VERSION_CHANGED == 'true'
id: update_version
run: |
echo "__version__ = '${{ env.NEXT_VERSION }}'" > __version__.py
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add __version__.py
git commit -m "chore: [gh] Update __version__.py to ${{ env.NEXT_VERSION }} [skip ci]"
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:${{ github.ref }}
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
NEXT_VERSION: ${{ env.NEXT_VERSION }}
VERSION_CHANGED: ${{ env.VERSION_CHANGED }}