Skip to content

Commit 606610e

Browse files
committed
wip cross build
1 parent 2969db7 commit 606610e

File tree

3 files changed

+76
-95
lines changed

3 files changed

+76
-95
lines changed

.github/workflows/build-and-test.yml

+4-24
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,26 @@
1-
name: Build & Test
1+
name: Test
22

33
on:
44
workflow_call:
55
inputs:
66
os:
77
required: true
88
type: string
9-
upload-artifact-name:
10-
required: true
11-
type: string
12-
upload-artifact-path:
13-
required: true
14-
type: string
159
additional-setup:
1610
required: false
1711
type: string
1812

1913
jobs:
2014
run:
2115
runs-on: ${{ inputs.os }}
16+
2217
steps:
2318
- name: Checkout Code
2419
uses: actions/checkout@v4
2520

26-
- name: Rust toolchain
27-
uses: dtolnay/rust-toolchain@stable
28-
29-
- name: Rust cache
30-
uses: Swatinem/rust-cache@v2
31-
3221
- name: Additional Setup (if specified)
3322
if: ${{ inputs.additional-setup != '' }}
3423
run: ${{ inputs.additional-setup }}
3524

36-
- name: Run Tests
37-
run: cargo test --release
38-
39-
- name: Build
40-
run: cargo build --release
41-
42-
- name: Upload Build Artifacts
43-
uses: actions/upload-artifact@v4
44-
with:
45-
name: ${{ inputs.upload-artifact-name }}
46-
path: ${{ inputs.upload-artifact-path }}
25+
- name: Run Tests (Native Only)
26+
run: cargo test

.github/workflows/rust.yml

+64-65
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,37 @@ jobs:
3030
components: clippy
3131
- run: cargo clippy -- -D warnings
3232

33-
linux-build-test:
34-
name: Build and Test (Linux)
33+
linux-test:
34+
name: Test (Linux)
3535
uses: ./.github/workflows/build-and-test.yml
3636
with:
3737
os: ubuntu-latest
38-
upload-artifact-name: notedeck-linux-bin
39-
upload-artifact-path: target/release/notedeck
4038
additional-setup: |
4139
sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libspeechd-dev libxkbcommon-dev libssl-dev
4240
43-
macos-build-test:
44-
name: Build and Test (macOS)
41+
macos-test:
42+
name: Test (macOS)
4543
uses: ./.github/workflows/build-and-test.yml
4644
with:
4745
os: macos-latest
48-
upload-artifact-name: notedeck-macos-bin
49-
upload-artifact-path: target/release/notedeck
5046

51-
windows-build-test:
52-
name: Build and Test (Windows)
47+
windows-test:
48+
name: Test (Windows)
5349
uses: ./.github/workflows/build-and-test.yml
5450
with:
5551
os: windows-latest
56-
upload-artifact-name: notedeck.exe
57-
upload-artifact-path: target/release/notedeck.exe
5852

