Correctly set snapshot_id (acting as build number) for mods

Also refactor a bunch of variables and their handling in the workflow.
This commit is contained in:
Tamás Bálint Misius 2021-04-16 23:20:38 +02:00
parent 706be01044
commit 62af7504b2
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
3 changed files with 20 additions and 12 deletions

27
.github/build.sh vendored
View File

@ -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

3
.github/get-type.py vendored
View File

@ -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())

View File

@ -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'