Merge pull request #278 from janhohenheim/bevy-12 #31
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: | |
- "v[0-9]+.[0-9]+.[0-9]+*" | |
env: | |
# heads-up: this value is used as a pattern in a sed command as a workaround for a trunk issue | |
# if you use special characters, take a look at the 'Make paths relative' step in the 'build-web' job | |
GAME_EXECUTABLE_NAME: foxtrot | |
GAME_OSX_APP_NAME: Foxtrot | |
CARGO_TERM_COLOR: always | |
NIGHTLY_TOOLCHAIN: nightly | |
# Sparse cargo registry for faster updates | |
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse | |
permissions: | |
contents: write | |
jobs: | |
build-macOS: | |
runs-on: macos-latest | |
env: | |
# macOS 11.0 Big Sur is the first version of macOS to support universal binaries | |
MACOSX_DEPLOYMENT_TARGET: 11.0 | |
steps: | |
- name: Get tag | |
id: tag | |
uses: dawidd6/action-get-tag@v1 | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Check out LFS objects | |
run: | | |
git lfs pull | |
- name: Remove build script | |
run: | | |
rm build.rs | |
- name: Install rust toolchain for Apple Silicon | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} | |
target: aarch64-apple-darwin | |
- name: Install zld | |
run: | | |
brew install michaeleisel/zld/zld | |
- name: Build release for Apple Silicon | |
run: | | |
SDKROOT=$(xcrun -sdk macosx --show-sdk-path) RUSTFLAGS="-C link-arg=-fuse-ld=/usr/local/bin/zld -Z share-generics=y" cargo build --release --no-default-features --features native --target=aarch64-apple-darwin | |
- name: Install rust toolchain for Apple x86 | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} | |
target: x86_64-apple-darwin | |
- name: Build release for x86 Apple | |
run: | | |
SDKROOT=$(xcrun -sdk macosx --show-sdk-path) cargo build --release --no-default-features --features native --target=x86_64-apple-darwin | |
- name: Create Universal Binary | |
run: | | |
lipo -create -output target/release/${{ env.GAME_EXECUTABLE_NAME }} target/aarch64-apple-darwin/release/${{ env.GAME_EXECUTABLE_NAME }} target/x86_64-apple-darwin/release/${{ env.GAME_EXECUTABLE_NAME }} | |
- name: Create release | |
run: | | |
mkdir -p build/macos/src/Game.app/Contents/MacOS/assets | |
cp -r assets/ build/macos/src/Game.app/Contents/MacOS/assets | |
cp -r credits/ build/macos/src/Game.app/Contents/MacOS/credits | |
cp target/release/${{ env.GAME_EXECUTABLE_NAME }} build/macos/src/Game.app/Contents/MacOS/ | |
strip build/macos/src/Game.app/Contents/MacOS/${{ env.GAME_EXECUTABLE_NAME }} | |
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: Upload release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ env.GAME_EXECUTABLE_NAME }}.dmg | |
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ steps.tag.outputs.tag }}_macOS.dmg | |
tag: ${{ github.ref }} | |
overwrite: true | |
build-linux: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get tag | |
id: tag | |
uses: dawidd6/action-get-tag@v1 | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Check out LFS objects | |
run: | | |
git lfs pull | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} | |
- name: Install Dependencies | |
run: sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev | |
- name: Build release | |
run: | | |
cargo build --release --no-default-features --features native | |
- name: Prepare release | |
run: | | |
strip target/release/${{ env.GAME_EXECUTABLE_NAME }} | |
chmod +x target/release/${{ env.GAME_EXECUTABLE_NAME }} | |
mv target/release/${{ env.GAME_EXECUTABLE_NAME }} . | |
- name: Bundle release | |
run: | | |
tar -czf ${{ env.GAME_EXECUTABLE_NAME }}_linux.tar.gz ${{ env.GAME_EXECUTABLE_NAME }} assets credits | |
- name: Upload release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ env.GAME_EXECUTABLE_NAME }}_linux.tar.gz | |
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ steps.tag.outputs.tag }}_linux.tar.gz | |
tag: ${{ github.ref }} | |
overwrite: true | |
build-windows: | |
runs-on: windows-latest | |
steps: | |
- name: Get tag | |
id: tag | |
uses: dawidd6/action-get-tag@v1 | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Check out LFS objects | |
run: | | |
git lfs pull | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} | |
- name: Install dotnet | |
uses: actions/setup-dotnet@v3 | |
with: | |
global-json-file: build/windows/installer/global.json | |
- name: Build release | |
run: | | |
cargo build --release --no-default-features --features native | |
- name: Prepare release | |
run: | | |
mkdir target/release/assets && cp -r assets target/release/assets | |
mkdir target/release/credits && cp -r credits target/release/credits | |
- name: Zip release | |
uses: vimtor/action-zip@v1 | |
with: | |
files: target/release/assets/ target/release/credits/ target/release/${{ env.GAME_EXECUTABLE_NAME }}.exe | |
dest: ${{ env.GAME_EXECUTABLE_NAME }}_windows.zip | |
- name: Create Installer | |
run: dotnet build -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 }}_${{ steps.tag.outputs.tag }}_windows.zip | |
tag: ${{ github.ref }} | |
overwrite: true | |
- name: Upload installer | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: installer/en-US/installer.msi | |
asset_name: ${{ env.GAME_EXECUTABLE_NAME }}_${{ steps.tag.outputs.tag }}_windows.msi | |
tag: ${{ github.ref }} | |
overwrite: true | |
build-web: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
lfs: true | |
- name: Check out LFS objects | |
run: | | |
git lfs pull | |
- name: Install rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} | |
- name: Install Dependencies | |
run: sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev | |
- name: Install trunk | |
uses: jetli/[email protected] | |
with: | |
version: "v0.16.0" | |
- name: Add wasm target | |
run: | | |
rustup target add wasm32-unknown-unknown | |
- name: Build Release | |
run: | | |
trunk build --release --public-url "${GITHUB_REPOSITORY#*/}" --no-default-features --features wasm | |
- name: Optimize Wasm | |
uses: NiklasEi/wasm-opt-action@v2 | |
with: | |
file: dist/*.wasm | |
- name: Deploy to GitHub Pages | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages | |
folder: dist |