From 30d8752ac518182b83af945b3dd372eb4fc9b08d Mon Sep 17 00:00:00 2001 From: kcgen <1557255+kcgen@users.noreply.github.com> Date: Sat, 28 Aug 2021 08:24:27 -0700 Subject: Stop versioning releases using GitHub tag handling Currently the release string embedded in the sources is populated using the "git describe --abbrev" command, written into a VERSION text file that's then compiled into the sources. Unfortunately this is unreliable and the latest isn't registered in GitHub and instead the sources are built using the prior tag (0.77.0 in this case). Hours have been wasted attempting to get the latest tag recognized. This is despite pushing the tag to GitHub and using git's tag-following feature. - Tag the kc/release-0.77.1 branch HEAD (failed - used 0.77.0) - Tag the release/0.77.x branch HEAD (failed - used 0.77.0) - Tag the master branch after HEAD (failed - used 0.77.0) - Tag the kc/release-0.77.1 branch base (failed - used 0.77.0) - Tag the release/0.77.x branch base (failed - used 0.77.0) GitHub's action logs show: ++ git describe --abbrev=0 + export VERSION=v0.77.0 + VERSION=v0.77.0 + echo VERSION=v0.77.0 This is despite GitHub's own action description showing the v0.77.1 tag instead of the branch name to label the action. This is the second time this has caused significant issues and wasted effort - and (due to whatever's happening on GitHub) has become a form of technical debt. --- .github/workflows/linux.yml | 11 ++++------- .github/workflows/macos.yml | 11 ++++------- .github/workflows/windows.yml | 11 +++++------ .version | 2 ++ scripts/version.sh | 21 +++++++++++++++++++++ 5 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 .version create mode 100755 scripts/version.sh diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 383140324..f7f9b90e5 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -189,10 +189,8 @@ jobs: - name: Inject version string run: | - set -x + scripts/version.sh >> $GITHUB_ENV git fetch --prune --unshallow - export VERSION=$(git describe --abbrev=0) - echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Setup release build run: | @@ -306,13 +304,12 @@ jobs: run: | set +x git fetch --unshallow - VERSION=$(git describe --abbrev=0) - echo "VERSION=$VERSION" >> $GITHUB_ENV NEWEST_TAG=$(git describe --abbrev=0) - git log "$NEWEST_TAG..HEAD" > changelog-$VERSION.txt + git log "$NEWEST_TAG..HEAD" > changelog.txt + scripts/version.sh >> $GITHUB_ENV - uses: actions/upload-artifact@v2 with: # Keep exactly this artifact name; it's being used to propagate # version info via GitHub REST API name: changelog-${{ env.VERSION }}.txt - path: changelog-${{ env.VERSION }}.txt + path: changelog.txt diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 8cd99c801..d7679908b 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -214,10 +214,8 @@ jobs: - name: Inject version string run: | - set -x + scripts/version.sh >> $GITHUB_ENV git fetch --prune --unshallow - export VERSION=$(git describe --abbrev=0) - echo "VERSION=$VERSION" >> $GITHUB_ENV - name: Setup release build run: | @@ -346,13 +344,12 @@ jobs: run: | set +x git fetch --unshallow - VERSION=$(git describe --abbrev=0) - echo "VERSION=$VERSION" >> $GITHUB_ENV NEWEST_TAG=$(git describe --abbrev=0) - git log "$NEWEST_TAG..HEAD" > changelog-$VERSION.txt + git log "$NEWEST_TAG..HEAD" > changelog.txt + scripts/version.sh >> $GITHUB_ENV - uses: actions/upload-artifact@v2 with: # Keep exactly this artifact name; it's being used to propagate # version info via GitHub REST API name: changelog-${{ env.VERSION }}.txt - path: changelog-${{ env.VERSION }}.txt + path: changelog.txt diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index d353da0a5..a34356c0d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -131,10 +131,10 @@ jobs: run: | set -x git fetch --prune --unshallow - export VERSION=$(git describe --abbrev=0) + eval $(scripts/version.sh) + echo "VERSION=$VERSION" >> $GITHUB_ENV # inject version based on vcs sed -i "s|DOSBOX_DETAILED_VERSION \"git\"|DOSBOX_DETAILED_VERSION \"$VERSION\"|" src/platform/visualc/config.h - echo "VERSION=$VERSION" >> $GITHUB_ENV # overwrite .conf file branding for release build sed -i "s|CONF_SUFFIX \"-staging-git\"|CONF_SUFFIX \"-staging\"|" src/platform/visualc/config.h @@ -247,13 +247,12 @@ jobs: run: | set +x git fetch --unshallow - VERSION=$(git describe --abbrev=0) - echo "VERSION=$VERSION" >> $GITHUB_ENV NEWEST_TAG=$(git describe --abbrev=0) - git log "$NEWEST_TAG..HEAD" > changelog-$VERSION.txt + git log "$NEWEST_TAG..HEAD" > changelog.txt + scripts/version.sh >> $GITHUB_ENV - uses: actions/upload-artifact@v2 with: # Keep exactly this artifact name; it's being used to propagate # version info via GitHub REST API name: changelog-${{ env.VERSION }}.txt - path: changelog-${{ env.VERSION }}.txt + path: changelog.txt diff --git a/.version b/.version new file mode 100644 index 000000000..450ea41ae --- /dev/null +++ b/.version @@ -0,0 +1,2 @@ +v0.77.1 + diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 000000000..3053b9248 --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Copyright (C) 2021-2021 kcgen +# +# version.sh - Print the currect software release an identifier + +set -euo pipefail + +vfile=".version" + +if [[ ! -f "$vfile" ]]; then + basedir=$(git rev-parse --show-toplevel) # or fail + vfile="$basedir/$vfile" +fi + +release=$(cat "$vfile") # or fail +identifier=$(git rev-parse --short=5 HEAD 2>/dev/null || echo norepo-source) + +echo "VERSION=$release-$identifier" -- cgit v1.2.3