5953
packaging:
60-
name: Build Linux Packages
54+
name: rpm/deb
6155
runs-on: ubuntu-latest
62-
needs: linux-build-test
63-
if: github.ref_name == 'master'
56+
needs: linux-test
57+
#if: github.ref_name == 'master'
58+
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
arch: [x86_64, aarch64]
63+
6464
steps:
6565
# Checkout the repository
6666
- name: Checkout Code
@@ -70,69 +70,80 @@ jobs:
7070
- name: Install Packaging Tools
7171
run: |
7272
sudo apt-get update
73-
sudo apt-get install -y rpm binutils
73+
if [ "${{ matrix.arch }}" = "aarch64" ]; then
74+
sudo apt-get install -y gcc-x86-64-linux-gnu
75+
fi
7476
cargo install cargo-generate-rpm cargo-deb
77+
rustup target add ${{ matrix.arch }}-unknown-linux-gnu
7578
76-
# download!
77-
- name: Download Build Artifacts
78-
uses: actions/download-artifact@v4
79-
with:
80-
name: notedeck-linux-bin
81-
path: target/release
82-
83-
# Build Packages
84-
- name: Build Packages
79+
# Build
80+
- name: Build (${{ matrix.arch }})
8581
run: |
86-
cargo generate-rpm
87-
cargo deb
82+
echo "arch: $(uname -m)"
83+
if [ "${{ matrix.arch }}" != "$(uname -m)" ]; then
84+
cargo build --release --target=${{ matrix.arch }}-unknown-linux-gnu
85+
else
86+
cargo build --release
87+
fi
88+
89+
# Build RPM Package
90+
- name: Build RPM Package
91+
run: |
92+
if [ "${{ matrix.arch }}" != "$(uname -m)" ]; then
93+
cargo generate-rpm --target=${{ matrix.arch }}-unknown-linux-gnu
94+
else
95+
cargo generate-rpm
96+
fi
97+
98+
# Build Debian Package
99+
- name: Build Debian Package
100+
run: |
101+
if [ "${{ matrix.arch }}" != "$(uname -m)" ]; then
102+
cargo deb --target=${{ matrix.arch }}-unknown-linux-gnu
103+
else
104+
cargo deb
105+
fi
88106
89107
# Upload RPM Package
90108
- name: Upload RPM Package
91109
uses: actions/upload-artifact@v4
92110
with:
93-
name: notedeck.rpm
94-
path: target/generate-rpm/*.rpm
111+
name: ${{ inputs.artifact-name }}-${{ matrix.arch }}.rpm
112+
path: target/${{ matrix.arch }}-unknown-linux-gnu/generate-rpm/*.rpm
95113

96114
# Upload Debian Package
97115
- name: Upload Debian Package
98116
uses: actions/upload-artifact@v4
99117
with:
100-
name: notedeck.deb
101-
path: target/debian/*.deb
118+
name: ${{ inputs.artifact-name }}-${{ inputs.arch }}.deb
119+
path: target/${{ matrix.arch }}-unknown-linux-gnu/debian/*.deb
102120

103121
macos-dmg:
104-
name: Build macOS DMG
122+
name: macOS dmg
105123
runs-on: macos-latest
106-
needs: macos-build-test
107-
if: github.ref_name == 'master'
124+
needs: macos-test
125+
#if: github.ref_name == 'master'
108126
env:
109127
NOTEDECK_APPLE_RELEASE_CERT_ID: ${{ secrets.NOTEDECK_APPLE_RELEASE_CERT_ID }}
110128
NOTEDECK_RELEASE_APPLE_ID: ${{ secrets.NOTEDECK_RELEASE_APPLE_ID }}
111129
NOTEDECK_APPLE_APP_SPECIFIC_PW: ${{ secrets.NOTEDECK_APPLE_APP_SPECIFIC_PW }}
112130
NOTEDECK_APPLE_TEAM_ID: ${{ secrets.NOTEDECK_APPLE_TEAM_ID }}
131+
132+
strategy:
133+
fail-fast: false
134+
matrix:
135+
arch: [x86_64, aarch64]
136+
113137
steps:
114138
# Checkout the repository
115139
- name: Checkout Code
116140
uses: actions/checkout@v4
117141

118-
# Set up Rust
119-
- name: Setup Rust
120-
uses: dtolnay/rust-toolchain@stable
121-
122-
# create-dmg and cargo-bundle caching
123-
- name: Rust cache
124-
uses: Swatinem/rust-cache@v2
125-
126-
- name: Download Build Artifacts (MacOS)
127-
uses: actions/download-artifact@v4
128-
with:
129-
name: notedeck-macos-bin # Assuming you need the Release build
130-
path: target/release
131-
132142
- name: Install Required Tools
133143
run: |
134144
brew install create-dmg
135145
cargo install cargo-bundle
146+
rustup target add ${{ matrix.arch }}-apple-darwin
136147
137148
- name: Import apple codesign cert
138149
uses: apple-actions/import-codesign-certs@v3
@@ -141,30 +152,24 @@ jobs:
141152
p12-password: ${{ secrets.CERTIFICATES_P12_PASSWORD }}
142153

143154
- name: Run macOS DMG Build Script
144-
run: ./scripts/macos_build.sh
155+
run: ARCH=${{ matrix.arch }} ./scripts/macos_build.sh
145156

146157
- name: Upload DMG Artifact
147158
uses: actions/upload-artifact@v4
148159
with:
149-
name: notedeck.dmg
150-
path: packages/notedeck.dmg
160+
name: notedeck-${{ matrix.arch }}.dmg
161+
path: packages/notedeck-${{ matrix.arch }}.dmg
151162

152163
windows-installer:
153164
name: Build Windows Installer
154165
runs-on: windows-latest
155-
needs: windows-build-test
166+
needs: windows-test
156167
if: github.ref_name == 'master'
157168
steps:
158169
# Checkout the repository
159170
- name: Checkout Code
160171
uses: actions/checkout@v4
161172

162-
- name: Download Build Artifacts
163-
uses: actions/download-artifact@v4
164-
with:
165-
name: notedeck.exe # Assuming you need the Release build
166-
path: target/release
167-
168173
# Create packages directory
169174
- name: Create packages directory
170175
run: mkdir packages
@@ -173,13 +178,6 @@ jobs:
173178
- name: Install Inno Setup
174179
run: choco install innosetup --no-progress --yes
175180

176-
# Validate executable exists
177-
- name: Validate required files
178-
run: |
179-
if (!(Test-Path -Path target\release\notedeck.exe)) {
180-
throw "Executable 'notedeck.exe' not found in 'target/release'."
181-
}
182-
183181
# Build Installer
184182
- name: Run Inno Setup Script
185183
run: |
@@ -195,3 +193,4 @@ jobs:
195193
with:
196194
name: DamusNotedeckInstaller.exe
197195
path: packages\DamusNotedeckInstaller.exe
196+

scripts/macos_build.sh

+8-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ set -o pipefail # Catch errors in pipelines
66

77
# Ensure the script is running in the correct directory
88
REQUIRED_DIR="notedeck"
9+
ARCH=${ARCH:-"aarch64"}
10+
TARGET=${TARGET:-${ARCH}-apple-darwin}
911
CURRENT_DIR=$(basename "$PWD")
1012

1113
if [ "$CURRENT_DIR" != "$REQUIRED_DIR" ]; then
@@ -40,7 +42,7 @@ fi
4042

4143
# Build the .app bundle
4244
echo "Building .app bundle..."
43-
cargo bundle --release
45+
cargo bundle --release --target $TARGET
4446

4547
# Sign the app
4648
echo "Codesigning the app..."
@@ -51,11 +53,11 @@ codesign \
5153
--options runtime \
5254
--entitlements entitlements.plist \
5355
--sign "$NOTEDECK_APPLE_RELEASE_CERT_ID" \
54-
target/release/bundle/osx/notedeck.app
56+
target/${TARGET}/release/bundle/osx/notedeck.app
5557

5658
# Create a zip for notarization
5759
echo "Creating zip for notarization..."
58-
zip -r notedeck.zip target/release/bundle/osx/notedeck.app
60+
zip -r notedeck.zip target/${TARGET}/release/bundle/osx/notedeck.app
5961

6062
# Submit for notarization
6163
echo "Submitting for notarization..."
@@ -68,7 +70,7 @@ xcrun notarytool submit \
6870

6971
# Staple the notarization
7072
echo "Stapling notarization to the app..."
71-
xcrun stapler staple target/release/bundle/osx/notedeck.app
73+
xcrun stapler staple target/${TARGET}/release/bundle/osx/notedeck.app
7274

7375
echo "Removing notedeck.zip"
7476
rm notedeck.zip
@@ -79,7 +81,7 @@ mkdir -p packages
7981
create-dmg \
8082
--window-size 600 400 \
8183
--app-drop-link 400 100 \
82-
packages/notedeck.dmg \
83-
target/release/bundle/osx/notedeck.app
84+
packages/notedeck-${ARCH}.dmg \
85+
target/${TARGET}/release/bundle/osx/notedeck.app
8486

8587
echo "Build and signing process completed successfully."

0 commit comments

Comments
 (0)