From 62af7504b2c761081ce6cafa1547287f02e84489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Fri, 16 Apr 2021 23:20:38 +0200 Subject: [PATCH] Correctly set snapshot_id (acting as build number) for mods Also refactor a bunch of variables and their handling in the workflow. --- .github/build.sh | 27 +++++++++++++++++++-------- .github/get-type.py | 3 --- .github/workflows/build.yaml | 2 +- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.github/build.sh b/.github/build.sh index a762d4203..139354661 100755 --- a/.github/build.sh +++ b/.github/build.sh @@ -19,14 +19,14 @@ if [ -z "${STATIC_DYNAMIC-}" ]; then >&2 echo "STATIC_DYNAMIC not set (static, dynamic)" exit 1 fi -if [ -z "${RELTYPECFG-}" ]; then - >&2 echo "RELTYPECFG not set" - exit 1 -fi if [ -z "${RELNAME-}" ]; then >&2 echo "RELNAME not set" exit 1 fi +if [ -z "${RELTYPE-}" ]; then + >&2 echo "RELTYPE not set" + exit 1 +fi if [ -z "${MOD_ID-}" ]; then >&2 echo "MOD_ID not set" exit 1 @@ -76,14 +76,25 @@ fi if [ $PLATFORM_SHORT == "win" ]; then bin_suffix=$bin_suffix.exe fi -if echo $RELTYPECFG | base64 -d | grep snapshot; then +if [ "$RELTYPE" == "snapshot" ]; then other_flags+=$'\t-Dsnapshot=true\t-Dsnapshot_id=' - other_flags+=`echo $RELNAME | cut -d '-' -f 2` + other_flags+=`echo $RELNAME | cut -d '-' -f 2` # $RELNAME is snapshot-X fi -if echo $RELTYPECFG | base64 -d | grep snapshot || [ "$MOD_ID" != "0" ]; then +if [ "$RELTYPE" == "snapshot" ] && [ "$MOD_ID" != "0" ]; then + >&2 echo "mods and snapshots do not mix" + exit 1 +fi +if [ "$RELTYPE" == "stable" ] && [ "$MOD_ID" != "0" ]; then + other_flags+=$'\t-Dsnapshot_id=' + other_flags+=`echo $RELNAME | cut -d '.' -f 3` # $RELNAME is vX.Y.Z +fi +if [ "$RELTYPE" == "snapshot" ] || [ "$MOD_ID" != "0" ]; then other_flags+=$'\t-Dupdate_server=starcatcher.us/TPT' fi -meson -Dbuildtype=release -Db_pie=false -Db_staticpic=false -Db_lto=true $static_flag -Dinstall_check=true $other_flags `echo $RELTYPECFG | base64 -d` build +if [ "$RELTYPE" != "dev" ]; then + other_flags+=$'\t-Dignore_updates=false' +fi +meson -Dbuildtype=release -Db_pie=false -Db_staticpic=false -Db_lto=true $static_flag -Dinstall_check=true $other_flags build cd build ninja if [ $PLATFORM_SHORT == "lin" ] || [ $PLATFORM_SHORT == "mac" ]; then diff --git a/.github/get-type.py b/.github/get-type.py index bba64a9f2..2ae4f2953 100644 --- a/.github/get-type.py +++ b/.github/get-type.py @@ -9,15 +9,12 @@ match_snapshot = re.match(r'refs/tags/snapshot-([0-9]+)', ref) if match_stable: print('::set-output name=TYPE::stable') print('::set-output name=NAME::v%s.%s.%s' % (match_stable.group(1), match_stable.group(2), match_stable.group(3))) - print('::set-output name=RELTYPECFG::%s' % base64.b64encode(('-Dignore_updates=false').encode('utf-8')).decode('utf-8')) elif match_snapshot: print('::set-output name=TYPE::snapshot') print('::set-output name=NAME::snapshot-%s' % match_snapshot.group(1)) - print('::set-output name=RELTYPECFG::%s' % base64.b64encode(('-Dignore_updates=false\t-Dsnapshot=true\t-Dsnapshot_id=%s' % match_snapshot.group(1)).encode('utf-8')).decode('utf-8')) else: print('::set-output name=TYPE::dev') print('::set-output name=NAME::dev') - print('::set-output name=RELTYPECFG::%s' % base64.b64encode(('-Dignore_updates=true').encode('utf-8')).decode('utf-8')) with open('.github/mod_id.txt') as f: print('::set-output name=MOD_ID::' + f.read()) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index efb2e043f..b6eba0a46 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -112,8 +112,8 @@ jobs: MACHINE_SHORT: ${{ matrix.machine_short }} TOOLSET_SHORT: ${{ matrix.toolset_short }} STATIC_DYNAMIC: ${{ matrix.static_dynamic }} - RELTYPECFG: ${{ steps.get_type.outputs.RELTYPECFG }} RELNAME: ${{ steps.get_type.outputs.NAME }} + RELTYPE: ${{ steps.get_type.outputs.TYPE }} MOD_ID: ${{ steps.get_type.outputs.MOD_ID }} - uses: actions/upload-release-asset@v1 if: steps.get_type.outputs.TYPE != 'dev' && matrix.static_dynamic == 'static'