Skip to content

Commit ac0beb6

Browse files
ci: add reusable GitHub Action to build packages from another repo and centralize CI scripts. (ThinkParQ/beegfs-rs#188)
1 parent 493060d commit ac0beb6

File tree

2 files changed

+67
-48
lines changed

2 files changed

+67
-48
lines changed

.github/actions/package/action.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: "Build packages"
2+
description: "Build RPM and DEB packages for multiple architectures"
3+
4+
inputs:
5+
CI_PROTOBUF_ACCESS_TOKEN:
6+
description: "Access token for protobuf repo"
7+
required: true
8+
9+
runs:
10+
using: "composite"
11+
steps:
12+
- name: Setup Rust Environment
13+
uses: moonrepo/setup-rust@v1
14+
with:
15+
components: clippy
16+
targets: aarch64-unknown-linux-gnu
17+
bins: cargo-deny, cargo-about, cargo-generate-rpm, cargo-deb, cargo-zigbuild
18+
- name: Setup nightly toolchain and tools
19+
shell: bash
20+
run: |
21+
sudo apt-get update -qq && sudo apt-get install -y gcc-aarch64-linux-gnu
22+
wget -q -P /tmp http://deb.debian.org/debian/pool/main/d/dpkg-sig/dpkg-sig_0.13.1+nmu4_all.deb
23+
sudo apt install --yes /tmp/dpkg-sig_0.13.1+nmu4_all.deb rpm gnupg2
24+
rustup toolchain install nightly
25+
rustup component add --toolchain nightly rustfmt
26+
# Install zig 0.13 release, needed for cargo-zigbuild (latest release doesn't work right now)
27+
wget https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz -qO zig.tar.xz
28+
mkdir -p ${HOME}/zig
29+
tar -xJ -C ${HOME}/zig --strip-components=1 -f zig.tar.xz
30+
echo ${HOME}/zig >> ${GITHUB_PATH}
31+
- name: Configure foreign git repos
32+
# Make sure the runner has access to the protobuf repo using an access token
33+
shell: bash
34+
run: git config --global url."https://${{ inputs.CI_PROTOBUF_ACCESS_TOKEN }}@github.com/thinkparq/protobuf".insteadOf https://github.com/thinkparq/protobuf
35+
- name: Run checks and tests
36+
shell: bash
37+
run: |
38+
make check
39+
make deny
40+
make test
41+
- name: Build x86_64 packages
42+
env:
43+
CARGO_TARGET: x86_64-unknown-linux-gnu
44+
GLIBC_VERSION: 2.27
45+
shell: bash
46+
run: make package
47+
- name: Build aarch64 packages
48+
env:
49+
CARGO_TARGET: aarch64-unknown-linux-gnu
50+
BIN_UTIL_PREFIX: aarch64-linux-gnu-
51+
GLIBC_VERSION: 2.27
52+
shell: bash
53+
run: make package
54+
- name: Generate checksums for all files
55+
shell: bash
56+
run: |
57+
cd target/package
58+
rm -rf checksums.txt
59+
for file in *.rpm *.deb; do
60+
# Skip if it's a directory
61+
if [ -f "$file" ]; then
62+
sha256sum "$file" >> checksums.txt
63+
fi
64+
done

.github/workflows/release.yml

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,55 +20,10 @@ jobs:
2020
with:
2121
# Important to fetch the tags
2222
fetch-depth: 0
23-
- name: Setup Rust
24-
uses: moonrepo/setup-rust@v1
23+
- name: Build Packages
24+
uses: ./.github/actions/package
2525
with:
26-
components: clippy
27-
targets: aarch64-unknown-linux-gnu
28-
bins: cargo-deny, cargo-about, cargo-generate-rpm, cargo-deb, cargo-zigbuild
29-
- name: Setup nightly toolchain and tools
30-
run: |
31-
sudo apt-get update -qq && sudo apt-get install -y gcc-aarch64-linux-gnu
32-
wget -q -P /tmp http://deb.debian.org/debian/pool/main/d/dpkg-sig/dpkg-sig_0.13.1+nmu4_all.deb
33-
sudo apt install --yes /tmp/dpkg-sig_0.13.1+nmu4_all.deb rpm gnupg2
34-
rustup toolchain install nightly
35-
rustup component add --toolchain nightly rustfmt
36-
# Install zig 0.13 release, needed for cargo-zigbuild (latest release doesn't work right now)
37-
wget https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz -qO zig.tar.xz
38-
mkdir -p ${HOME}/zig
39-
tar -xJ -C ${HOME}/zig --strip-components=1 -f zig.tar.xz
40-
echo ${HOME}/zig >> ${GITHUB_PATH}
41-
- name: Configure foreign git repos
42-
# Make sure the runner has access to the protobuf repo using an access token
43-
run: git config --global url."https://${{ secrets.CI_PROTOBUF_ACCESS }}@github.com/thinkparq/protobuf".insteadOf https://github.com/thinkparq/protobuf
44-
- name: Run checks and tests
45-
run: |
46-
make check
47-
make deny
48-
make test
49-
- name: Build x86_64 packages
50-
env:
51-
CARGO_TARGET: x86_64-unknown-linux-gnu
52-
GLIBC_VERSION: 2.27
53-
run: make package
54-
- name: Build aarch64 packages
55-
env:
56-
CARGO_TARGET: aarch64-unknown-linux-gnu
57-
BIN_UTIL_PREFIX: aarch64-linux-gnu-
58-
GLIBC_VERSION: 2.27
59-
run: make package
60-
- name: Generate checksums for all files
61-
run: |
62-
cd target/package
63-
rm -rf checksums.txt
64-
for file in *.rpm *.deb; do
65-
# Skip if it's a directory
66-
if [ -f "$file" ]; then
67-
sha256sum "$file" >> checksums.txt
68-
fi
69-
done
70-
- name: show checksums
71-
run: cat target/package/checksums.txt
26+
CI_PROTOBUF_ACCESS_TOKEN: ${{ secrets.CI_PROTOBUF_ACCESS }}
7227
- name: Import GPG key
7328
id: import_gpg
7429
uses: crazy-max/ghaction-import-gpg@v6

0 commit comments

Comments
 (0)