Skip to content

Commit 302b16e

Browse files
authored
Merge pull request #2 from thecatcore/feature/cross-build
Publish artifacts for Windows x86 and Arm64, MacOs x64 and universal2, Linux aarch64
2 parents 535ab6f + 7f0cd06 commit 302b16e

File tree

4 files changed

+219
-26
lines changed

4 files changed

+219
-26
lines changed

.github/workflows/build.yml

Lines changed: 78 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,32 @@ jobs:
1414
build:
1515
strategy:
1616
matrix:
17-
build: [linux, windows, mac]
17+
build: [linux-x86_64, windows-x86, windows-x86_64, windows-aarch64]
1818
include:
19-
- build: linux
19+
- build: linux-x86_64
2020
os: ubuntu-latest
21-
rust: "stable"
22-
- build: windows
21+
target: x86_64-unknown-linux-gnu
22+
- build: windows-x86
2323
os: windows-latest
24-
rust: "stable"
25-
- build: mac
26-
os: macos-latest
27-
rust: "stable"
24+
target: i686-pc-windows-msvc
25+
msvc_arch: amd64_x86
26+
- build: windows-x86_64
27+
os: windows-latest
28+
target: x86_64-pc-windows-msvc
29+
msvc_arch: amd64
30+
- build: windows-aarch64
31+
os: windows-latest
32+
target: aarch64-pc-windows-msvc
33+
msvc_arch: amd64_arm64
2834
runs-on: ${{ matrix.os }}
2935

3036
steps:
3137
- uses: actions/checkout@v4
38+
- name: Install C toolchain (Windows)
39+
if: runner.os == 'Windows'
40+
uses: ilammy/msvc-dev-cmd@v1
41+
with:
42+
arch: ${{ matrix.msvc_arch }}
3243
- name: Install packages (Linux)
3344
if: runner.os == 'Linux'
3445
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
@@ -39,12 +50,13 @@ jobs:
3950
- name: Install Rust
4051
uses: dtolnay/rust-toolchain@stable
4152
with:
42-
toolchain: ${{ matrix.rust }}
53+
toolchain: stable
4354
- uses: Swatinem/rust-cache@v2
55+
- run: rustup target add ${{ matrix.target }}
4456
- name: Build
45-
run: cargo build --verbose
57+
run: cargo build --verbose --target ${{ matrix.target }}
4658
- name: Build release binary
47-
run: cargo build --release
59+
run: cargo build --release --target ${{ matrix.target }}
4860
- name: Upload a Build Artifact
4961
uses: actions/upload-artifact@v4
5062
with:
@@ -53,3 +65,58 @@ jobs:
5365
target/**/ornithe-installer-rs*
5466
!target/**/ornithe-installer-rs.d
5567
!target/**/build/
68+
build_macos:
69+
runs-on: ubuntu-latest
70+
container: ghcr.io/rust-cross/cargo-zigbuild:0.20
71+
steps:
72+
- uses: actions/checkout@v4
73+
- name: Install Rust
74+
uses: dtolnay/rust-toolchain@stable
75+
with:
76+
toolchain: stable
77+
- uses: Swatinem/rust-cache@v2
78+
- run: rustup target add aarch64-apple-darwin
79+
- run: rustup target add x86_64-apple-darwin
80+
- name: Build
81+
run: cargo zigbuild --verbose --target universal2-apple-darwin
82+
- name: Build release binary
83+
run: cargo zigbuild --release --target universal2-apple-darwin
84+
- name: Upload a Build Artifact
85+
uses: actions/upload-artifact@v4
86+
with:
87+
name: CI builds (macos)
88+
path: |
89+
target/**/ornithe-installer-rs*
90+
!target/**/ornithe-installer-rs.d
91+
!target/**/build/
92+
build_linux_cross:
93+
strategy:
94+
matrix:
95+
build: [linux-aarch64]
96+
include:
97+
- build: linux-aarch64
98+
target: aarch64-unknown-linux-gnu
99+
runs-on: ubuntu-latest
100+
steps:
101+
- uses: actions/checkout@v4
102+
- name: Install Rust
103+
uses: dtolnay/rust-toolchain@stable
104+
with:
105+
toolchain: stable
106+
- uses: Swatinem/rust-cache@v2
107+
with:
108+
key: linux-cross
109+
- run: cargo install cross --git https://github.com/cross-rs/cross
110+
- run: rustup target add ${{ matrix.target }}
111+
- name: Build
112+
run: cross build --verbose --target ${{ matrix.target }}
113+
- name: Build release binary
114+
run: cross build --release --target ${{ matrix.target }}
115+
- name: Upload a Build Artifact
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: CI builds (${{ matrix.build }})
119+
path: |
120+
target/**/ornithe-installer-rs*
121+
!target/**/ornithe-installer-rs.d
122+
!target/**/build/

