Use GITHUB_OUTPUT env var for setting job output

Also update some actions, and use my forks for the release ones.
This commit is contained in:
Tamás Bálint Misius 2022-10-19 18:29:16 +02:00
parent 6338da7cb7
commit 6944d95d5a
No known key found for this signature in database
GPG Key ID: 5B472A12F6ECA9F2
2 changed files with 23 additions and 19 deletions

18
.github/prepare.py vendored
View File

@ -7,6 +7,10 @@ import sys
ref = os.getenv('GITHUB_REF')
publish_hostport = os.getenv('PUBLISH_HOSTPORT')
def set_output(key, value):
with open(os.getenv('GITHUB_OUTPUT'), 'a') as f:
f.write(f"{key}={value}\n")
match_stable = re.fullmatch(r'refs/tags/v([0-9]+)\.([0-9]+)\.([0-9]+)', ref)
match_beta = re.fullmatch(r'refs/tags/v([0-9]+)\.([0-9]+)\.([0-9]+)b', ref)
match_snapshot = re.fullmatch(r'refs/tags/snapshot-([0-9]+)', ref)
@ -32,11 +36,11 @@ else:
release_name = 'dev'
do_publish = publish_hostport and do_release
print('::set-output name=release_type::' + release_type)
print('::set-output name=release_name::' + release_name)
set_output('release_type', release_type)
set_output('release_name', release_name)
with open('.github/mod_id.txt') as f:
print('::set-output name=mod_id::' + f.read())
set_output('mod_id', f.read())
build_matrix = []
publish_matrix = []
@ -103,7 +107,7 @@ for bsh_host_arch, bsh_host_platform, bsh_host_libc, bsh_static_dynamic, bsh_bui
'starcatcher_name': starcatcher_name,
})
print('::set-output name=build_matrix::' + json.dumps({ 'include': build_matrix }))
print('::set-output name=publish_matrix::' + json.dumps({ 'include': publish_matrix }))
print('::set-output name=do_release::' + (do_release and 'yes' or 'no'))
print('::set-output name=do_publish::' + (do_publish and 'yes' or 'no'))
set_output('build_matrix', json.dumps({ 'include': build_matrix }))
set_output('publish_matrix', json.dumps({ 'include': publish_matrix }))
set_output('do_release', do_release and 'yes' or 'no')
set_output('do_publish', do_publish and 'yes' or 'no')

View File

@ -25,8 +25,8 @@ jobs:
mod_id: ${{ steps.prepare.outputs.mod_id }}
do_publish: ${{ steps.prepare.outputs.do_publish }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- id: prepare
@ -36,7 +36,7 @@ jobs:
GITHUB_REF: ${{ github.ref }}
- if: steps.prepare.outputs.do_release == 'yes'
id: create_release
uses: actions/create-release@v1
uses: LBPHacker/create-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
@ -51,8 +51,8 @@ jobs:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare.outputs.build_matrix) }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: python -m pip install meson ninja
@ -80,7 +80,7 @@ jobs:
ASSET_PATH: ${{ matrix.asset_path }}
DEBUG_ASSET_PATH: ${{ matrix.debug_asset_path }}
SEPARATE_DEBUG: ${{ matrix.separate_debug }}
- uses: actions/upload-release-asset@v1 # TODO-NTL: ship licenses
- uses: LBPHacker/upload-release-asset@v2 # TODO-NTL: ship licenses
if: needs.prepare.outputs.do_release == 'yes' && matrix.publish == 'yes'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -89,7 +89,7 @@ jobs:
asset_path: build/${{ matrix.asset_path }}
asset_name: ${{ matrix.asset_name }}
asset_content_type: application/zip
- uses: actions/upload-release-asset@v1
- uses: LBPHacker/upload-release-asset@v2
if: needs.prepare.outputs.do_release == 'yes' && matrix.publish == 'yes' && matrix.separate_debug == 'yes'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -98,12 +98,12 @@ jobs:
asset_path: build/${{ matrix.debug_asset_path }}
asset_name: ${{ matrix.debug_asset_name }}
asset_content_type: application/zip
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: matrix.artifact == 'yes'
with:
path: build/${{ matrix.asset_path }}
name: ${{ matrix.asset_name }}
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
if: matrix.artifact == 'yes' && matrix.separate_debug == 'yes'
with:
path: build/${{ matrix.debug_asset_path }}
@ -116,8 +116,8 @@ jobs:
matrix: ${{ fromJSON(needs.prepare.outputs.publish_matrix) }}
if: needs.prepare.outputs.do_publish == 'yes'
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v1
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: ${{ matrix.asset_name }}
- run: mv ${{ matrix.asset_name }}/${{ matrix.asset_path }} ${{ matrix.starcatcher_name }}
@ -133,7 +133,7 @@ jobs:
needs: [build, publish, prepare]
if: needs.prepare.outputs.do_publish == 'yes'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: ./.github/starcatcher-release.sh
env:
RELEASE_NAME: ${{ needs.prepare.outputs.release_name }}