Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,30 @@ jobs:
with:
fetch-depth: 0

- 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.13.0
Expand All @@ -77,24 +88,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
Original file line number Diff line number Diff line change
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