diff --git a/.github/workflows/build-all.yaml b/.github/workflows/build-all.yaml index 315e648ff..32d3b0db2 100644 --- a/.github/workflows/build-all.yaml +++ b/.github/workflows/build-all.yaml @@ -7,6 +7,13 @@ on: jobs: common: runs-on: ubuntu-latest + outputs: + SEMVER: ${{ steps.version_generator.outputs.SEMVER }} + PROJECTNAME: ${{ steps.version_generator.outputs.PROJECTNAME }} + GitVersion_Major: ${{ steps.version_generator.outputs.GitVersion_Major }} + GitVersion_Minor: ${{ steps.version_generator.outputs.GitVersion_Minor }} + GitVersion_Patch: ${{ steps.version_generator.outputs.GitVersion_Patch }} + GitVersion_VersionSourceDistance: ${{ steps.version_generator.outputs.GitVersion_VersionSourceDistance }} steps: - name: Checkout project uses: actions/checkout@v6 @@ -34,8 +41,15 @@ jobs: semantic-version-format=Loose next-version=1.93.1 - - name: Check environment + - name: Print and register result + id: version_generator run: | + echo "SEMVER=$GitVersion_SemVer" >> "$GITHUB_OUTPUT" + echo "GitVersion_Major=$GitVersion_Major" >> "$GITHUB_OUTPUT" + echo "GitVersion_Minor=$GitVersion_Minor" >> "$GITHUB_OUTPUT" + echo "GitVersion_Patch=$GitVersion_Patch" >> "$GITHUB_OUTPUT" + echo "GitVersion_VersionSourceDistance=$GitVersion_VersionSourceDistance" >> "$GITHUB_OUTPUT" + echo "PROJECTNAME=$PROJECTNAME" >> "$GITHUB_OUTPUT" printenv | sort build-linux: @@ -80,6 +94,9 @@ jobs: run: | oolite/ShellScripts/Linux/install_mozilla_js.sh system - name: Build Oolite + env: + SEMVER: ${{ needs.common.outputs.SEMVER }} + PROJECTNAME: ${{ needs.common.outputs.PROJECTNAME }} run: | oolite/ShellScripts/common/build_oolite.sh ${{matrix.flavour}} - name: Archive installer @@ -103,6 +120,9 @@ jobs: path: oolite fetch-depth: 0 - name: Build flatpak + env: + SEMVER: ${{ needs.common.outputs.SEMVER }} + PROJECTNAME: ${{ needs.common.outputs.PROJECTNAME }} run: | oolite/installers/flatpak/create_flatpak.sh - name: Archive installer @@ -151,6 +171,13 @@ jobs: shell: msys2 {0} env: msystem: UCRT64 + VER_MAJ: ${{ needs.common.outputs.GitVersion_Major }} + VER_MIN: ${{ needs.common.outputs.GitVersion_Minor }} + VER_REV: ${{ needs.common.outputs.GitVersion_Patch }} + VER_GITREV: ${{ needs.common.outputs.GitVersion_VersionSourceDistance }} + SEMVER: ${{ needs.common.outputs.SEMVER }} + VER_NSIS: ${{ needs.common.outputs.GitVersion_Major }}.${{ needs.common.outputs.GitVersion_Minor }}.${{ needs.common.outputs.GitVersion_Patch }}.${{ needs.common.outputs.GitVersion_VersionSourceDistance }} + PROJECTNAME: ${{ needs.common.outputs.PROJECTNAME }} run: | oolite/ShellScripts/common/build_oolite.sh ${{matrix.flavour}} - name: Archive installer @@ -162,7 +189,7 @@ jobs: retention-days: 5 release: - needs: [build-linux, build-flatpak, build-windows] + needs: [build-linux, build-flatpak, build-windows, common] runs-on: ubuntu-22.04 steps: ## This is for debugging only and helps developing the workflow. @@ -181,6 +208,9 @@ jobs: fetch-depth: 0 - name: Calculate version number and set OOLITE_VERSION id: version + env: + SEMVER: ${{ needs.common.outputs.SEMVER }} + PROJECTNAME: ${{ needs.common.outputs.PROJECTNAME }} run: | set -x cd oolite @@ -199,7 +229,6 @@ jobs: # For changes on master branch, create a new release. # It should move the 'latest' tag automatically. - name: Create Release - if: github.ref == 'refs/heads/master' || endsWith(github.ref, 'maintenance') id: create_release uses: "marvinpinto/action-automatic-releases@latest" with: diff --git a/ShellScripts/Linux/install_freedesktop_fn.sh b/ShellScripts/Linux/install_freedesktop_fn.sh index 6429a223c..7638b3bfc 100644 --- a/ShellScripts/Linux/install_freedesktop_fn.sh +++ b/ShellScripts/Linux/install_freedesktop_fn.sh @@ -1,4 +1,14 @@ -#!/bin/bash +#!/bin/bash -x +# +# Installs the manifest and injects version number +# +# Requires environment variables: +# VERSION +# APP_DATE +# + +echo "I am install_freedesktop_fn.sh $@" +printenv | sort install_freedesktop() { # Install metainfo (eg. for FlatHub and AppImageHub) @@ -45,10 +55,15 @@ install_freedesktop() { sed -i "s/@VER@/${VERSION}/g" "$APP_METAINFO" sed -i "s/@DATE@/${APP_DATE}/g" "$APP_METAINFO" + echo =========================================== + echo Our manifest looks like this: + cat "$APP_METAINFO" + echo =========================================== + # Desktop and Icon install -D ../../installers/FreeDesktop/space.oolite.Oolite.desktop "$APPSHR/applications/space.oolite.Oolite.desktop" || { echo "$err_msg desktop file" >&2; return 1; } install -D "$PROGDIR/Resources/Textures/oolite-logo1.png" "$APPSHR/icons/hicolor/256x256/apps/space.oolite.Oolite.png" || { echo "$err_msg icon file" >&2; return 1; } popd -} \ No newline at end of file +} diff --git a/ShellScripts/common/get_version.sh b/ShellScripts/common/get_version.sh index 462bd02a8..da7d67261 100755 --- a/ShellScripts/common/get_version.sh +++ b/ShellScripts/common/get_version.sh @@ -1,4 +1,8 @@ #!/bin/bash +# +# Calculates the Oolite version number if not passed via env variables. +# Output goes into the OOLITE_VERSION.txt file and to stdout. +# SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd) pushd "$SCRIPT_DIR" > /dev/null @@ -6,14 +10,9 @@ pushd "$SCRIPT_DIR" > /dev/null mkdir -p ../../build cd ../../build -VERSION=$(cat ../src/Cocoa/oolite-version.xcconfig | cut -d '=' -f 2) -VER_MAJ=$(echo "$VERSION" | cut -d. -f1) -VER_MIN=$(echo "$VERSION" | cut -d. -f2) -VER_REV=$(echo "$VERSION" | cut -d. -f3) -if [ "" == "$VER_REV" ]; then - VER_REV="0" -fi +# Timestamp of last commit/push TIMESTAMP=$(git log -1 --format=%ct) + # Date conversions use UTC for consistency # Convert to __DATE__ format (e.g., Feb 20 2026) CPP_DATE=$(date -u -d "@$TIMESTAMP" +"%b %e %Y") @@ -22,14 +21,29 @@ APP_DATE=$(date -u -d "@$TIMESTAMP" +"%Y-%m-%d") # Convert to YYMMDD format (e.g., 260313) VER_DATE=$(date -u -d "@$TIMESTAMP" +"%y%m%d") -VER_GITREV=$(git rev-list --count HEAD) -VER_GITHASH=$(git rev-parse --short=7 HEAD) -VER_FULL="$VER_MAJ.$VER_MIN.$VER_REV.$VER_GITREV-$VER_DATE-$VER_GITHASH" -BUILDTIME=$(date "+%Y.%m.%d %H:%M") - +if [[ -z "${SEMVER}" ]] || [[ -z "${PROJECTNAME}" ]] +then + # Variables not passed in. Calculate the classic way. + + VERSION=$(cat ../src/Cocoa/oolite-version.xcconfig | cut -d '=' -f 2) + VER_MAJ=$(echo "$VERSION" | cut -d. -f1) + VER_MIN=$(echo "$VERSION" | cut -d. -f2) + VER_REV=$(echo "$VERSION" | cut -d. -f3) + if [[ "" == "$VER_REV" ]]; then + VER_REV="0" + fi + + VER_GITREV=$(git rev-list --count HEAD) + VER_GITHASH=$(git rev-parse --short=7 HEAD) + VER_FULL="$VER_MAJ.$VER_MIN.$VER_REV.$VER_GITREV-$VER_DATE-$VER_GITHASH" + BUILDTIME=$(date "+%Y.%m.%d %H:%M") +else + # Variables passed in. Make use of them. + + VER_FULL="${SEMVER}" +fi echo "OOLITE_VERSION=$VER_FULL" > OOLITE_VERSION.txt - echo "$VER_FULL" -popd > /dev/null \ No newline at end of file +popd > /dev/null diff --git a/installers/appimage/create_appimage.sh b/installers/appimage/create_appimage.sh index 866c1c920..dbdaf1880 100755 --- a/installers/appimage/create_appimage.sh +++ b/installers/appimage/create_appimage.sh @@ -1,4 +1,10 @@ -#!/bin/bash +#!/bin/bash -x +# +# Creates the appimage. +# First parameter can be set to build type, typically one of "test", "dev" or omitted for release builds. +# + +echo I am $0 $@ run_script() { # First parameter is a suffix for the build type eg. test, dev diff --git a/installers/flatpak/create_flatpak.sh b/installers/flatpak/create_flatpak.sh index 79ec2085f..5f4232d7f 100755 --- a/installers/flatpak/create_flatpak.sh +++ b/installers/flatpak/create_flatpak.sh @@ -1,4 +1,6 @@ -#!/bin/bash +#!/bin/bash -x + +echo "I am $0 $@" run_script() { # First parameter is a suffix for the build type eg. test, dev @@ -31,8 +33,17 @@ run_script() { fi local MANIFEST="space.oolite.Oolite.yaml" + + if [ -n "${SEMVER}" ] && [ -n "${PROJECTNAME}" ]; then + # patch manifest + sed -i "97a \ env:\n SEMVER: $SEMVER\n PROJECTNAME: $PROJECTNAME\n VERSION: $SEMVER" $MANIFEST || return 1 + fi + + # check manifest if command -v flatpak-builder-lint >/dev/null 2>&1; then if ! flatpak-builder-lint manifest "$MANIFEST"; then + echo "❌ Flatpak manifest lint failed!" >&2 + cat $MANIFEST echo "❌ Flatpak manifest lint failed!" >&2 return 1 fi @@ -60,6 +71,10 @@ run_script() { - type: dir path: ../ EOF + + # show effective manifest + flatpak-builder --show-manifest $MANIFEST + if ! flatpak-builder \ --user \ --force-clean \ diff --git a/installers/flatpak/flatpak_build.sh b/installers/flatpak/flatpak_build.sh index 03e4cc17e..d22b38f73 100755 --- a/installers/flatpak/flatpak_build.sh +++ b/installers/flatpak/flatpak_build.sh @@ -1,4 +1,10 @@ -#!/bin/bash +#!/bin/bash -x +# +# Prepares the app directory for the flatpak builder +# + +echo "I am flatpak_build.sh $@" +printenv | sort source /app/share/GNUstep/Makefiles/GNUstep.sh source ShellScripts/common/get_version.sh diff --git a/installers/win32/OOlite.nsi b/installers/win32/OOlite.nsi index 1da430bf0..f3e85ec2d 100644 --- a/installers/win32/OOlite.nsi +++ b/installers/win32/OOlite.nsi @@ -31,6 +31,9 @@ !ifndef OUTDIR !define OUTDIR . !endif +!ifndef SEMVER +!define SEMVER ${VERSION} +!endif !ifndef SNAPSHOT !ifndef DEPLOYMENT @@ -58,10 +61,10 @@ SetCompress auto SetCompressor LZMA SetCompressorDictSize 32 SetDatablockOptimize on -OutFile "${OUTDIR}\OoliteInstall-${VER}-win${EXTVER}.exe" +OutFile "${OUTDIR}\OoliteInstall-${SEMVER}-win${EXTVER}.exe" BrandingText "(C) 2003-2026 Giles Williams, Jens Ayton and contributors" Name "Oolite" -Caption "Oolite ${VER}${EXTVER} Setup" +Caption "Oolite ${SEMVER} ${EXTVER} Setup" SubCaption 0 " " SubCaption 1 " " SubCaption 2 " " @@ -83,7 +86,7 @@ VIAddVersionKey "ProductName" "Oolite" VIAddVersionKey "FileDescription" "A space combat/trading game, inspired by Elite." VIAddVersionKey "LegalCopyright" "� 2003-2026 Giles Williams, Jens Ayton and contributors" VIAddVersionKey "FileVersion" "${VER}" -VIAddVersionKey "ProductVersion" "${VER}" +VIAddVersionKey "ProductVersion" "${SEMVER}" !ifdef SNAPSHOT VIAddVersionKey "GIT Revision" "${VER_GITHASH}" !endif diff --git a/installers/win32/create_nsis.sh b/installers/win32/create_nsis.sh index 3e85ff186..c00ce9bf0 100644 --- a/installers/win32/create_nsis.sh +++ b/installers/win32/create_nsis.sh @@ -1,4 +1,14 @@ -#!/bin/bash +#!/bin/bash -x +# +# Creates the windows installer using NSIS. +# First parameter can be set to build type, typically one of "test", "dev" or omitted for release builds. +# Accepts two verion variables: +# VER_FULL - the full version number Oolite is getting built with +# VER_NSIS - the numberical version number (x.x.x.x) that the NSIS installer is built with +# + +echo I am $0 $@ + run_script() { # First parameter is a suffix for the build type eg. test, dev @@ -32,6 +42,11 @@ run_script() { return 1 fi + if [[ -z "${VER_NSIS}" ]] + then + export VER_NSIS=$VER_FULL; + fi + # Passing arguments cause problems with some versions of NSIS. # Because of this, we generate them into a separate file and include them. echo "; Version Definitions for Oolite" > OoliteVersions.nsh @@ -41,7 +56,8 @@ run_script() { echo "!define VER_REV ${VER_REV}" >> OoliteVersions.nsh echo "!define VER_GITREV ${VER_GITREV}" >> OoliteVersions.nsh echo "!define VER_GITHASH ${VER_GITHASH}" >> OoliteVersions.nsh - echo "!define VERSION ${VER_FULL}" >> OoliteVersions.nsh + echo "!define VERSION ${VER_NSIS}" >> OoliteVersions.nsh + echo "!define SEMVER ${SEMVER}" >> OoliteVersions.nsh echo "!define BUILDTIME \"${BUILDTIME}\"" >> OoliteVersions.nsh echo "!define BUILDHOST_IS64BIT 1" >> OoliteVersions.nsh