Skip to content

Commit e81f0b7

Browse files
ci(release): add tagged binary publishing
1 parent d8834a2 commit e81f0b7

3 files changed

Lines changed: 141 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
build:
16+
name: Build ${{ matrix.target }}
17+
runs-on: ${{ matrix.runner }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- runner: ubuntu-24.04
23+
target: x86_64-unknown-linux-gnu
24+
binary_name: pacman
25+
asset_ext: tar.gz
26+
- runner: ubuntu-24.04-arm
27+
target: aarch64-unknown-linux-gnu
28+
binary_name: pacman
29+
asset_ext: tar.gz
30+
- runner: windows-2025
31+
target: x86_64-pc-windows-msvc
32+
binary_name: pacman.exe
33+
asset_ext: exe
34+
- runner: macos-15
35+
target: aarch64-apple-darwin
36+
binary_name: pacman
37+
asset_ext: tar.gz
38+
39+
steps:
40+
- name: Check out repository
41+
uses: actions/checkout@v6
42+
with:
43+
fetch-depth: 0
44+
45+
- name: Install Linux build dependencies
46+
if: runner.os == 'Linux'
47+
run: sudo apt-get update && sudo apt-get install -y libasound2-dev
48+
49+
- name: Set up Rust
50+
uses: dtolnay/rust-toolchain@stable
51+
52+
- name: Add target
53+
run: rustup target add ${{ matrix.target }}
54+
55+
- name: Build release binary
56+
run: cargo build --locked --release --bin pacman --target ${{ matrix.target }}
57+
58+
- name: Compute asset name
59+
id: asset
60+
shell: bash
61+
run: echo "name=pacman-${GITHUB_REF_NAME}-${{ matrix.target }}.${{ matrix.asset_ext }}" >> "$GITHUB_OUTPUT"
62+
63+
- name: Package Unix archive
64+
if: runner.os != 'Windows'
65+
shell: bash
66+
run: |
67+
set -euo pipefail
68+
mkdir -p dist
69+
tar -C "target/${{ matrix.target }}/release" -czf "dist/${{ steps.asset.outputs.name }}" "${{ matrix.binary_name }}"
70+
71+
- name: Package Windows archive
72+
if: runner.os == 'Windows'
73+
shell: pwsh
74+
run: |
75+
New-Item -ItemType Directory -Force -Path dist | Out-Null
76+
Copy-Item "target\${{ matrix.target }}\release\${{ matrix.binary_name }}" "dist\${{ steps.asset.outputs.name }}"
77+
78+
- name: Upload packaged binary
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: ${{ steps.asset.outputs.name }}
82+
path: dist/${{ steps.asset.outputs.name }}
83+
if-no-files-found: error
84+
85+
release:
86+
name: Publish GitHub Release
87+
runs-on: ubuntu-24.04
88+
needs: build
89+
permissions:
90+
actions: read
91+
contents: write
92+
env:
93+
GH_REPO: ${{ github.repository }}
94+
GH_TOKEN: ${{ github.token }}
95+
steps:
96+
- name: Download packaged binaries
97+
uses: actions/download-artifact@v5
98+
with:
99+
path: dist
100+
101+
- name: Create or update release
102+
shell: bash
103+
run: |
104+
set -euo pipefail
105+
tag="${GITHUB_REF_NAME}"
106+
mapfile -t assets < <(find dist -type f | sort)
107+
108+
if [ "${#assets[@]}" -eq 0 ]; then
109+
echo "No release assets were downloaded" >&2
110+
exit 1
111+
fi
112+
113+
checksum_file="dist/pacman-${tag}-SHA256SUMS.txt"
114+
: > "$checksum_file"
115+
for asset in "${assets[@]}"; do
116+
printf "%s %s\n" "$(sha256sum "$asset" | cut -d' ' -f1)" "$(basename "$asset")" >> "$checksum_file"
117+
done
118+
assets+=("$checksum_file")
119+
120+
if gh release view "$tag" >/dev/null 2>&1; then
121+
gh release upload "$tag" "${assets[@]}" --clobber
122+
else
123+
gh release create "$tag" "${assets[@]}" --verify-tag --generate-notes
124+
fi

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ After installation, run the game with:
5555

5656
- `pacman`
5757

58+
Version tags such as `v1.0.0` also publish prebuilt GitHub Release binaries for:
59+
60+
- Linux `x86_64`
61+
- Linux `arm64`
62+
- Windows `x86_64`
63+
- macOS `arm64`
64+
- A `pacman-<tag>-SHA256SUMS.txt` manifest for the released assets
65+
5866
Notes:
5967

6068
- Run it inside `kitty`, `ghostty`, `warp`, or another terminal that supports

src/audio.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ impl Default for AudioManager {
4141
impl SoundAsset {
4242
const fn bytes(self) -> &'static [u8] {
4343
match self {
44-
Self::ButtonClick => include_bytes!("../assets/Sounds/button_click.ogg"),
45-
Self::Death => include_bytes!("../assets/Sounds/death.wav"),
46-
Self::FreightMode => include_bytes!("../assets/Sounds/fright_mode_short.wav"),
47-
Self::FruitEat => include_bytes!("../assets/Sounds/fruit_eat.wav"),
48-
Self::GhostEat => include_bytes!("../assets/Sounds/ghost_eat.wav"),
49-
Self::LevelComplete => include_bytes!("../assets/Sounds/level_complete.wav"),
50-
Self::LevelStart => include_bytes!("../assets/Sounds/level_start.wav"),
51-
Self::Music => include_bytes!("../assets/Sounds/music.ogg"),
52-
Self::SmallPellet => include_bytes!("../assets/Sounds/small_pellet2.wav"),
44+
Self::ButtonClick => include_bytes!("../assets/sounds/button_click.ogg"),
45+
Self::Death => include_bytes!("../assets/sounds/death.wav"),
46+
Self::FreightMode => include_bytes!("../assets/sounds/fright_mode_short.wav"),
47+
Self::FruitEat => include_bytes!("../assets/sounds/fruit_eat.wav"),
48+
Self::GhostEat => include_bytes!("../assets/sounds/ghost_eat.wav"),
49+
Self::LevelComplete => include_bytes!("../assets/sounds/level_complete.wav"),
50+
Self::LevelStart => include_bytes!("../assets/sounds/level_start.wav"),
51+
Self::Music => include_bytes!("../assets/sounds/music.ogg"),
52+
Self::SmallPellet => include_bytes!("../assets/sounds/small_pellet2.wav"),
5353
}
5454
}
5555
}

0 commit comments

Comments
 (0)