mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
split the release jobs into their own workflow
A skipped job still shows up in a pull request's check list, so assemble and release reported there as two permanently skipped checks. A job can only be left out of a run graph it does not belong to, so move both into release.yml, which triggers on master, v* tags and manual dispatch, and gets its build by calling build.yml through workflow_call. A pull request now runs build.yml directly and reports exactly the five checks it can actually pass. The global_vars step only existed to compute assemble_release for the two jobs that left, and it read the workflow_dispatch input, which a called workflow cannot see. Its logic moves to a condition on assemble itself, unchanged: a manual run assembles only when asked, tags always assemble, master assembles only upstream. The release job needs no condition since a skipped assemble skips it. Check out the source rather than cloning it by hand. A pull request builds its merge commit, which is on no branch and so is absent from a clone of branches and tags; it resolved only because --filter=tree:0 made the clone partial and git fetched it from the promisor remote on demand. The action fetches the merge ref itself, so nothing hinges on the filter. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
committed by
majcosta
co-authored by
Claude Opus 5
parent
d68f046ea3
commit
3471b19fdc
+15
-187
@@ -1,65 +1,39 @@
|
|||||||
name: build
|
name: build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
pull_request:
|
pull_request:
|
||||||
# allows to manually trigger a build
|
# release.yml calls this workflow, which is how master, tags and manual runs
|
||||||
workflow_dispatch:
|
# build. Keeping the release jobs out of here keeps them off the pull request
|
||||||
inputs:
|
# check list, where they would only ever show up as skipped.
|
||||||
assemble_release:
|
workflow_call:
|
||||||
description: create release
|
|
||||||
required: false
|
|
||||||
default: false
|
|
||||||
type: boolean
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
workflow_setup:
|
workflow_setup:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
|
||||||
assemble_release: ${{ steps.global_vars.outputs.assemble_release }}
|
|
||||||
steps:
|
steps:
|
||||||
- id: global_vars
|
- name: Checkout source
|
||||||
name: Set global variables
|
uses: actions/checkout@v7
|
||||||
run: |
|
with:
|
||||||
set -eux
|
path: source
|
||||||
|
filter: 'tree:0'
|
||||||
full_release='${{ ( github.repository == '1dot13/source' && github.ref_name == 'master' ) || startsWith(github.ref, 'refs/tags/v') }}'
|
fetch-depth: 0
|
||||||
|
|
||||||
if [[ '${{ inputs.assemble_release }}' == 'true' || ( '${{ inputs.assemble_release }}' == '' && "$full_release" == 'true' ) ]]
|
|
||||||
then
|
|
||||||
assemble_release='true'
|
|
||||||
else
|
|
||||||
assemble_release='false'
|
|
||||||
fi
|
|
||||||
echo "assemble_release=$assemble_release" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Clone repos metadata
|
- name: Clone gamedir metadata
|
||||||
run: |
|
run: |
|
||||||
set -eux
|
set -eux
|
||||||
|
|
||||||
GAMEDIR_REPOSITORY=1dot13/gamedir
|
GAMEDIR_REPOSITORY=1dot13/gamedir
|
||||||
GAMEDIR_LANGUAGES_REPOSITORY=1dot13/gamedir-languages
|
GAMEDIR_LANGUAGES_REPOSITORY=1dot13/gamedir-languages
|
||||||
|
|
||||||
# filter tree is what makes this fast
|
# filter tree is what makes this fast
|
||||||
git clone --config transfer.fsckobjects=false --tags --no-checkout --filter=tree:0 \
|
|
||||||
"https://github.com/$GITHUB_REPOSITORY" \
|
|
||||||
source
|
|
||||||
|
|
||||||
git clone --config transfer.fsckobjects=false --no-checkout --filter=tree:0 \
|
git clone --config transfer.fsckobjects=false --no-checkout --filter=tree:0 \
|
||||||
https://github.com/$GAMEDIR_REPOSITORY \
|
https://github.com/$GAMEDIR_REPOSITORY \
|
||||||
gamedir
|
gamedir
|
||||||
|
|
||||||
git clone --config transfer.fsckobjects=false --no-checkout --filter=tree:0 \
|
git clone --config transfer.fsckobjects=false --no-checkout --filter=tree:0 \
|
||||||
https://github.com/$GAMEDIR_LANGUAGES_REPOSITORY \
|
https://github.com/$GAMEDIR_LANGUAGES_REPOSITORY \
|
||||||
gamedir-languages
|
gamedir-languages
|
||||||
|
|
||||||
mkdir dist/
|
mkdir dist/
|
||||||
echo -n "
|
echo -n "
|
||||||
GAMEDIR_REPOSITORY=$GAMEDIR_REPOSITORY
|
GAMEDIR_REPOSITORY=$GAMEDIR_REPOSITORY
|
||||||
@@ -217,149 +191,3 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: ${{ matrix.application }}
|
name: ${{ matrix.application }}
|
||||||
path: build/*.exe
|
path: build/*.exe
|
||||||
|
|
||||||
# only the game data differs per language, every package gets the same executables
|
|
||||||
assemble:
|
|
||||||
needs: [ workflow_setup, compile ]
|
|
||||||
if: needs.workflow_setup.outputs.assemble_release == 'true'
|
|
||||||
runs-on: windows-latest # required for case-insensitive filesystem handling
|
|
||||||
# at least English has to work
|
|
||||||
continue-on-error: ${{ matrix.language != 'English' }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
language: [Chinese, German, English, French, Polish, Italian, Dutch, Russian]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Download versions.env
|
|
||||||
uses: actions/download-artifact@v8
|
|
||||||
with:
|
|
||||||
name: versions.env
|
|
||||||
path: artifacts
|
|
||||||
- name: Restore versions.env
|
|
||||||
shell: bash
|
|
||||||
run: cat artifacts/versions.env >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Checkout gamedir
|
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
repository: ${{ env.GAMEDIR_REPOSITORY }}
|
|
||||||
ref: ${{ env.GAMEDIR_COMMIT_SHA }}
|
|
||||||
path: gamedir
|
|
||||||
|
|
||||||
- name: Checkout gamedir-languages
|
|
||||||
if: matrix.language != 'English'
|
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
repository: ${{ env.GAMEDIR_LANGUAGES_REPOSITORY }}
|
|
||||||
ref: ${{ env.GAMEDIR_LANGUAGES_COMMIT_SHA }}
|
|
||||||
path: gamedir-languages
|
|
||||||
|
|
||||||
- name: Copy gamedir-languages files to gamedir
|
|
||||||
if: matrix.language != 'English'
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -eux
|
|
||||||
cp -a gamedir-languages/${{ matrix.language }}_Version/* gamedir/
|
|
||||||
|
|
||||||
- name: Download applications
|
|
||||||
uses: actions/download-artifact@v8
|
|
||||||
with:
|
|
||||||
pattern: ja2*
|
|
||||||
path: artifacts
|
|
||||||
|
|
||||||
- name: Copy application files to gamedir
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -eux
|
|
||||||
for APP in ja2 ja2mapeditor ja2ub ja2ubmapeditor
|
|
||||||
do
|
|
||||||
mv artifacts/${APP}/*.exe gamedir/${APP}.exe
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Create version information file
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -eux
|
|
||||||
|
|
||||||
# "-" separates words, "_" combines words, see double-click behavior
|
|
||||||
DIST_PREFIX='JA2_113'
|
|
||||||
DIST_NAME="${DIST_PREFIX}-${GAME_VERSION}-G${GAMEDIR_COMMIT_SHA:0:4}L${GAMEDIR_LANGUAGES_COMMIT_SHA:0:4}-${{ matrix.language }}"
|
|
||||||
echo "DIST_NAME=$DIST_NAME" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
echo "If you encounter problems during gameplay, please provide the following version information:
|
|
||||||
Distribution Name: $DIST_NAME
|
|
||||||
Game Version: $GAME_VERSION
|
|
||||||
Language: ${{ matrix.language }}
|
|
||||||
Build Information: $GAME_BUILD_INFORMATION
|
|
||||||
Source Repository: $GITHUB_REPOSITORY
|
|
||||||
Source Commit SHA: $GITHUB_SHA
|
|
||||||
Source Commit Date: $SOURCE_COMMIT_DATETIME
|
|
||||||
Gamedir Repository: $GAMEDIR_REPOSITORY
|
|
||||||
Gamedir Commit SHA: $GAMEDIR_COMMIT_SHA
|
|
||||||
Gamedir Commit Date: $GAMEDIR_COMMIT_DATETIME
|
|
||||||
Gamedir Languages Repository: $GAMEDIR_LANGUAGES_REPOSITORY
|
|
||||||
Gamedir Languages Commit SHA: $GAMEDIR_LANGUAGES_COMMIT_SHA
|
|
||||||
Gamedir Languages Commit Date: $GAMEDIR_LANGUAGES_COMMIT_DATETIME
|
|
||||||
" > "gamedir/${DIST_PREFIX}-Version.txt"
|
|
||||||
cat "gamedir/${DIST_PREFIX}-Version.txt"
|
|
||||||
|
|
||||||
- name: Create release archive
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -eux
|
|
||||||
mkdir dist/
|
|
||||||
cd gamedir/
|
|
||||||
7z a -bb -xr'!.*' "../dist/${DIST_NAME}.7z" .
|
|
||||||
|
|
||||||
- name: Upload
|
|
||||||
uses: actions/upload-artifact@v7
|
|
||||||
with:
|
|
||||||
name: ${{ matrix.language }}_release
|
|
||||||
path: dist/
|
|
||||||
compression-level: 0
|
|
||||||
|
|
||||||
release:
|
|
||||||
needs: [ workflow_setup, assemble ]
|
|
||||||
if: needs.workflow_setup.outputs.assemble_release == 'true'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Download artifacts
|
|
||||||
uses: actions/download-artifact@v8
|
|
||||||
with:
|
|
||||||
path: dist
|
|
||||||
pattern: '*_release'
|
|
||||||
merge-multiple: true
|
|
||||||
|
|
||||||
- name: Checkout Repo
|
|
||||||
uses: actions/checkout@v7
|
|
||||||
with:
|
|
||||||
path: source
|
|
||||||
fetch-depth: 1
|
|
||||||
sparse-checkout: 'README.md'
|
|
||||||
- name: Create latest pre-release
|
|
||||||
if: github.ref == 'refs/heads/master'
|
|
||||||
working-directory: source
|
|
||||||
run: |
|
|
||||||
gh release delete latest --cleanup-tag || true
|
|
||||||
git tag -d latest || true
|
|
||||||
git push --delete origin refs/tags/latest || true
|
|
||||||
git tag latest
|
|
||||||
git push --force origin refs/tags/latest
|
|
||||||
sleep 15 # make sure github can find the tag for gh release
|
|
||||||
gh release create latest ../dist/* \
|
|
||||||
--generate-notes \
|
|
||||||
--title "Latest (unstable)" \
|
|
||||||
--verify-tag \
|
|
||||||
--prerelease
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Upload to tagged release
|
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
|
||||||
working-directory: source
|
|
||||||
run: |
|
|
||||||
gh release upload "$GITHUB_REF_NAME" ../dist/* --clobber
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|||||||
@@ -0,0 +1,176 @@
|
|||||||
|
name: release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
# allows to manually trigger a build
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
assemble_release:
|
||||||
|
description: create release
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
uses: ./.github/workflows/build.yml
|
||||||
|
|
||||||
|
# only the game data differs per language, every package gets the same executables
|
||||||
|
assemble:
|
||||||
|
needs: build
|
||||||
|
# a manual run only assembles when asked for it. Otherwise every tag does,
|
||||||
|
# and master does in the upstream repository, which is the only one with
|
||||||
|
# somewhere to publish to
|
||||||
|
if: >-
|
||||||
|
${{ github.event_name == 'workflow_dispatch' && inputs.assemble_release
|
||||||
|
|| github.event_name != 'workflow_dispatch'
|
||||||
|
&& ( ( github.repository == '1dot13/source' && github.ref_name == 'master' )
|
||||||
|
|| startsWith(github.ref, 'refs/tags/v') ) }}
|
||||||
|
runs-on: windows-latest # required for case-insensitive filesystem handling
|
||||||
|
# at least English has to work
|
||||||
|
continue-on-error: ${{ matrix.language != 'English' }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: [Chinese, German, English, French, Polish, Italian, Dutch, Russian]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download versions.env
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
name: versions.env
|
||||||
|
path: artifacts
|
||||||
|
- name: Restore versions.env
|
||||||
|
shell: bash
|
||||||
|
run: cat artifacts/versions.env >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Checkout gamedir
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
repository: ${{ env.GAMEDIR_REPOSITORY }}
|
||||||
|
ref: ${{ env.GAMEDIR_COMMIT_SHA }}
|
||||||
|
path: gamedir
|
||||||
|
|
||||||
|
- name: Checkout gamedir-languages
|
||||||
|
if: matrix.language != 'English'
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
repository: ${{ env.GAMEDIR_LANGUAGES_REPOSITORY }}
|
||||||
|
ref: ${{ env.GAMEDIR_LANGUAGES_COMMIT_SHA }}
|
||||||
|
path: gamedir-languages
|
||||||
|
|
||||||
|
- name: Copy gamedir-languages files to gamedir
|
||||||
|
if: matrix.language != 'English'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
cp -a gamedir-languages/${{ matrix.language }}_Version/* gamedir/
|
||||||
|
|
||||||
|
- name: Download applications
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
pattern: ja2*
|
||||||
|
path: artifacts
|
||||||
|
|
||||||
|
- name: Copy application files to gamedir
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
for APP in ja2 ja2mapeditor ja2ub ja2ubmapeditor
|
||||||
|
do
|
||||||
|
mv artifacts/${APP}/*.exe gamedir/${APP}.exe
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Create version information file
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
|
||||||
|
# "-" separates words, "_" combines words, see double-click behavior
|
||||||
|
DIST_PREFIX='JA2_113'
|
||||||
|
DIST_NAME="${DIST_PREFIX}-${GAME_VERSION}-G${GAMEDIR_COMMIT_SHA:0:4}L${GAMEDIR_LANGUAGES_COMMIT_SHA:0:4}-${{ matrix.language }}"
|
||||||
|
echo "DIST_NAME=$DIST_NAME" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
echo "If you encounter problems during gameplay, please provide the following version information:
|
||||||
|
Distribution Name: $DIST_NAME
|
||||||
|
Game Version: $GAME_VERSION
|
||||||
|
Language: ${{ matrix.language }}
|
||||||
|
Build Information: $GAME_BUILD_INFORMATION
|
||||||
|
Source Repository: $GITHUB_REPOSITORY
|
||||||
|
Source Commit SHA: $GITHUB_SHA
|
||||||
|
Source Commit Date: $SOURCE_COMMIT_DATETIME
|
||||||
|
Gamedir Repository: $GAMEDIR_REPOSITORY
|
||||||
|
Gamedir Commit SHA: $GAMEDIR_COMMIT_SHA
|
||||||
|
Gamedir Commit Date: $GAMEDIR_COMMIT_DATETIME
|
||||||
|
Gamedir Languages Repository: $GAMEDIR_LANGUAGES_REPOSITORY
|
||||||
|
Gamedir Languages Commit SHA: $GAMEDIR_LANGUAGES_COMMIT_SHA
|
||||||
|
Gamedir Languages Commit Date: $GAMEDIR_LANGUAGES_COMMIT_DATETIME
|
||||||
|
" > "gamedir/${DIST_PREFIX}-Version.txt"
|
||||||
|
cat "gamedir/${DIST_PREFIX}-Version.txt"
|
||||||
|
|
||||||
|
- name: Create release archive
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -eux
|
||||||
|
mkdir dist/
|
||||||
|
cd gamedir/
|
||||||
|
7z a -bb -xr'!.*' "../dist/${DIST_NAME}.7z" .
|
||||||
|
|
||||||
|
- name: Upload
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: ${{ matrix.language }}_release
|
||||||
|
path: dist/
|
||||||
|
compression-level: 0
|
||||||
|
|
||||||
|
# a skipped assemble skips this too, so it needs no condition of its own
|
||||||
|
release:
|
||||||
|
needs: assemble
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Download artifacts
|
||||||
|
uses: actions/download-artifact@v8
|
||||||
|
with:
|
||||||
|
path: dist
|
||||||
|
pattern: '*_release'
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Checkout Repo
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
path: source
|
||||||
|
fetch-depth: 1
|
||||||
|
sparse-checkout: 'README.md'
|
||||||
|
- name: Create latest pre-release
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
working-directory: source
|
||||||
|
run: |
|
||||||
|
gh release delete latest --cleanup-tag || true
|
||||||
|
git tag -d latest || true
|
||||||
|
git push --delete origin refs/tags/latest || true
|
||||||
|
git tag latest
|
||||||
|
git push --force origin refs/tags/latest
|
||||||
|
sleep 15 # make sure github can find the tag for gh release
|
||||||
|
gh release create latest ../dist/* \
|
||||||
|
--generate-notes \
|
||||||
|
--title "Latest (unstable)" \
|
||||||
|
--verify-tag \
|
||||||
|
--prerelease
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Upload to tagged release
|
||||||
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
|
working-directory: source
|
||||||
|
run: |
|
||||||
|
gh release upload "$GITHUB_REF_NAME" ../dist/* --clobber
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
Reference in New Issue
Block a user