Skip to content

Commit 1dbad99

Browse files
Merge pull request #293 from RainbowCookie32/dev
Actions: Add macOS universal binaries, auto-generate releases when merging to master
2 parents 3ede13b + 50c9a07 commit 1dbad99

File tree

6 files changed

+490
-160
lines changed

6 files changed

+490
-160
lines changed

.github/workflows/main.yml

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,71 @@ jobs:
1616
- uses: actions/checkout@v4
1717

1818
- name: Rust Cache
19-
uses: Swatinem/rust-cache@v2.7.3
19+
uses: Swatinem/rust-cache@v2
2020
with:
2121
key: ${{ matrix.feature }}-${{ matrix.os }}
2222
cache-on-failure: "true"
2323

24+
- name: Get Cargo.toml version
25+
id: cargo_version
26+
uses: dante-signal31/rust-app-version@v1.2.0
27+
if: ${{ matrix.os != 'windows-latest' }}
28+
2429
- name: Install dependencies
2530
if: ${{ matrix.os == 'ubuntu-latest' && matrix.feature == 'egui' }}
2631
run: |
2732
sudo apt update
2833
sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev libgtk-3-dev
34+
35+
- name: Add x86 target (macOS)
36+
if: ${{ matrix.os == 'macos-latest' }}
37+
run: rustup target add x86_64-apple-darwin
2938

30-
- name: Build rusty-psn
39+
- name: Build rusty-psn (Linux/Windows)
40+
if: ${{ matrix.os != 'macos-latest' }}
3141
run: cargo build --release --no-default-features --features ${{ matrix.feature }}
3242

43+
- name: Build rusty-psn (macOS)
44+
if: ${{ matrix.os == 'macos-latest' }}
45+
run: |
46+
cargo build --release --no-default-features --features ${{ matrix.feature }}
47+
cargo build --release --no-default-features --features ${{ matrix.feature }} --target x86_64-apple-darwin
48+
49+
- name: Make universal binary (macOS)
50+
if: ${{ matrix.os == 'macos-latest' }}
51+
run: |
52+
mkdir target/release/universal
53+
lipo -create -output target/release/universal/rusty-psn target/release/rusty-psn target/x86_64-apple-darwin/release/rusty-psn
54+
55+
- name: Make app bundle (macOS - egui)
56+
if: ${{ matrix.os == 'macos-latest' && matrix.feature == 'egui' }}
57+
run: |
58+
mkdir rusty-psn.app
59+
mkdir rusty-psn.app/Contents
60+
mkdir rusty-psn.app/Contents/MacOS
61+
62+
cp resources/Info.plist rusty-psn.app/Contents
63+
sed -i '' -e 's/%RPSN_VERSION%/${{ steps.cargo_version.outputs.app_version }}/g' rusty-psn.app/Contents/Info.plist
64+
65+
cp target/release/universal/rusty-psn rusty-psn.app/Contents/MacOS
66+
3367
- name: Move binary (Linux)
3468
if: ${{ matrix.os == 'ubuntu-latest' }}
3569
run: |
3670
mkdir result
3771
cp target/release/rusty-psn result
3872
39-
- name: Move binary (MacOS)
40-
if: ${{ matrix.os == 'macos-latest' }}
73+
- name: Move binary (MacOS - cli)
74+
if: ${{ matrix.os == 'macos-latest' && matrix.feature == 'cli' }}
4175
run: |
4276
mkdir result
43-
cp target/release/rusty-psn result
77+
cp target/release/universal/rusty-psn result
78+
79+
- name: Move binary (MacOS - egui)
80+
if: ${{ matrix.os == 'macos-latest' && matrix.feature == 'egui' }}
81+
run: |
82+
mkdir result
83+
cp -R rusty-psn.app result
4484
4585
- name: Move binary (Windows)
4686
if: ${{ matrix.os == 'windows-latest' }}
@@ -59,7 +99,7 @@ jobs:
5999
if: ${{ matrix.os == 'macos-latest' }}
60100
uses: actions/upload-artifact@v4
61101
with:
62-
name: rusty-psn-${{ matrix.feature }}-macos
102+
name: rusty-psn-${{ matrix.feature }}-macos-universal
63103
path: result
64104

65105
- name: Upload artifact (Windows)
@@ -69,3 +109,31 @@ jobs:
69109
name: rusty-psn-${{ matrix.feature }}-windows
70110
path: result
71111

112+
create_release:
113+
needs: build_matrix
114+
runs-on: ubuntu-latest
115+
if: github.ref == 'refs/heads/master'
116+
permissions:
117+
contents: write
118+
119+
steps:
120+
- name: Get Cargo.toml version
121+
id: cargo_version
122+
uses: dante-signal31/rust-app-version@v1.2.0
123+
124+
- name: Download artifacts
125+
uses: actions/download-artifact@v4.1.9
126+
with:
127+
path: ./artifacts
128+
patters: rusty-psn*
129+
130+
- name: Create release
131+
uses: softprops/action-gh-release@v2.2.1
132+
with:
133+
name: "v${{ steps.cargo_version.outputs.app_version }}"
134+
tag_name: "v${{ steps.cargo_version.outputs.app_version }}"
135+
files: "./artifacts/*"
136+
generate_release_notes: true
137+
make_latest: true
138+
139+

0 commit comments

Comments
 (0)