Skip to content

Commit

Permalink
Handle release/* branch names in CI/CD process
Browse files Browse the repository at this point in the history
- Development build is always 0.0.0.0
- Nightly build version number is 0.0.0.BuildNumber
- Release build version number is the git branch name plus the build number.
  • Loading branch information
chchwy committed Jun 18, 2024
1 parent b283578 commit 6a0be64
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 10 deletions.
16 changes: 10 additions & 6 deletions .github/actions/create-package/create-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ create_package_macos() {
echo "Create ZIP"
local qtsuffix="-qt${INPUT_QT}"
local arch=`uname -m`
bsdtar caf "pencil2d${qtsuffix/-qt5/}-mac-${arch}-$3.zip" Pencil2D
echo "output-basename=pencil2d${qtsuffix/-qt5/}-mac-${arch}-$3" > "${GITHUB_OUTPUT}"
local fileinfo="${qtsuffix/-qt5/}-mac-${arch}-$3"
mv Pencil2D "pencil2d${fileinfo}"
ditto -c -k --sequesterRsrc --keepParent "pencil2d${fileinfo}" "pencil2d${fileinfo}.zip"
rm -r "pencil2d${fileinfo}"
echo "output-basename=pencil2d${fileinfo}" > "${GITHUB_OUTPUT}"
}

create_package_windows() {
Expand Down Expand Up @@ -165,10 +168,11 @@ create_package_windows() {
echo "output-basename=pencil2d${qtsuffix/-qt5/}-${platform}-$3" > "${GITHUB_OUTPUT}"
}

eval "$(grep '^VERSION =' ../util/common.pri | tr -d '[:blank:]')"
buildversion="${GITHUB_RUN_NUMBER}-$(date +%F)"
echo "Version: ${VERSION_NUMBER}"

filename_suffix="b${GITHUB_RUN_NUMBER}-$(date +%F)"
if [ "$IS_RELEASE" = "true" ]; then
buildversion="${VERSION}"
filename_suffix="${VERSION_NUMBER}"
fi

"create_package_$(echo $RUNNER_OS | tr '[A-Z]' '[a-z]')" "${GITHUB_RUN_NUMBER}" "${VERSION}" "${buildversion}"
"create_package_$(echo $RUNNER_OS | tr '[A-Z]' '[a-z]')" "${GITHUB_RUN_NUMBER}" "${VERSION_NUMBER}" "${filename_suffix}"
2 changes: 2 additions & 0 deletions .github/actions/setup-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ runs:
env:
RUNNER_OS: ${{runner.os}}
INPUT_ARCH: ${{inputs.arch}}
- run: ${GITHUB_ACTION_PATH}/setup-versions.sh
shell: bash
16 changes: 16 additions & 0 deletions .github/actions/setup-environment/setup-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# set env.VERSION_NUMBER from release branch names e.g., release/0.7.0
if [[ "${GITHUB_REF_NAME}" == "release/"* ]]; then
branchVerion=$(echo "${GITHUB_REF_NAME}" | sed 's/release\///')
VERSION_NUMBER="$branchVerion.${GITHUB_RUN_NUMBER}"
echo "VERSION_NUMBER=$VERSION_NUMBER" >> $GITHUB_ENV
echo "VERSION_NUMBER is $VERSION_NUMBER"
fi

# set env.VERSION_NUMBER to 99.0.0.buildNumber if the branch is master
if [ "${GITHUB_REF_NAME}" = "master" ]; then
VERSION_NUMBER=99.0.0.${GITHUB_RUN_NUMBER}
echo "VERSION_NUMBER=${VERSION_NUMBER}" >> "${GITHUB_ENV}"
echo "VERSION_NUMBER is $VERSION_NUMBER"
fi
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ jobs:
run: mkdir build; ${{runner.os == 'Linux' && matrix.qt == 6 && 'qmake6' || 'qmake'}}
-o build PREFIX=/usr CONFIG-=debug_and_release CONFIG+=release CONFIG+=GIT
CONFIG+=PENCIL2D_${{ startsWith(github.ref, 'refs/heads/release/') && 'RELEASE' || 'NIGHTLY' }}
VERSION=${{ env.VERSION_NUMBER }}

- name: Build Pencil2D
working-directory: build
Expand Down
17 changes: 14 additions & 3 deletions util/common.pri
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
VERSION = 0.6.6
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
RC_DEFINES += APP_VERSION=\\\"$$VERSION\\\" APP_VERSION_RC=$$replace(VERSION, "\.", ",")

# Development branch build number is always 0.0.0.0
# Nightly build version number is 0.0.0.BuildNumber
# Release build version number is the git branch name plus the build number.

isEmpty(VERSION) {
VERSION = 0.0.0.0
}

message("App Version: $$VERSION")

DEFINES += APP_VERSION=\\\"$$VERSION\\\"
RC_DEFINES += APP_VERSION=\\\"$$VERSION\\\"
RC_DEFINES += APP_VERSION_RC=$$replace(VERSION, "\.", ",")

PENCIL2D_NIGHTLY {
DEFINES += PENCIL2D_NIGHTLY_BUILD
Expand Down
2 changes: 1 addition & 1 deletion util/installer/pencil2d.bundle.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<?elseif $(Edition)="Nightly" ?>
<?define Name = "Pencil2D Nightly" ?>
<?define ExeName = "pencil2d-nightly" ?>
<?define MsiName = "pencil2d-win$(WordSize)-$(NightlyBuildNumber)-$(NightlyBuildTimestamp)" ?>
<?define MsiName = "pencil2d-win$(WordSize)-b$(NightlyBuildNumber)-$(NightlyBuildTimestamp)" ?>
<?define Version = "0.0.$(NightlyBuildNumber)" ?>
<?define UpgradeCode = "DB09026E-2975-43BA-BB2E-AACD1715B9C8" ?>
<?else?>
Expand Down

0 comments on commit 6a0be64

Please sign in to comment.