Skip to content

Commit

Permalink
build: Update version management scripts and control (#2028)
Browse files Browse the repository at this point in the history
Co-authored-by: Tristan Youngs <trisyoungs@googlemail.com>
  • Loading branch information
trisyoungs and Tristan Youngs authored Jan 17, 2025
1 parent 9b27472 commit d5855bc
Show file tree
Hide file tree
Showing 37 changed files with 1,425 additions and 862 deletions.
93 changes: 54 additions & 39 deletions .github/workflows/_build_and_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,47 @@ name: Build and Package
on:
workflow_call:
inputs:
checkoutRef:
default: ''
currentVersion:
type: string
required: true
description: "Version used for labelling packages and other artifacts"
qtVersion:
type: string
required: true
antlrVersion:
type: string
required: true
conanHash:
type: string
required: true
nixHash:
type: string
required: true

jobs:

QC:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.checkoutRef }}
- name: Setup
uses: "./.github/workflows/setup"
- name: Quality Control
uses: "./.github/workflows/qc"

Build:
strategy:
fail-fast: false
matrix:
os: [ macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.checkoutRef }}
- name: Setup
uses: "./.github/workflows/setup"
- name: Set Short Hash
uses: "./.github/workflows/set-short-hash"
- name: "Build (${{ matrix.os }})"
uses: "./.github/workflows/build"
- name: 'Download Source Tarfiles'
uses: actions/download-artifact@v4
with:
name: source

- name: 'Unpack Source'
shell: bash
run: tar -xvf dissolve-versioned-source.tar

- name: "Build (${{ matrix.os }})"
uses: "./.github/workflows/build"
with:
qtVersion: ${{ inputs.qtVersion }}
antlrVersion: ${{ inputs.antlrVersion }}
conanHash: ${{ inputs.conanHash }}

BuildLinux:
strategy:
Expand All @@ -46,18 +52,21 @@ jobs:
target: [ dissolve, dissolve-gui ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: 'Download Source Tarfiles'
uses: actions/download-artifact@v4
with:
ref: ${{ inputs.checkoutRef }}
- name: Setup
uses: "./.github/workflows/setup"
- name: Set Short Hash
uses: "./.github/workflows/set-short-hash"
name: source

- name: 'Unpack Source'
shell: bash
run: tar -xvf dissolve-versioned-source.tar

- name: "Build, Test, Package (Linux, ${{ matrix.target }})"
uses: "./.github/workflows/build"
with:
target: ${{ matrix.target }}
currentVersion: ${{ inputs.currentVersion }}
nixHash: ${{ inputs.nixHash }}

Package:
needs: Build
Expand All @@ -67,11 +76,17 @@ jobs:
os: [ macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.checkoutRef }}
- name: Setup
uses: "./.github/workflows/setup"
- name: "Package (${{ matrix.os }})"
uses: "./.github/workflows/package"
- name: 'Download Source Tarfiles'
uses: actions/download-artifact@v4
with:
name: source

- name: 'Unpack Source'
shell: bash
run: tar -xvf dissolve-versioned-source.tar

- name: "Package (${{ matrix.os }})"
uses: "./.github/workflows/package"
with:
currentVersion: ${{ inputs.currentVersion }}
qtVersion: ${{ inputs.qtVersion }}
236 changes: 236 additions & 0 deletions .github/workflows/_checkout.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
name: Checkout
description: Checks out the source and packages the source as an artifact for use by other workflow steps. Reversioning of the source to a git-cliff bumped version is performed if the "bump" flag is set. Tags are created / moved according to the value of 'publishType'.

