Simplified sentence to make it more user-friendly #103
Workflow file for this run
This file contains 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: release-flow | |
on: | |
push: | |
tags: | |
- "[0-9]+.[0-9]+.[0-9]+*" | |
workflow_dispatch: | |
inputs: | |
version: | |
description: '0.1.0' | |
required: true | |
type: string | |
env: | |
# This variable is used to name release output files. | |
GAME_EXECUTABLE_NAME: Minesweeper | |
GAME_OSX_APP_NAME: Minesweeper | |
permissions: | |
contents: write | |
jobs: | |
get-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get tag | |
id: tag | |
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" | |
outputs: | |
version: ${{ inputs.version || steps.tag.outputs.tag }} | |
build-macOS: | |
runs-on: macos-latest | |
needs: get-version | |
env: | |
# macOS 11.0 Big Sur is the first version to support universal binaries | |
MACOSX_DEPLOYMENT_TARGET: 11.0 | |
VERSION: ${{needs.get-version.outputs.version}} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup | |
run: | | |
rm build.rs | |
brew install llvm | |
- name: Install rust toolchain for Apple Silicon | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
targets: aarch64-apple-darwin | |
- name: Build release for Apple Silicon | |
run: | | |
SDKROOT=$(xcrun -sdk macosx --show-sdk-path) cargo build --profile dist --target=aarch64-apple-darwin | |
- name: Install rust toolchain for Apple x86 | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
components: rust-src | |
targets: x86_64-apple-darwin | |
- name: Build release for x86 Apple | |
run: | | |
SDKROOT=$(xcrun -sdk macosx --show-sdk-path) cargo build --profile dist --target=x86_64-apple-darwin | |
- name: Create Universal Binary | |
run: | | |
lipo -create -output target/dist/${{ env.GAME_EXECUTABLE_NAME }} target/aarch64-apple-darwin/dist/${{ env.GAME_EXECUTABLE_NAME }} target/x86_64-apple-darwin/dist/${{ env.GAME_EXECUTABLE_NAME }} | |
- name: Create release | |
run: | | |
mkdir -p build/macos/src/Game.app/Contents/MacOS/ | |
cp target/dist/${{ env.GAME_EXECUTABLE_NAME }} build/macos/src/Game.app/Contents/MacOS/ | |
mv build/macos/src/Game.app build/macos/src/${{ env.GAME_OSX_APP_NAME }}.app | |
ln -s /Applications build/macos/src/ | |
hdiutil create -fs HFS+ -volname "${{ env.GAME_OSX_APP_NAME }}" -srcfolder build/macos/src ${{ env.GAME_EXECUTABLE_NAME }}.dmg | |
- name: Compress release | |
run: | | |
zip ${{ env.GAME_EXECUTABLE_NAME }}_macOS.zip ${{ env.GAME_EXECUTABLE_NAME }}.dmg | |
- name: Upload release | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ env.GAME_EXECUTABLE_NAME }}_macOS.zip | |
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_macOS.zip | |
release_name: ${{ env.VERSION }} | |
tag: ${{ env.VERSION }} | |
overwrite: true | |
build-linux: | |
runs-on: ubuntu-latest | |
needs: get-version | |
env: | |
VERSION: ${{needs.get-version.outputs.version}} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
components: rust-src | |
- name: Install Dependencies | |
run: sudo apt-get update; sudo apt install -y pkg-config libx11-dev mold upx libwayland-dev libasound2-dev libudev-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev | |
- name: Build release | |
run: | | |
cargo build --profile dist | |
- name: Prepare release | |
run: | | |
chmod +x target/dist/${{ env.GAME_EXECUTABLE_NAME }} | |
mv target/dist/${{ env.GAME_EXECUTABLE_NAME }} . | |
- name: Compress release | |
run: | | |
zip ${{ env.GAME_EXECUTABLE_NAME }}_linux.zip ${{ env.GAME_EXECUTABLE_NAME }} | |
- name: Upload release | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ env.GAME_EXECUTABLE_NAME }}_linux.zip | |
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_linux.zip | |
release_name: ${{ env.VERSION }} | |
tag: ${{ env.VERSION }} | |
overwrite: true | |
build-windows: | |
runs-on: windows-latest | |
needs: get-version | |
env: | |
VERSION: ${{needs.get-version.outputs.version}} | |
BUILD_INSTALLER: ${{ false }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
components: rust-src | |
- name: Install dotnet | |
if: ${{ env.BUILD_INSTALLER }} | |
uses: actions/setup-dotnet@v3 | |
with: | |
global-json-file: build/windows/installer/global.json | |
- name: Build release | |
run: | | |
cargo build --profile dist | |
- name: Zip release | |
uses: vimtor/[email protected] | |
with: | |
files: target/dist/${{ env.GAME_EXECUTABLE_NAME }}.exe | |
dest: ${{ env.GAME_EXECUTABLE_NAME }}_windows.zip | |
- name: Create Installer | |
if: ${{ env.BUILD_INSTALLER }} | |
run: dotnet build -p:Version=${{ env.VERSION }} -c Release build/windows/installer/Installer.wixproj --output installer | |
- name: Upload release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ env.GAME_EXECUTABLE_NAME }}_windows.zip | |
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_windows.zip | |
tag: ${{ env.VERSION }} | |
overwrite: true | |
- name: Upload installer | |
if: ${{ env.BUILD_INSTALLER }} | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: installer/en-US/installer.msi | |
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_windows.msi | |
release_name: ${{ env.VERSION }} | |
tag: ${{ env.VERSION }} | |
overwrite: true | |
build-web: | |
runs-on: ubuntu-latest | |
needs: get-version | |
env: | |
VERSION: ${{needs.get-version.outputs.version}} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
components: rust-src | |
- name: Install Dependencies | |
run: sudo apt-get update; sudo apt install -y pkg-config libx11-dev mold upx libwayland-dev libasound2-dev libudev-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev | |
- name: Install trunk | |
uses: jetli/[email protected] | |
with: | |
version: latest | |
- name: Add wasm target | |
run: | | |
rustup target add wasm32-unknown-unknown | |
- name: Build Release | |
run: | | |
trunk build --release | |
- name: Optimize Wasm | |
uses: NiklasEi/wasm-opt-action@v2 | |
with: | |
file: dist/*.wasm | |
- name: Zip release | |
uses: vimtor/[email protected] | |
with: | |
files: dist/ | |
dest: ${{ env.GAME_EXECUTABLE_NAME }}_web.zip | |
- name: Upload release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ env.GAME_EXECUTABLE_NAME }}_web.zip | |
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_web.zip | |
release_name: ${{ env.VERSION }} | |
tag: ${{ env.VERSION }} | |
overwrite: true | |
build-for-iOS: | |
runs-on: macos-latest | |
timeout-minutes: 30 | |
needs: get-version | |
env: | |
VERSION: ${{needs.get-version.outputs.version}} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Add iOS targets | |
run: rustup target add aarch64-apple-ios x86_64-apple-ios | |
- name: Build app for iOS | |
run: | | |
cd mobile | |
make xcodebuild-iphone-release | |
mkdir Payload | |
mv build/Build/Products/Release-iphoneos/*.app Payload | |
zip -r ${{ env.GAME_EXECUTABLE_NAME }}.zip Payload | |
mv ${{ env.GAME_EXECUTABLE_NAME }}.zip ${{ env.GAME_EXECUTABLE_NAME }}_unsigned_ios.ipa | |
zip "${{ env.GAME_EXECUTABLE_NAME }}.zip" "${{ env.GAME_EXECUTABLE_NAME }}_unsigned_ios.ipa" | |
- name: Upload release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: mobile/${{ env.GAME_EXECUTABLE_NAME }}.zip | |
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_unsigned_ios.zip | |
release_name: ${{ env.VERSION }} | |
tag: ${{ env.VERSION }} | |
overwrite: true | |
build-for-Android-debug: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
needs: get-version | |
env: | |
VERSION: ${{needs.get-version.outputs.version}} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Add Android targets | |
run: rustup target add aarch64-linux-android armv7-linux-androideabi | |
- name: Install Cargo APK | |
run: cargo install --force cargo-apk | |
- name: Build app for Android | |
run: ANDROID_NDK_ROOT=$ANDROID_NDK_LATEST_HOME cargo apk build --package mobile | |
- name: Zip release | |
run: | | |
cd target/debug/apk && zip "${{ env.GAME_EXECUTABLE_NAME }}_android-debug.zip" ${{ env.GAME_OSX_APP_NAME }}.apk && cd ../../../ | |
- name: Upload release | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: target/debug/apk/${{ env.GAME_EXECUTABLE_NAME }}_android-debug.zip | |
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_android-debug.zip | |
release_name: ${{ env.VERSION }} | |
tag: ${{ env.VERSION }} | |
overwrite: true | |
build-for-Android-release: | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
needs: get-version | |
env: | |
VERSION: ${{needs.get-version.outputs.version}} | |
GAME_EXECUTABLE_NAME: Minesweeper | |
BUNDLE_PATH: "target/x/release/android/mobile.aab" | |
PACKAGE_NAME: "prrmrc.game.minesweeper" | |
TRACK: internal | |
MOBILE_DIRECTORY: mobile | |
steps: | |
- name: Install Dependencies | |
run: sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev lld llvm | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Add Android targets | |
run: rustup target add aarch64-linux-android armv7-linux-androideabi | |
- name: Install cargo-binstall | |
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash | |
- name: Install xbuild | |
run: cargo binstall --git https://github.com/NiklasEi/xbuild --bin-dir x xbuild -y | |
- name: Build app bundle | |
run: | | |
cd ${{ env.MOBILE_DIRECTORY }} | |
x doctor | |
x build --release --platform android --store play | |
- name: Sign app bundle | |
run: | | |
KEYSTORE_PATH=${{ runner.temp }}/upload-keystore.jks | |
echo -n "${{ secrets.PLAYSTORE_KEYSTORE }}" | base64 --decode > $KEYSTORE_PATH | |
jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore $KEYSTORE_PATH -storepass "${{ secrets.PLAYSTORE_KEYSTORE_PASSWORD }}" ${{ env.BUNDLE_PATH }} upload | |
- name: Convert aab to apk | |
id: convert_aab | |
uses: ethanneff/[email protected] | |
with: | |
aabFile: ${{ env.BUNDLE_PATH }} | |
base64Keystore: ${{ secrets.PLAYSTORE_KEYSTORE }} | |
keystorePassword: ${{ secrets.PLAYSTORE_KEYSTORE_PASSWORD }} | |
keystoreAlias: upload | |
keyPassword: ${{ secrets.PLAYSTORE_KEYSTORE_PASSWORD }} | |
- name: Zip release | |
run: | | |
zip "${{ env.GAME_EXECUTABLE_NAME }}_android.zip" ${{ steps.convert_aab.outputs.apkPath }} | |
- name: Upload signed apk to GitHub | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ env.GAME_EXECUTABLE_NAME }}_android.zip | |
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ env.VERSION }}_android.zip | |
release_name: ${{ env.VERSION }} | |
tag: ${{ env.VERSION }} | |
overwrite: true |