Create a snapshot release #219
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Create a snapshot release | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| prepare: | |
| name: Prepare the environment | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout the master branch | |
| uses: actions/checkout@v4 | |
| - name: Install Nix | |
| uses: nixbuild/nix-quick-install-action@v29 | |
| with: | |
| nix_conf: | | |
| require-sigs = false | |
| - name: Enter CI tailored shell | |
| uses: rrbutani/use-nix-shell-action@v1 | |
| with: | |
| devShell: .#ciDefault | |
| - name: Update Doom2D related inputs and populate environment variables | |
| run: | | |
| ./game/bundle/scripts/mkEnv.bash | |
| - name: Save updated flake.lock | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: flake.lock | |
| path: flake.lock | |
| - name: Save release_body | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release_body | |
| path: release_body | |
| build: | |
| name: Build | |
| needs: prepare | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| matrix: | |
| arch: | |
| - android | |
| - apple | |
| - mingw | |
| steps: | |
| - name: Free space | |
| run: | # stolen from https://github.com/easimon/maximize-build-space and https://github.com/actions/runner-images/issues/2840 | |
| echo "=== Before pruning ===" | |
| df -h | |
| sudo rm -rf /opt || : | |
| sudo rm -rf /usr/share/dotnet || : | |
| sudo rm -rf "/usr/local/share/boost" || : | |
| sudo rm -rf "$AGENT_TOOLSDIRECTORY" || : | |
| sudo rm -rf /opt/hostedtoolcache/CodeQL || : | |
| sudo rm -rf /usr/local/lib/android || : | |
| sudo rm -rf /opt/ghc || : | |
| sudo docker image prune --all --force || : | |
| sudo docker builder prune -a || : | |
| echo | |
| echo "=== After pruning ===" | |
| df -h | |
| - name: Checkout the master branch | |
| uses: actions/checkout@v4 | |
| - name: Install Nix | |
| uses: nixbuild/nix-quick-install-action@v30 | |
| with: | |
| nix_conf: | | |
| require-sigs = false | |
| - name: Enter CI tailored shell | |
| uses: rrbutani/use-nix-shell-action@v1 | |
| with: | |
| devShell: .#ciDefault | |
| - name: Calculate nixpkgs' lock hash | |
| run: | | |
| NIXPKGS_REV=$(nix flake metadata . --json 2>/dev/null | jq --raw-output '.locks.nodes."nixpkgs".locked.rev') | |
| echo "NIXPKGS_REV=$NIXPKGS_REV" >> "$GITHUB_ENV" | |
| - uses: actions/cache/restore@v4 | |
| name: Restore persistent cache | |
| with: | |
| path: /tmp/nixcache_${{ matrix.arch }} | |
| key: ${{ runner.os }}-${{ env.NIXPKGS_REV }}-${{ matrix.arch }} | |
| - name: Restore toolchain from cache | |
| run: | | |
| nix copy --all --from /tmp/nixcache_${{ matrix.arch }} | |
| - name: Delete old flake.lock | |
| run: | | |
| rm -f flake.lock | |
| - name: Restore updated flake.lock | |
| uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| - name: Populate environment variables | |
| env: | |
| UPDATE_FLAKE: 0 | |
| run: | | |
| ./game/bundle/scripts/mkEnv.bash | |
| - name: Build debug APK | |
| if: ${{ matrix.arch == 'android' }} | |
| env: | |
| BUNDLE_NAME: android.bundles.default | |
| EMBED_BUILD_DATE: 1 | |
| run: | | |
| ./game/bundle/scripts/mkOverride.bash | |
| cp result Doom2D-Forever.apk | |
| - name: Upload debug APK | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ matrix.arch == 'android' }} | |
| with: | |
| name: Doom2D-Forever.apk | |
| path: Doom2D-Forever.apk | |
| if-no-files-found: error | |
| - name: Build Windows x86 ZIP bundle | |
| if: ${{ matrix.arch == 'mingw' }} | |
| env: | |
| BUNDLE_NAME: mingw32.bundles.zip | |
| run: | | |
| ./game/bundle/scripts/mkOverride.bash | |
| cp result doom2df_windows.x86.zip | |
| - name: Upload Windows x86 ZIP bundle | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ matrix.arch == 'mingw' }} | |
| with: | |
| name: doom2df_windows.x86.zip | |
| path: doom2df_windows.x86.zip | |
| - name: Build Windows x86_64 ZIP bundle | |
| if: ${{ matrix.arch == 'mingw' }} | |
| env: | |
| BUNDLE_NAME: mingw64.bundles.zip | |
| run: | | |
| ./game/bundle/scripts/mkOverride.bash | |
| cp result doom2df_win64.x86-64.zip | |
| - name: Upload Windows x86_64 ZIP bundle | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ matrix.arch == 'mingw' }} | |
| with: | |
| name: doom2df_win64.x86-64.zip | |
| path: doom2df_win64.x86-64.zip | |
| - name: Build MacOS x86_64 ZIP bundle | |
| if: ${{ matrix.arch == 'apple' }} | |
| env: | |
| BUNDLE_NAME: x86_64-apple-darwin.bundles.zip | |
| run: | | |
| ./game/bundle/scripts/mkOverride.bash | |
| cp result doom2df_macos.intel64.zip | |
| - name: Upload MacOS x86_64 ZIP bundle | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ matrix.arch == 'apple' }} | |
| with: | |
| name: doom2df_macos.intel64.zip | |
| path: doom2df_macos.intel64.zip | |
| - name: Build MacOS aarch64 ZIP bundle | |
| if: ${{ matrix.arch == 'apple' }} | |
| env: | |
| BUNDLE_NAME: arm64-apple-darwin.bundles.zip | |
| run: | | |
| ./game/bundle/scripts/mkOverride.bash | |
| cp result doom2df_macos.aarch64.zip | |
| - name: Upload MacOS aarch64 ZIP bundle | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ matrix.arch == 'apple' }} | |
| with: | |
| name: doom2df_macos.aarch64.zip | |
| path: doom2df_macos.aarch64.zip | |
| - name: Build MacOS app bundle | |
| if: ${{ matrix.arch == 'apple' }} | |
| env: | |
| BUNDLE_NAME: macOS.bundles.default | |
| run: | | |
| ./game/bundle/scripts/mkOverride.bash | |
| cp result Doom2D-Forever.dmg | |
| - name: Upload MacOS app bundle | |
| uses: actions/upload-artifact@v4 | |
| if: ${{ matrix.arch == 'apple' }} | |
| with: | |
| name: Doom2D-Forever.dmg | |
| path: Doom2D-Forever.dmg | |
| if-no-files-found: error | |
| upload: | |
| name: Create a new release | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: write-all | |
| steps: | |
| - name: Download all artifacts in this run (release_body and artifacts) | |
| uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| - name: Calculate new build number | |
| run: | | |
| GITHUB_RESPONSE_FILE=github_response | |
| TODAY=$(date +'%Y-%m-%d') | |
| curl \ | |
| -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${{ github.repository }}/releases \ | |
| -H "Authorization: ${{ secrets.GITHUB_TOKEN }}" \ | |
| > $GITHUB_RESPONSE_FILE | |
| TODAY_RELEASES_COUNT=$(jq --arg TODAY $TODAY '[.[] | select((.published_at | startswith($TODAY) ) )] | length' $GITHUB_RESPONSE_FILE) | |
| THIS_RELEASE_COUNT=$(( $TODAY_RELEASES_COUNT + 1 )) | |
| RELEASE_PREFIX="0.667b" | |
| RELEASE_NAME="${RELEASE_PREFIX}-$(date +'%Y.%m.%d')-$THIS_RELEASE_COUNT" | |
| echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV | |
| - uses: ncipollo/release-action@v1 | |
| if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch'}} | |
| with: | |
| artifacts: doom2df_windows.x86.zip, Doom2D-Forever.apk, doom2df_win64.x86-64.zip, doom2df_macos.intel64.zip, doom2df_macos.aarch64.zip, Doom2D-Forever.dmg | |
| replacesArtifacts: false | |
| removeArtifacts: false | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| name: ${{ env.RELEASE_NAME }} | |
| bodyFile: release_body | |
| tag: ${{ env.RELEASE_NAME }} | |
| allowUpdates: false | |
| artifactErrorsFailBuild: true | |
| - name: Delete releases and workflows runs | |
| uses: ophub/delete-releases-workflows@main | |
| with: | |
| delete_releases: true | |
| releases_keep_latest: 16 | |
| delete_workflows: true | |
| workflows_keep_day: 10 | |
| gh_token: ${{ secrets.GITHUB_TOKEN }} |