.github/workflows/publish.yml

Lines changed: 131 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,31 @@ jobs:
1313
publish:
1414
strategy:
1515
matrix:
16+
build: [linux-x86_64, windows-x86, windows-x86_64, windows-aarch64]
1617
include:
17-
- build: linux-x86
18+
- build: linux-x86_64
1819
os: ubuntu-latest
1920
target: x86_64-unknown-linux-gnu
2021
- build: windows-x86
22+
os: windows-latest
23+
target: i686-pc-windows-msvc
24+
msvc_arch: amd64_x86
25+
- build: windows-x86_64
2126
os: windows-latest
2227
target: x86_64-pc-windows-msvc
23-
#- build: windows-i686
24-
# os: windows-latest
25-
# target: i686-pc-windows-msvc
26-
#- build: windows-aarch64
27-
# os: windows-latest
28-
# target: aarch64-pc-windows-msvc
29-
#- build: macos-x86
30-
# os: macos-latest
31-
# target: x86_64-apple-darwin
32-
- build: macos-aarch64
33-
os: macos-latest
34-
target: aarch64-apple-darwin
28+
msvc_arch: amd64
29+
- build: windows-aarch64
30+
os: windows-latest
31+
target: aarch64-pc-windows-msvc
32+
msvc_arch: amd64_arm64
3533
runs-on: ${{ matrix.os }}
3634
steps:
3735
- uses: actions/checkout@v4
36+
- name: Install C toolchain (Windows)
37+
if: runner.os == 'Windows'
38+
uses: ilammy/msvc-dev-cmd@v1
39+
with:
40+
arch: ${{ matrix.msvc_arch }}
3841
- name: Install packages (Linux)
3942
if: runner.os == 'Linux'
4043
uses: awalsh128/cache-apt-pkgs-action@v1.4.3
@@ -53,6 +56,8 @@ jobs:
5356
with:
5457
toolchain: stable
5558
- uses: Swatinem/rust-cache@v2
59+
with:
60+
key: ${{ matrix.build }}
5661
- run: rustup target add ${{ matrix.target }}
5762
# Build the CLI only binary
5863
- run: cargo build --no-default-features --release --target ${{ matrix.target }}
@@ -76,12 +81,124 @@ jobs:
7681
MAVEN_URL: ${{ secrets.NEW_MAVEN_URL }}
7782
MAVEN_USERNAME: ${{ secrets.NEW_MAVEN_USERNAME }}
7883
MAVEN_PASSWORD: ${{ secrets.NEW_MAVEN_PASSWORD }}
84+
SNAPSHOTS_URL: ${{ secrets.NEW_MAVEN_SNAPSHOT_URL }}
85+
SNAPSHOTS_USERNAME: ${{ secrets.NEW_MAVEN_SNAPSHOT_USERNAME }}
86+
SNAPSHOTS_PASSWORD: ${{ secrets.NEW_MAVEN_SNAPSHOT_PASSWORD }}
7987
TARGET: ${{ matrix.target }}
8088
OS: ${{ matrix.build }}
89+
publish_macos:
90+
runs-on: ubuntu-latest
91+
container: ghcr.io/rust-cross/cargo-zigbuild:0.20
92+
steps:
93+
- uses: actions/checkout@v4
94+
- uses: actions/setup-java@v4
95+
with:
96+
distribution: "microsoft"
97+
java-version: "21"
98+
cache: "gradle"
99+
- uses: gradle/actions/wrapper-validation@v3
100+
- name: Install Rust
101+
uses: dtolnay/rust-toolchain@stable
102+
with:
103+
toolchain: stable
104+
- uses: Swatinem/rust-cache@v2
105+
- run: rustup target add aarch64-apple-darwin
106+
- run: rustup target add x86_64-apple-darwin
107+
# Build the CLI only binary
108+
- run: cargo zigbuild --no-default-features --release --target universal2-apple-darwin
109+
- name: Rename CLI Binaries
110+
run: |
111+
mv "target/aarch64-apple-darwin/release/ornithe-installer-rs" "target/aarch64-apple-darwin/release/ornithe-installer-rs-cli.bin"
112+
mv "target/x86_64-apple-darwin/release/ornithe-installer-rs" "target/x86_64-apple-darwin/release/ornithe-installer-rs-cli.bin"
113+
mv "target/universal2-apple-darwin/release/ornithe-installer-rs" "target/universal2-apple-darwin/release/ornithe-installer-rs-cli.bin"
114+
# Regular build with GUI
115+
- run: cargo zigbuild --release --target universal2-apple-darwin
116+
- name: Rename Binaries
117+
run: |
118+
mv "target/aarch64-apple-darwin/release/ornithe-installer-rs" "target/aarch64-apple-darwin/release/ornithe-installer-rs.bin"
119+
mv "target/x86_64-apple-darwin/release/ornithe-installer-rs" "target/x86_64-apple-darwin/release/ornithe-installer-rs.bin"
120+
mv "target/universal2-apple-darwin/release/ornithe-installer-rs" "target/universal2-apple-darwin/release/ornithe-installer-rs.bin"
121+
- uses: actions/upload-artifact@v4
122+
with:
123+
name: Artifacts macos
124+
path: |
125+
target/**/release/ornithe-installer-rs*
126+
!target/**/ornithe-installer-rs.d
127+
!target/**/build/
128+
- run: ./gradlew publish --stacktrace
129+
env:
130+
MAVEN_URL: ${{ secrets.NEW_MAVEN_URL }}
131+
MAVEN_USERNAME: ${{ secrets.NEW_MAVEN_USERNAME }}
132+
MAVEN_PASSWORD: ${{ secrets.NEW_MAVEN_PASSWORD }}
133+
SNAPSHOTS_URL: ${{ secrets.NEW_MAVEN_SNAPSHOT_URL }}
134+
SNAPSHOTS_USERNAME: ${{ secrets.NEW_MAVEN_SNAPSHOT_USERNAME }}
135+
SNAPSHOTS_PASSWORD: ${{ secrets.NEW_MAVEN_SNAPSHOT_PASSWORD }}
136+
TARGET: aarch64-apple-darwin
137+
OS: macos-aarch64
138+
- run: ./gradlew publish --stacktrace
139+
env:
140+
MAVEN_URL: ${{ secrets.NEW_MAVEN_URL }}
141+
MAVEN_USERNAME: ${{ secrets.NEW_MAVEN_USERNAME }}
142+
MAVEN_PASSWORD: ${{ secrets.NEW_MAVEN_PASSWORD }}
143+
SNAPSHOTS_URL: ${{ secrets.NEW_MAVEN_SNAPSHOT_URL }}
144+
SNAPSHOTS_USERNAME: ${{ secrets.NEW_MAVEN_SNAPSHOT_USERNAME }}
145+
SNAPSHOTS_PASSWORD: ${{ secrets.NEW_MAVEN_SNAPSHOT_PASSWORD }}
146+
TARGET: x86_64-apple-darwin
147+
OS: macos-x86_64
148+
- run: ./gradlew publish --stacktrace
149+
env:
150+
MAVEN_URL: ${{ secrets.NEW_MAVEN_URL }}
151+
MAVEN_USERNAME: ${{ secrets.NEW_MAVEN_USERNAME }}
152+
MAVEN_PASSWORD: ${{ secrets.NEW_MAVEN_PASSWORD }}
153+
SNAPSHOTS_URL: ${{ secrets.NEW_MAVEN_SNAPSHOT_URL }}
154+
SNAPSHOTS_USERNAME: ${{ secrets.NEW_MAVEN_SNAPSHOT_USERNAME }}
155+
SNAPSHOTS_PASSWORD: ${{ secrets.NEW_MAVEN_SNAPSHOT_PASSWORD }}
156+
TARGET: universal2-apple-darwin
157+
OS: macos-universal2
158+
publish_linux_cross:
159+
strategy:
160+
matrix:
161+
build: [linux-aarch64]
162+
include:
163+
- build: linux-aarch64
164+
target: aarch64-unknown-linux-gnu
165+
runs-on: ubuntu-latest
166+
steps:
167+
- uses: actions/checkout@v4
168+
- uses: actions/setup-java@v4
169+
with:
170+
distribution: "microsoft"
171+
java-version: "21"
172+
cache: "gradle"
173+
- uses: gradle/actions/wrapper-validation@v3
174+
- name: Install Rust
175+
uses: dtolnay/rust-toolchain@stable
176+
with:
177+
toolchain: stable
178+
- uses: Swatinem/rust-cache@v2
179+
with:
180+
key: linux-cross
181+
- run: cargo install cross --git https://github.com/cross-rs/cross
182+
# Build the CLI only binary
183+
- run: cross build --no-default-features --release --target ${{ matrix.target }}
184+
- run: mv "target/${{ matrix.target }}/release/ornithe-installer-rs" "target/${{ matrix.target }}/release/ornithe-installer-rs-cli.bin"
185+
# Regular build with GUI
186+
- run: cross build --release --target ${{ matrix.target }}
187+
- run: mv "target/${{ matrix.target }}/release/ornithe-installer-rs" "target/${{ matrix.target }}/release/ornithe-installer-rs.bin"
188+
- uses: actions/upload-artifact@v4
189+
with:
190+
name: Artifacts ${{ matrix.target }}
191+
path: |
192+
target/${{ matrix.target }}/release/ornithe-installer-rs*
193+
!target/**/ornithe-installer-rs.d
194+
!target/**/build/
81195
- run: ./gradlew publish --stacktrace
82196
env:
197+
MAVEN_URL: ${{ secrets.NEW_MAVEN_URL }}
198+
MAVEN_USERNAME: ${{ secrets.NEW_MAVEN_USERNAME }}
199+
MAVEN_PASSWORD: ${{ secrets.NEW_MAVEN_PASSWORD }}
83200
SNAPSHOTS_URL: ${{ secrets.NEW_MAVEN_SNAPSHOT_URL }}
84201
SNAPSHOTS_USERNAME: ${{ secrets.NEW_MAVEN_SNAPSHOT_USERNAME }}
85202
SNAPSHOTS_PASSWORD: ${{ secrets.NEW_MAVEN_SNAPSHOT_PASSWORD }}
86203
TARGET: ${{ matrix.target }}
87-
OS: ${{ matrix.build }}
204+
OS: ${{ matrix.build }}

