Skip to content

Commit

Permalink
fix: examples ci
Browse files Browse the repository at this point in the history
skip-checks: true
  • Loading branch information
eerii committed Jul 13, 2024
1 parent b965537 commit aa67edd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 64 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ jobs:
uses: nicknovitski/nix-develop@v1

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
shared-key: "linux-debug"
uses: swatinem/rust-cache@v2

- name: Cargo test
run: cargo test --workspace
Expand All @@ -91,8 +89,6 @@ jobs:

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
shared-key: "linux-release"

- name: Cargo test
run: cargo test --workspace --release --no-default-features --features release
Expand Down
18 changes: 6 additions & 12 deletions .github/workflows/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ jobs:
features: "release"
- name: jump
features: "release"
fail-fast: false

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install nix
uses: nixbuild/nix-quick-install-action@v28
Expand All @@ -38,16 +39,15 @@ jobs:

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
shared-key: "web-release"

- name: Build
run: |
cargo build --release --example ${{ matrix.name }} --no-default-features --features ${{ matrix.features }} --target wasm32-unknown-unknown
- name: Prepare package
run: |
wasm-bindgen --no-typescript --out-name ${{ env.binary }} --out-dir wasm --target web target/wasm32-unknown-unknown/release/${{ env.binary }}.wasm
wasm-bindgen --no-typescript --out-name ${{ env.binary }} --out-dir wasm --target web target/wasm32-unknown-unknown/release/examples/${{ matrix.name }}.wasm
sed -i "s/hello-bevy/${{ env.binary }}/g" wasm/index.html
- name: Optimize Wasm
if: ${{ env.optimize == 'true' }}
Expand All @@ -56,14 +56,8 @@ jobs:
mv ${{ env.binary }}_bg.wasm base.wasm
wasm-opt base.wasm -o ${{ env.binary }}_bg.wasm -Os
- name: Package as a zip
working-directory: ./wasm
run: |
sed -i "s/hello-bevy/${{ env.binary }}/g" index.html
zip --recurse-paths ../${{ matrix.name }}.zip .
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ matrix.name }}.zip
name: wasm
path: wasm/*
name: ${{ matrix.name }}
74 changes: 32 additions & 42 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Based on https://github.com/bevyengine/bevy_github_ci_template/blob/main/.github/workflows/release.yaml
# For cache to work in tags, you need to create it first in main
# The recommended way to do this is to dispatch a job manually, then the subsequent tag releases can use that cache
name: release

on:
push:
tags:
- "*[0-9]+.[0-9]+"
tags: [ "*[0-9]+.[0-9]+" ]
workflow_dispatch:
inputs:
version:
Expand Down Expand Up @@ -37,7 +38,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install nix
uses: nixbuild/nix-quick-install-action@v28
Expand All @@ -48,17 +49,16 @@ jobs:
arguments: ".#web"

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
shared-key: "web-release"
uses: swatinem/rust-cache@v2

- name: Build
run: |
cargo build --release --example ${{ matrix.name }} --no-default-features --features ${{ matrix.features }} --target wasm32-unknown-unknown
cargo build --release --target wasm32-unknown-unknown --no-default-features --features ${{ env.features }}
- name: Prepare package
run: |
wasm-bindgen --no-typescript --out-name ${{ env.binary }} --out-dir wasm --target web target/wasm32-unknown-unknown/release/${{ env.binary }}.wasm
sed -i "s/hello-bevy/${{ env.binary }}/g" wasm/index.html
- name: Optimize Wasm
if: ${{ env.optimize == 'true' }}
Expand All @@ -67,18 +67,17 @@ jobs:
mv ${{ env.binary }}_bg.wasm base.wasm
wasm-opt base.wasm -o ${{ env.binary }}_bg.wasm -Os
- name: Package as a zip
working-directory: ./wasm
run: |
sed -i "s/hello-bevy/${{ env.binary }}/g" index.html
zip --recurse-paths ../${{ matrix.name }}.zip .
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ env.binary }}.zip
path: wasm/*
name: wasm

- name: Package as a zip
working-directory: ./wasm
run: |
zip --recurse-paths ../${{ env.binary }}.zip .
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
Expand All @@ -97,7 +96,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install nix
uses: nixbuild/nix-quick-install-action@v28
Expand All @@ -107,8 +106,6 @@ jobs:

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
shared-key: "linux-release"

- name: Build
run: |
Expand All @@ -120,17 +117,17 @@ jobs:
cp target/x86_64-unknown-linux-gnu/release/${{ env.binary }} linux/
strip linux/${{ env.binary }}
- name: Package as a zip
working-directory: ./linux
run: |
zip --recurse-paths ../${{ env.binary }}.zip .
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ env.binary }}.zip
path: linux/*
name: linux

- name: Package as a zip
working-directory: ./linux
run: |
zip --recurse-paths ../${{ env.binary }}.zip .
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
Expand All @@ -149,7 +146,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Remove debug config (windows)
run: Remove-Item -Path .cargo/config.toml
Expand All @@ -170,16 +167,16 @@ jobs:
mkdir windows
cp target/x86_64-pc-windows-msvc/release/${{ env.binary }}.exe windows/
- name: Package as a zip
run: |
Compress-Archive -Path windows/* -DestinationPath ${{ env.binary }}.zip
- name: Upload binaries to artifacts
uses: actions/upload-artifact@v4
with:
path: ${{ env.binary }}.zip
path: windows/*
name: windows

- name: Package as a zip
run: |
Compress-Archive -Path windows/* -DestinationPath ${{ env.binary }}.zip
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
Expand All @@ -199,7 +196,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Remove debug config
run: rm -f .cargo/config.toml
Expand All @@ -211,8 +208,6 @@ jobs:

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
key: "arm"

- name: Build release for Apple Silicon
run: |
Expand All @@ -223,19 +218,14 @@ jobs:
with:
targets: x86_64-apple-darwin

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
key: "x86"

- name: Build release for x86 Apple
run: |
SDKROOT=$(xcrun -sdk macosx --show-sdk-path) cargo build --release --target=x86_64-apple-darwin --no-default-features --features ${{ env.features }}
- name: Create Universal Binary
run: |
lipo -create -output target/release/${{ env.binary }} target/aarch64-apple-darwin/release/${{ env.binary }} target/x86_64-apple-darwin/release/${{ env.binary }}
- name: Prepare package
run: |
mkdir -p ${{ env.binary }}.app/Contents/MacOS
Expand Down Expand Up @@ -277,16 +267,16 @@ jobs:
- check-upload-to-itch
- release-wasm
- release-linux
# - release-windows # [CHANGE]: Uncomment this if you want to automaticall deploy mac and windows builds to itch
# - release-macos # It is disabled by default because they take a loong time
- release-windows
- release-macos
if: ${{ needs.check-upload-to-itch.outputs.should-upload == 'yes' }}

env:
version: ${{needs.get-version.outputs.version}}

steps:
- name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: ./builds

Expand All @@ -307,6 +297,6 @@ jobs:
./butler push \
--fix-permissions \
--userversion="${{ env.version }}" \
builds/$channel/* \
builds/$channel \
${{ env.itch_target }}:$channel
done
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ to run a release build locally:
cargo run --release --no-default-features --features release
```

on nixos, you might have trouble if you are downloading the linux precompiled binary from releases. this is because nixos does not follow fhs and it doesn't have a global library path. a workarround for running games there is to use this command:

```sh
NIXPKGS_ALLOW_UNFREE=1 nix-shell -p steam-run --run "steam-run GAME_PATH"
```
if the `tts` feature is enabled, you may need to install [speech dispatcher](https://wiki.archlinux.org/title/Speech_dispatcher) on linux.

### profiling 📈

Expand Down

0 comments on commit aa67edd

Please sign in to comment.