From f5d328c3a5bd1d847b21cc8b660dbf6417ef680c Mon Sep 17 00:00:00 2001 From: maj00r Date: Tue, 6 Oct 2026 22:19:12 +0200 Subject: [PATCH] ci: translations of lang/ packaged with the builds; each push of a branch publishes its Windows and Linux builds as the rolling pre-release build-, downloadable without a GitHub account and removed along with the branch --- .github/workflows/build_bin.yml | 95 ++++++++++++++++++++++++++++- .github/workflows/build_cleanup.yml | 21 +++++++ 2 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build_cleanup.yml diff --git a/.github/workflows/build_bin.yml b/.github/workflows/build_bin.yml index f0b1fdec..255c89a6 100644 --- a/.github/workflows/build_bin.yml +++ b/.github/workflows/build_bin.yml @@ -87,7 +87,7 @@ jobs: --config $env:CONFIG_WIN ` --parallel - - name: Copy shaders + - name: Copy shaders and translations shell: pwsh run: | $output = "build/bin/$env:CONFIG_WIN" @@ -103,6 +103,17 @@ jobs: -Recurse ` -Force + New-Item ` + -ItemType Directory ` + -Force ` + -Path "$output/lang" | Out-Null + + Copy-Item ` + -Path "lang/*" ` + -Destination "$output/lang" ` + -Recurse ` + -Force + - name: Upload Windows build uses: actions/upload-artifact@v4 with: @@ -238,10 +249,11 @@ jobs: "$PYTHON_HOME/bin/python" -c "from PIL import Image; print('Pillow:', Image.__version__)" - - name: Copy shaders + - name: Copy shaders and translations run: | - mkdir -p build/bin/shaders + mkdir -p build/bin/shaders build/bin/lang cp -R shaders/. build/bin/shaders/ + cp -R lang/. build/bin/lang/ - name: Upload Linux build uses: actions/upload-artifact@v4 @@ -251,3 +263,80 @@ jobs: build/bin/ if-no-files-found: error retention-days: 14 + + + # ============================================================ + # Public download: release assets need no GitHub account + # ============================================================ + + publish: + name: Publish public download + needs: [windows, linux] + if: github.event_name != 'pull_request' + runs-on: ubuntu-24.04 + permissions: + contents: write + concurrency: + group: publish-${{ github.ref }} + cancel-in-progress: false + + steps: + - name: Download Windows build + uses: actions/download-artifact@v4 + with: + name: maszyna-windows-x64-${{ env.CONFIG_WIN }} + path: dist/maszyna-windows-x64 + + - name: Download Linux build + uses: actions/download-artifact@v4 + with: + name: maszyna-linux-x64-${{ env.CONFIG_LINUX }} + path: dist/maszyna-linux-x64 + + - name: Pack + run: | + cd dist + + find maszyna-linux-x64 -type f -exec sh -c 'file -b "$1" | grep -q "^ELF" && chmod +x "$1"' _ {} \; + if [ -d maszyna-linux-x64/linuxpython64/bin ]; then + chmod +x maszyna-linux-x64/linuxpython64/bin/* + fi + + (cd maszyna-windows-x64 && zip -qr9 ../maszyna-windows-x64.zip .) + tar -czf maszyna-linux-x64.tar.gz -C maszyna-linux-x64 . + ls -la + + - name: Publish rolling release of the branch + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + BRANCH: ${{ github.ref_name }} + SHA: ${{ github.sha }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + slug="$(printf '%s' "$BRANCH" | tr '/ ' '--' | tr -cd '[:alnum:]._-')" + tag="build-$slug" + base="${{ github.server_url }}/${{ github.repository }}/releases/download/$tag" + + notes="$(printf '%s\n' \ + "Automatic build of branch \`$BRANCH\`, commit $SHA, replaced by every push to the branch." \ + "" \ + "Download without a GitHub account:" \ + "- Windows: $base/maszyna-windows-x64.zip" \ + "- Linux: $base/maszyna-linux-x64.tar.gz" \ + "" \ + "Unpack over a MaSzyna installation (the game data isn't included). Build log: $RUN_URL")" + + gh release delete "$tag" --yes --cleanup-tag || true + gh release create "$tag" \ + dist/maszyna-windows-x64.zip \ + dist/maszyna-linux-x64.tar.gz \ + --target "$SHA" \ + --prerelease \ + --latest=false \ + --title "Build: $BRANCH" \ + --notes "$notes" + + echo "### Public download" >> "$GITHUB_STEP_SUMMARY" + echo "- Windows: $base/maszyna-windows-x64.zip" >> "$GITHUB_STEP_SUMMARY" + echo "- Linux: $base/maszyna-linux-x64.tar.gz" >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/build_cleanup.yml b/.github/workflows/build_cleanup.yml new file mode 100644 index 00000000..8b20be0d --- /dev/null +++ b/.github/workflows/build_cleanup.yml @@ -0,0 +1,21 @@ +name: Remove public build of a deleted branch + +on: + delete: + +permissions: + contents: write + +jobs: + cleanup: + if: github.event.ref_type == 'branch' + runs-on: ubuntu-24.04 + steps: + - name: Delete the rolling release of the branch + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + BRANCH: ${{ github.event.ref }} + run: | + slug="$(printf '%s' "$BRANCH" | tr '/ ' '--' | tr -cd '[:alnum:]._-')" + gh release delete "build-$slug" --yes --cleanup-tag || true