on:
workflow_call:
inputs:
qtVersion:
type: string
default: 6.4.2
hugoVersion:
type: string
default: "0.135.0"
apptainerVersion:
type: string
default: "1.2.5"
conanfile:
type: string
default: cmake/Modules/conan-dissolve.cmake
publishType:
default: 'none'
type: string
checkoutRef:
default: ''
type: string
bump:
default: false
type: boolean
outputs:
currentVersion:
description: "Full version (MAJOR.MINOR.PATCH) determined from source, and after any reversioning"
value: ${{ jobs.Checkout.outputs.currentVersion }}
currentVersionMajor:
description: "MAJOR version determined from source, and after any reversioning"
value: ${{ jobs.Checkout.outputs.currentVersionMajor }}
currentVersionMinor:
description: "MINOR version determined from source, and after any reversioning"
value: ${{ jobs.Checkout.outputs.currentVersionMinor }}
currentVersionPatch:
description: "PATCH version determined from source, and after any reversioning"
value: ${{ jobs.Checkout.outputs.currentVersionPatch }}
currentShortHash:
description: "Short hash of the current HEAD commit"
value: ${{ jobs.Checkout.outputs.currentShortHash }}
qtVersion:
description: "Version of Qt required by the project"
value: ${{ jobs.Checkout.outputs.qtVersion }}
antlrVersion:
description: "Version of ANTLR required by the project (determined from conanfile)"
value: ${{ jobs.Checkout.outputs.antlrVersion }}
hugoVersion:
description: "Version of Hugo required for building website"
value: ${{ jobs.Checkout.outputs.hugoVersion }}
apptainerVersion:
description: "Version of Apptainer required for uploading to Harbor"
value: ${{ jobs.Checkout.outputs.apptainerVersion }}
nixHash:
description: "Hash of the current nix files (flake.lock and flake.nix)"
value: ${{ jobs.Checkout.outputs.nixHash }}
conanHash:
description: "Hash of the current conanfile"
value: ${{ jobs.Checkout.outputs.conanHash }}

jobs:

Checkout:
runs-on: ubuntu-latest
outputs:
currentVersion: ${{ steps.authVersion.outputs.currentVersion }}
currentVersionMajor: ${{ steps.authVersion.outputs.currentVersionMajor }}
currentVersionMinor: ${{ steps.authVersion.outputs.currentVersionMinor }}
currentVersionPatch: ${{ steps.authVersion.outputs.currentVersionPatch }}
currentShortHash: ${{ steps.authVersion.outputs.currentShortHash }}
qtVersion: ${{ steps.versions.outputs.qtVersion }}
antlrVersion: ${{ steps.versions.outputs.antlrVersion }}
hugoVersion: ${{ steps.versions.outputs.hugoVersion }}
apptainerVersion: ${{ steps.versions.outputs.apptainerVersion }}
nixHash: ${{ steps.hashes.outputs.nixHash }}
conanHash: ${{ steps.hashes.outputs.conanHash }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ inputs.checkoutRef }}
fetch-depth: 0

- name: Create Original Source Artifact
shell: bash
run: |
set -ex
tar -cvf ${{ runner.temp }}/dissolve-original-source.tar ./
- name: Set Required Versions
id: versions
shell: bash
run: |
set -ex
echo "qtVersion=${{ inputs.qtVersion }}" >> $GITHUB_OUTPUT
echo "hugoVersion=${{ inputs.hugoVersion }}" >> $GITHUB_OUTPUT
echo "apptainerVersion=${{ inputs.apptainerVersion }}" >> $GITHUB_OUTPUT
ANTLR_VERSION=$(cat ${{ inputs.conanfile }} | sed -n -e 's%^.*antlr4-cppruntime/%%p')
echo "antlrVersion=${ANTLR_VERSION}" >> $GITHUB_OUTPUT
- name: Get nix hash
shell: bash
run: |
set -ex
NIX_HASH=`sha256sum flake.lock | gawk '{print $1}'`
echo "Hash of nix files (flake.lock and flake.nix) is ${NIX_HASH}"
echo "nixHash=${NIX_HASH}" >> $GITHUB_OUTPUT
CONAN_HASH=`sha256sum ${{ inputs.conanfile }} | gawk '{print $1}'`
echo "Hash of conanfile.txt is ${CONAN_HASH}"
echo "conanHash=${CONAN_HASH}" >> $GITHUB_OUTPUT
- name: Set Short Hash
shell: bash
run: |
set -ex
SHORT_HASH=$(git rev-parse --short HEAD)
echo "Current short hash is ${SHORT_HASH}"
sed -i -e "s/DISSOLVESHORTHASH \".*\"/DISSOLVESHORTHASH \"${SHORT_HASH}\"/g" src/main/version.cpp
cat src/main/version.cpp
- name: Get Cliff
uses: "./.github/workflows/get-cliff"

