diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..f5c6ed2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,78 @@ +# Builds Morpho Match and its two-player server and, on a tag, publishes them +# as a GitHub release, so a check or a CI job can install the game without +# building it: `gh release download -R mobiumdev/morpho-match`, or +# https://github.com/mobiumdev/morpho-match/releases/latest/download/. +# +# The file names do not carry the version, so that latest/download URL +# stays the same from release to release. The APK runs on a phone and on a +# Meta Quest, and is signed with the runner's debug key: an app under test, +# never published to a store. The server listens on 127.0.0.1:8787 unless +# given -addr. +# +# A pull request that changes this file builds everything and publishes +# nothing. +name: Release + +on: + push: + tags: ['v*'] + pull_request: + paths: ['.github/workflows/release.yml'] + workflow_dispatch: + +permissions: + contents: read + +jobs: + android: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: '21' + - run: ./gradlew --no-daemon :app:testDebugUnitTest :app:assembleRelease + working-directory: android + - run: cp android/app/build/outputs/apk/release/app-release.apk MorphoMatch-android.apk + - uses: actions/upload-artifact@v5 + with: + name: android + path: MorphoMatch-android.apk + + server: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-go@v6 + with: + go-version-file: server/go.mod + - run: go test ./... + working-directory: server + - run: | + for t in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64; do + os=${t%/*}; arch=${t#*/}; ext=; [ "$os" = windows ] && ext=.exe + CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -trimpath -o "../morpho-match-server-$os-$arch$ext" . + done + working-directory: server + - uses: actions/upload-artifact@v5 + with: + name: server + path: morpho-match-server-* + + release: + if: startsWith(github.ref, 'refs/tags/v') + needs: [android, server] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/download-artifact@v5 + with: + path: dist + merge-multiple: true + - run: sha256sum * > SHA256SUMS + working-directory: dist + - run: gh release create "$GITHUB_REF_NAME" dist/* --repo "$GITHUB_REPOSITORY" --title "Morpho Match $GITHUB_REF_NAME" --generate-notes + env: + GH_TOKEN: ${{ github.token }} diff --git a/README.md b/README.md index 2ff5aa8..4d050b1 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ Recorded on an Android 15 emulator and the Meta Spatial Simulator - [See it run](#see-it-run) - [Why it exists](#why-it-exists) - [What is in it](#what-is-in-it) +- [Install a release](#install-a-release) - [Build and install](#build-and-install) - [Run the tests](#run-the-tests) - [Two players](#two-players) @@ -120,6 +121,25 @@ tests-duo/ duo-play.sh, duo-matrix.sh and duo-outage.sh, the two-device scripts docs/media the recordings above ``` +## Install a release + +Each tag `v*` publishes the game, `MorphoMatch-android.apk` (a phone or a +Meta Quest), and the two-player server for Linux, macOS and Windows, +`morpho-match-server--`, with `SHA256SUMS`, made by +`.github/workflows/release.yml` under names that stay the same from release +to release. + +```sh +gh release download -R mobiumdev/morpho-match -p MorphoMatch-android.apk +adb install -r MorphoMatch-android.apk + +gh release download -R mobiumdev/morpho-match -p morpho-match-server-darwin-arm64 +chmod +x morpho-match-server-darwin-arm64 && ./morpho-match-server-darwin-arm64 -seed 42 +``` + +The APK is signed with the build machine's debug key, so uninstall one you +built yourself before installing a release over it. + ## Build and install Needs JDK 21 and the Android SDK; the server needs Go.