Cross.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[build]
2+
pre-build = [
3+
"dpkg --add-architecture $CROSS_DEB_ARCH",
4+
"apt-get update && apt-get --assume-yes install libxcb-render0-dev:$CROSS_DEB_ARCH libxcb-shape0-dev:$CROSS_DEB_ARCH libxcb-xfixes0-dev:$CROSS_DEB_ARCH libxkbcommon-dev:$CROSS_DEB_ARCH libssl-dev:$CROSS_DEB_ARCH libgtk-3-dev:$CROSS_DEB_ARCH"
5+
]

build.gradle.kts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,19 @@ publishing {
5454
repositories {
5555
if (env["MAVEN_URL"] != null) {
5656
repositories.maven {
57+
name = "Release"
5758
url = uri(env["MAVEN_URL"]!!)
5859

5960
credentials {
6061
username = env["MAVEN_USERNAME"]
6162
password = env["MAVEN_PASSWORD"]
6263
}
6364
}
64-
} else if (env["SNAPSHOTS_URL"] != null) {
65+
}
66+
67+
if (env["SNAPSHOTS_URL"] != null) {
6568
repositories.maven {
69+
name = "Snapshots"
6670
url = uri(env["SNAPSHOTS_URL"]!!)
6771

6872
credentials {

0 commit comments

Comments
 (0)