- name: Generate ChangeLog.md
if: inputs.publishType != 'none'
shell: bash
run: |
set -ex
./changeversion -l > ChangeLog.md
- name: Bump Version
if: inputs.bump == true
shell: bash
run: |
set -ex
./changeversion -b
./changeversion -k
- name: Tag Continuous
if: inputs.publishType == 'continuous'
shell: bash
run: |
set -ex
# Move 'continuous' tag to the current HEAD
if [ $(git tag -l continuous) ]
then
echo "Tag 'continuous' exists and will be moved."
git tag --delete continuous
else
echo "Tag 'continuous' doesn't yet exist - it will be created."
fi
git tag continuous ${{ github.event.pull_request.merge_commit_sha }}
git show continuous
git push origin -f continuous
- name: Tag Release
if: inputs.publishType == 'release'
shell: bash
run: |
set -ex
# Get authoritative version at this point
CURRENT=$(./changeversion -v)
echo "Current version determined to be ${CURRENT}"
BUMPED=$(./changeversion -q)
echo "Bumped version determined to be ${BUMPED}"
# If the current and bumped versions differ then there is an issue...
if [ ${BUMPED} != ${CURRENT} ]
then
echo "Error: Current and bumped versions are different. Is this a valid release branch / point? Stopping here."
exit 1
fi
# Create the new version tag
if [ $(git tag -l ${BUMPED}) ]
then
echo "Error: Version tag ${BUMPED} alread exists."
exit 1
fi
git tag ${BUMPED} ${{ github.event.pull_request.merge_commit_sha }}
git show ${BUMPED}
git push origin ${BUMPED}
- name: Create / Check Release Root Branch
if: inputs.publishType == 'release'
shell: bash
run: |
set -ex
# Get the root release branch name - version as MAJOR.MINOR.X
BRANCH="release/$(./changeversion -x)"
# Create root release branch if it doesn't already exist
if git rev-parse --verify ${BRANCH} 2>/dev/null
then
echo "Release branch ${BRANCH} already exists."
else
git config user.name "${{ env.USER }}"
git config user.email "${{ env.EMAIL }}"
git checkout -b ${BRANCH}
git push --set-upstream origin ${BRANCH}
fi
- name: Get Authoritative Version Information
id: authVersion
shell: bash
run: |
set -ex
CURRENT=$(./changeversion -v)
echo "currentVersion=${CURRENT}" >> $GITHUB_OUTPUT
PARTS=($(echo ${CURRENT} | tr "." " "))
echo "currentVersionMajor=${PARTS[0]}" >> $GITHUB_OUTPUT
echo "currentVersionMinor=${PARTS[1]}" >> $GITHUB_OUTPUT
echo "currentVersionPatch=${PARTS[2]}" >> $GITHUB_OUTPUT
echo "currentShortHash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- name: Create Versioned Source Artifact
shell: bash
run: |
set -ex
tar -cvf ${{ runner.temp }}/dissolve-versioned-source.tar ./
- name: Upload Versioned Source Artifact
uses: actions/upload-artifact@v4
with:
name: source
path: ${{ runner.temp }}/dissolve-*-source.tar
retention-days: 1
Loading

0 comments on commit d5855bc

Please sign in to comment.