Skip to content

Commit d7a1246

Browse files
authored
Merge pull request #14 from lpm0073/next
- fix automated python package version bump
2 parents 431a13e + ab72d7d commit d7a1246

File tree

3 files changed

+72
-28
lines changed

3 files changed

+72
-28
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
branches:
1111
- main
1212

13-
1413
jobs:
1514
build:
1615
runs-on: ubuntu-latest
@@ -29,32 +28,6 @@ jobs:
2928
- name: Install npm dev dependencies
3029
run: npm install --only=dev
3130

32-
- name: Get current version
33-
id: current_version
34-
run: |
35-
echo "::set-output name=version::$(python -c 'from __version__ import __version__; print(__version__)')"
36-
env:
37-
GITHUB_TOKEN: ${{ secrets.PAT }}
38-
39-
- name: Get next version
40-
id: next_version
41-
run: |
42-
echo "::set-output name=version::$(npx semantic-release --dry-run | awk '/The next release version is/{print $NF}')"
43-
env:
44-
GITHUB_TOKEN: ${{ secrets.PAT }}
45-
46-
- name: Update __version__
47-
if: steps.current_version.outputs.version != steps.next_version.outputs.version
48-
run: |
49-
echo "__version__ = '${{ steps.next_version.outputs.version }}'" > __version__.py
50-
git config --local user.email "[email protected]"
51-
git config --local user.name "GitHub Action"
52-
git add __version__.py
53-
git commit -m "chore: [gh] Update __version__.py to ${{ steps.next_version.outputs.version }} [skip ci]"
54-
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:main
55-
env:
56-
GITHUB_TOKEN: ${{ secrets.PAT }}
57-
5831
- name: Semantic Release
5932
uses: cycjimmy/semantic-release-action@v4
6033
id: semantic

.github/workflows/versionBump.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#---------------------------------------------------------
2+
# - Create a semantical release
3+
# - Set latest tag
4+
#---------------------------------------------------------
5+
name: Bump version
6+
7+
on:
8+
workflow_dispatch:
9+
push:
10+
branches:
11+
- next
12+
- next-major
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
# required antecedent
20+
- uses: actions/checkout@v4
21+
with:
22+
persist-credentials: false
23+
24+
- name: Setup Node.js environment
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20.9.0'
28+
29+
- name: Install npm dev dependencies
30+
run: npm install
31+
32+
- name: Get current version
33+
id: current_version
34+
run: |
35+
echo "CURRENT_VERSION=$(python -c 'from __version__ import __version__; print(__version__)')" >> $GITHUB_ENV
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.PAT }}
38+
39+
- name: Get next version
40+
id: next_version
41+
run: |
42+
echo "NEXT_VERSION=$(npx semantic-release --dry-run | awk '/The next release version is/{print $NF}')" >> $GITHUB_ENV
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.PAT }}
45+
46+
- name: Check versions
47+
id: check_versions
48+
run: |
49+
if [ "$CURRENT_VERSION" != "$NEXT_VERSION" ]; then
50+
echo "::set-output name=version_changed::true"
51+
else
52+
echo "::set-output name=version_changed::false"
53+
fi
54+
env:
55+
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
56+
NEXT_VERSION: ${{ env.NEXT_VERSION }}
57+
58+
- name: Update __version__
59+
if: steps.check_versions.outputs.version_changed == 'true'
60+
id: update_version
61+
run: |
62+
echo "__version__ = '${{ env.NEXT_VERSION }}'" > __version__.py
63+
git config --local user.email "[email protected]"
64+
git config --local user.name "GitHub Action"
65+
git add __version__.py
66+
git commit -m "chore: [gh] Update __version__.py to ${{ env.NEXT_VERSION }} [skip ci]"
67+
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:${{ github.ref }}
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.PAT }}
70+
CURRENT_VERSION: ${{ env.CURRENT_VERSION }}
71+
NEXT_VERSION: ${{ env.NEXT_VERSION }}

__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = ''
1+
__version__ = '0.1.10'

0 commit comments

Comments
 (0)