Skip to content

Commit 7e1b1b3

Browse files
authored
ci: build riscv64, loongarch64, and ppc64 releases (#30)
1 parent d7f2f6c commit 7e1b1b3

3 files changed

Lines changed: 81 additions & 2 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ permissions:
1414
contents: write
1515
id-token: write
1616

17+
env:
18+
ZIG_VERSION: 0.16.0
19+
ZIG_SHA256: 70e49664a74374b48b51e6f3fdfbf437f6395d42509050588bd49abe52ba3d00
20+
1721
jobs:
1822
publish-binaries:
1923
name: Publish binaries
@@ -32,6 +36,30 @@ jobs:
3236
RUNNER: ubuntu-24.04-arm,
3337
TARGET: aarch64-unknown-linux-musl,
3438
}
39+
- {
40+
NAME: riscv64-linux,
41+
RUNNER: ubuntu-latest,
42+
TARGET: riscv64gc-unknown-linux-musl,
43+
ZIGTARGET: riscv64-linux-musl,
44+
}
45+
- {
46+
NAME: loongarch64-linux,
47+
RUNNER: ubuntu-latest,
48+
TARGET: loongarch64-unknown-linux-musl,
49+
ZIGTARGET: loongarch64-linux-musl,
50+
}
51+
- {
52+
NAME: ppc64-linux,
53+
RUNNER: ubuntu-latest,
54+
TARGET: powerpc64-unknown-linux-musl,
55+
ZIGTARGET: powerpc64-linux-musl,
56+
}
57+
- {
58+
NAME: ppc64le-linux,
59+
RUNNER: ubuntu-latest,
60+
TARGET: powerpc64le-unknown-linux-musl,
61+
ZIGTARGET: powerpc64le-linux-musl,
62+
}
3563
steps:
3664
- name: Checkout
3765
uses: actions/checkout@v4
@@ -52,8 +80,47 @@ jobs:
5280
targets: ${{ matrix.build.TARGET }}
5381
components: rust-src
5482

83+
- name: Install zig
84+
if: ${{ matrix.build.ZIGTARGET }}
85+
run: |
86+
curl -fL --retry 3 -o "$RUNNER_TEMP/zig.tar.xz" \
87+
"https://ziglang.org/download/${ZIG_VERSION}/zig-x86_64-linux-${ZIG_VERSION}.tar.xz"
88+
echo "${ZIG_SHA256} $RUNNER_TEMP/zig.tar.xz" | sha256sum -c -
89+
mkdir -p "$RUNNER_TEMP/zig"
90+
tar xJf "$RUNNER_TEMP/zig.tar.xz" -C "$RUNNER_TEMP/zig" --strip-components=1
91+
92+
- name: Create zig cc wrappers
93+
if: ${{ matrix.build.ZIGTARGET }}
94+
run: |
95+
# cc-rs appends a rustc triple as --target=, which zig cc cannot
96+
# parse, so the wrapper drops it and keeps the zig target
97+
cat > "$RUNNER_TEMP/zigcc" <<EOF
98+
#!/bin/bash
99+
args=()
100+
for a in "\$@"; do
101+
case "\$a" in --target=*) ;; *) args+=("\$a") ;; esac
102+
done
103+
exec "$RUNNER_TEMP/zig/zig" cc -target ${{ matrix.build.ZIGTARGET }} "\${args[@]}"
104+
EOF
105+
printf '#!/bin/bash\nexec "%s" ar "$@"\n' "$RUNNER_TEMP/zig/zig" > "$RUNNER_TEMP/zigar"
106+
chmod +x "$RUNNER_TEMP/zigcc" "$RUNNER_TEMP/zigar"
107+
55108
- name: Build
56-
run: cargo build --release --locked --target ${{ matrix.build.TARGET }} -Z build-std=std,panic_abort
109+
run: |
110+
# the profile only asks for panic = "abort" so the crate still builds
111+
# on stable; nightly upgrades it to immediate-abort here
112+
export RUSTFLAGS="-Z unstable-options -C panic=immediate-abort"
113+
if [ -n "${{ matrix.build.ZIGTARGET }}" ]; then
114+
TARGET_ENV=$(echo "${{ matrix.build.TARGET }}" | tr 'a-z-' 'A-Z_')
115+
CC_ENV=$(echo "${{ matrix.build.TARGET }}" | tr '-' '_')
116+
export CARGO_TARGET_${TARGET_ENV}_LINKER="$RUNNER_TEMP/zigcc"
117+
export CC_${CC_ENV}="$RUNNER_TEMP/zigcc"
118+
export AR_${CC_ENV}="$RUNNER_TEMP/zigar"
119+
RUSTFLAGS="$RUSTFLAGS -C target-feature=+crt-static -C link-self-contained=no"
120+
export ZIG_GLOBAL_CACHE_DIR="$RUNNER_TEMP/zig-cache"
121+
export ZIG_LOCAL_CACHE_DIR="$RUNNER_TEMP/zig-cache"
122+
fi
123+
cargo build --release --locked --target ${{ matrix.build.TARGET }} -Z build-std=std,panic_abort
57124
58125
- name: Prepare release assets
59126
shell: bash

‎README.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ A Rust implementation of AppImageUpdate - a tool for updating AppImages using ef
1818

1919
## Installation
2020

21+
### Prebuilt Binaries
22+
23+
Every release ships static binaries for `x86_64`, `aarch64`, `riscv64`, `loongarch64`, `ppc64`, and `ppc64le` on the [releases page](https://github.com/pkgforge-dev/appimageupdate/releases). An installed copy can upgrade itself with `appimageupdate --self-update`.
24+
2125
### From Source
2226

2327
```bash

‎src/self_update.rs‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,17 @@ fn detect_arch() -> Result<&'static str> {
129129
Ok("x86_64")
130130
} else if cfg!(target_arch = "aarch64") {
131131
Ok("aarch64")
132+
} else if cfg!(target_arch = "riscv64") {
133+
Ok("riscv64")
134+
} else if cfg!(target_arch = "loongarch64") {
135+
Ok("loongarch64")
136+
} else if cfg!(all(target_arch = "powerpc64", target_endian = "little")) {
137+
Ok("ppc64le")
138+
} else if cfg!(target_arch = "powerpc64") {
139+
Ok("ppc64")
132140
} else {
133141
Err(Error::AppImage(
134-
"--self-update only supports x86_64 and aarch64".into(),
142+
"--self-update has no binary release for this architecture".into(),
135143
))
136144
}
137145
}

0 commit comments

Comments
 (0)