Skip to content

Commit

Permalink
chore: Bump version to 12 in a couple places (#6789)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
jennifer-richards and NGPixel committed Mar 11, 2024
1 parent 528d697 commit 3b67d9e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 14 deletions.
37 changes: 24 additions & 13 deletions .github/workflows/build.yml
Expand Up @@ -62,19 +62,30 @@ jobs:
fetch-depth: 1
fetch-tags: false

- name: Get Next Version
- name: Get Next Version (Prod)
if: ${{ github.ref_name == 'release' }}
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: release
skipInvalidTags: true

- name: Set Next Version Env Var

- name: Get Dev Version
if: ${{ github.ref_name != 'release' }}
id: semverdev
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
branch: release
skipInvalidTags: true
noVersionBumpBehavior: 'current'
noNewCommitBehavior: 'current'

- name: Set Release Flag
if: ${{ github.ref_name == 'release' }}
run: |
echo "NEXT_VERSION=$nextStrict" >> $GITHUB_ENV
echo "IS_RELEASE=true" >> $GITHUB_ENV
- name: Create Draft Release
uses: ncipollo/release-action@v1.14.0
Expand All @@ -83,24 +94,24 @@ jobs:
prerelease: true
draft: false
commit: ${{ github.sha }}
tag: ${{ env.NEXT_VERSION }}
name: ${{ env.NEXT_VERSION }}
tag: ${{ steps.semver.outputs.nextStrict }}
name: ${{ steps.semver.outputs.nextStrict }}
body: '*pending*'
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set Build Variables
id: buildvars
run: |
if [[ $NEXT_VERSION ]]; then
echo "Using AUTO SEMVER mode: $NEXT_VERSION"
if [[ $IS_RELEASE ]]; then
echo "Using AUTO SEMVER mode: ${{ steps.semver.outputs.nextStrict }}"
echo "should_deploy=true" >> $GITHUB_OUTPUT
echo "pkg_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "::notice::Release $NEXT_VERSION created using branch $GITHUB_REF_NAME"
echo "pkg_version=${{ steps.semver.outputs.nextStrict }}" >> $GITHUB_OUTPUT
echo "::notice::Release ${{ steps.semver.outputs.nextStrict }} created using branch $GITHUB_REF_NAME"
else
echo "Using TEST mode: 11.0.0-dev.$GITHUB_RUN_NUMBER"
echo "Using TEST mode: ${{ steps.semverdev.outputs.nextMajorStrict }}.0.0-dev.$GITHUB_RUN_NUMBER"
echo "should_deploy=false" >> $GITHUB_OUTPUT
echo "pkg_version=11.0.0-dev.$GITHUB_RUN_NUMBER" >> $GITHUB_OUTPUT
echo "::notice::Non-production build 11.0.0-dev.$GITHUB_RUN_NUMBER created using branch $GITHUB_REF_NAME"
echo "pkg_version=${{ steps.semverdev.outputs.nextMajorStrict }}.0.0-dev.$GITHUB_RUN_NUMBER" >> $GITHUB_OUTPUT
echo "::notice::Non-production build ${{ steps.semverdev.outputs.nextMajorStrict }}.0.0-dev.$GITHUB_RUN_NUMBER created using branch $GITHUB_REF_NAME"
fi
# -----------------------------------------------------------------
Expand Down
20 changes: 19 additions & 1 deletion ietf/__init__.py
Expand Up @@ -6,7 +6,7 @@

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

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

if __version__ == '1.0.0-dev' and __release_hash__ == '' and __release_branch__ == '':
import subprocess
branch = subprocess.run(
["/usr/bin/git", "branch", "--show-current"],
capture_output=True,
).stdout.decode().strip()
git_hash = subprocess.run(
["/usr/bin/git", "rev-parse", "head"],
capture_output=True,
).stdout.decode().strip()
rev = subprocess.run(
["/usr/bin/git", "describe", "--tags", git_hash],
capture_output=True,
).stdout.decode().strip().split('-', 1)[0]
__version__ = f"{rev}-dev"
__release_branch__ = branch
__release_hash__ = git_hash


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

0 comments on commit 3b67d9e

Please sign in to comment.