Skip to content

Commit 3b67d9e

Browse files
chore: Bump version to 12 in a couple places (ietf-tools#6789)
* chore: Bump version to 12 in a couple places * ci: use semver-action to set dev major version * feat: Extract version at runtime for dev * fix: Use version/branch/hash vars --------- Co-authored-by: Nicolas Giard <github@ngpixel.com>
1 parent 528d697 commit 3b67d9e

2 files changed

Lines changed: 43 additions & 14 deletions

File tree

.github/workflows/build.yml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,30 @@ jobs:
6262
fetch-depth: 1
6363
fetch-tags: false
6464

65-
- name: Get Next Version
65+
- name: Get Next Version (Prod)
6666
if: ${{ github.ref_name == 'release' }}
6767
id: semver
6868
uses: ietf-tools/semver-action@v1
6969
with:
7070
token: ${{ github.token }}
7171
branch: release
7272
skipInvalidTags: true
73-
74-
- name: Set Next Version Env Var
73+
74+
- name: Get Dev Version
75+
if: ${{ github.ref_name != 'release' }}
76+
id: semverdev
77+
uses: ietf-tools/semver-action@v1
78+
with:
79+
token: ${{ github.token }}
80+
branch: release
81+
skipInvalidTags: true
82+
noVersionBumpBehavior: 'current'
83+
noNewCommitBehavior: 'current'
84+
85+
- name: Set Release Flag
7586
if: ${{ github.ref_name == 'release' }}
7687
run: |
77-
echo "NEXT_VERSION=$nextStrict" >> $GITHUB_ENV
88+
echo "IS_RELEASE=true" >> $GITHUB_ENV
7889
7990
- name: Create Draft Release
8091
uses: ncipollo/release-action@v1.14.0
@@ -83,24 +94,24 @@ jobs:
8394
prerelease: true
8495
draft: false
8596
commit: ${{ github.sha }}
86-
tag: ${{ env.NEXT_VERSION }}
87-
name: ${{ env.NEXT_VERSION }}
97+
tag: ${{ steps.semver.outputs.nextStrict }}
98+
name: ${{ steps.semver.outputs.nextStrict }}
8899
body: '*pending*'
89100
token: ${{ secrets.GITHUB_TOKEN }}
90101

91102
- name: Set Build Variables
92103
id: buildvars
93104
run: |
94-
if [[ $NEXT_VERSION ]]; then
95-
echo "Using AUTO SEMVER mode: $NEXT_VERSION"
105+
if [[ $IS_RELEASE ]]; then
106+
echo "Using AUTO SEMVER mode: ${{ steps.semver.outputs.nextStrict }}"
96107
echo "should_deploy=true" >> $GITHUB_OUTPUT
97-
echo "pkg_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
98-
echo "::notice::Release $NEXT_VERSION created using branch $GITHUB_REF_NAME"
108+
echo "pkg_version=${{ steps.semver.outputs.nextStrict }}" >> $GITHUB_OUTPUT
109+
echo "::notice::Release ${{ steps.semver.outputs.nextStrict }} created using branch $GITHUB_REF_NAME"
99110
else
100-
echo "Using TEST mode: 11.0.0-dev.$GITHUB_RUN_NUMBER"
111+
echo "Using TEST mode: ${{ steps.semverdev.outputs.nextMajorStrict }}.0.0-dev.$GITHUB_RUN_NUMBER"
101112
echo "should_deploy=false" >> $GITHUB_OUTPUT
102-
echo "pkg_version=11.0.0-dev.$GITHUB_RUN_NUMBER" >> $GITHUB_OUTPUT
103-
echo "::notice::Non-production build 11.0.0-dev.$GITHUB_RUN_NUMBER created using branch $GITHUB_REF_NAME"
113+
echo "pkg_version=${{ steps.semverdev.outputs.nextMajorStrict }}.0.0-dev.$GITHUB_RUN_NUMBER" >> $GITHUB_OUTPUT
114+
echo "::notice::Non-production build ${{ steps.semverdev.outputs.nextMajorStrict }}.0.0-dev.$GITHUB_RUN_NUMBER created using branch $GITHUB_REF_NAME"
104115
fi
105116
106117
# -----------------------------------------------------------------

ietf/__init__.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Version must stay in single quotes for automatic CI replace
88
# Don't add patch number here:
9-
__version__ = '11.0.0-dev'
9+
__version__ = '1.0.0-dev'
1010

1111
# Release hash must stay in single quotes for automatic CI replace
1212
__release_hash__ = ''
@@ -17,6 +17,24 @@
1717
# set this to ".p1", ".p2", etc. after patching
1818
__patch__ = ""
1919

20+
if __version__ == '1.0.0-dev' and __release_hash__ == '' and __release_branch__ == '':
21+
import subprocess
22+
branch = subprocess.run(
23+
["/usr/bin/git", "branch", "--show-current"],
24+
capture_output=True,
25+
).stdout.decode().strip()
26+
git_hash = subprocess.run(
27+
["/usr/bin/git", "rev-parse", "head"],
28+
capture_output=True,
29+
).stdout.decode().strip()
30+
rev = subprocess.run(
31+
["/usr/bin/git", "describe", "--tags", git_hash],
32+
capture_output=True,
33+
).stdout.decode().strip().split('-', 1)[0]
34+
__version__ = f"{rev}-dev"
35+
__release_branch__ = branch
36+
__release_hash__ = git_hash
37+
2038

2139
# This will make sure the app is always imported when
2240
# Django starts so that shared_task will use this app.

0 commit comments

Comments
 (0)