Files
bottom/.github/workflows/build_releases.yml
Clement Tsang 9d9f857195 ci: reuse build artifacts for build-deb and build-rpm (#1990)
* reuse build artifacts for build-deb and rpm

* don't need cross anymore

* no need to download cargo if I'm just using a container

* revert

* Revert again
2026-02-26 23:20:50 -05:00

716 lines
23 KiB
YAML

# Builds the following releases:
# - Binaries
# - Binaries via VMs
# - Cirrus binaries (currently just Linux 2.17)
# - MSI installer for Windows (.msi)
# - .deb releases
# - .rpm releases
#
# Note that for musl targets, we use cross to avoid having to set up the dependencies for musl.
#
# TODO: Break this up into scripts instead.
# TODO: Trigger this in CI as well if this file changes, so I don't have to spam nightly builds.
name: "build releases"
on:
workflow_dispatch:
workflow_call:
inputs:
caller:
description: "The calling workflow."
default: ""
required: false
type: string
env:
RUST_BACKTRACE: 1
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0
CARGO_HUSKY_DONT_INSTALL_HOOKS: true
COMPLETION_DIR: "target/tmp/bottom/completion/"
MANPAGE_DIR: "target/tmp/bottom/manpage/"
CROSS_VERSION: "git:588b3c99db52b5a9c5906fab96cfadcf1bde7863"
permissions:
id-token: write
contents: read
attestations: write
jobs:
build-binaries:
name: "Build binaries"
runs-on: ${{ matrix.info.os }}
container: ${{ matrix.info.container }}
timeout-minutes: 12
strategy:
fail-fast: false
matrix:
info:
# ======= Supported targets =======
# Linux (x86-64, x86, aarch64)
- {
target: "x86_64-unknown-linux-gnu",
os: "ubuntu-22.04",
cross: false,
generate-other-artifacts: true,
}
- {
target: "i686-unknown-linux-gnu",
os: "ubuntu-22.04",
cross: true,
}
- {
target: "x86_64-unknown-linux-musl",
os: "ubuntu-22.04",
cross: true,
}
- {
target: "i686-unknown-linux-musl",
os: "ubuntu-22.04",
cross: true,
}
- {
target: "aarch64-unknown-linux-gnu",
os: "ubuntu-22.04-arm",
cross: false,
}
- {
target: "aarch64-unknown-linux-musl",
os: "ubuntu-22.04",
cross: true,
}
# macOS (x86-64 and aarch64)
- {
target: "x86_64-apple-darwin",
os: "macos-15-intel",
cross: false,
}
- { target: "aarch64-apple-darwin", os: "macos-15", cross: false }
# Windows (x86-64, x86)
- {
target: "x86_64-pc-windows-msvc",
os: "windows-2022",
cross: false,
}
- { target: "i686-pc-windows-msvc", os: "windows-2022", cross: false }
- {
target: "x86_64-pc-windows-gnu",
os: "windows-2022",
cross: false,
}
# ======= Unsupported targets =======
# armv7
- {
target: "armv7-unknown-linux-gnueabihf",
os: "ubuntu-22.04",
cross: true,
}
- {
target: "armv7-unknown-linux-musleabihf",
os: "ubuntu-22.04",
cross: true,
}
# PowerPC 64 LE
- {
target: "powerpc64le-unknown-linux-gnu",
os: "ubuntu-22.04",
cross: true,
}
# Risc-V 64gc
- {
target: "riscv64gc-unknown-linux-gnu",
os: "ubuntu-22.04",
cross: true,
}
# Android
- {
target: "aarch64-linux-android",
os: "ubuntu-24.04",
cross: true,
no-default-features: true,
}
# Loongarch
- {
target: "loongarch64-unknown-linux-gnu",
os: "ubuntu-22.04",
cross: true,
}
# Windows ARM, may promote to official.
- {
target: "aarch64-pc-windows-msvc",
os: "windows-11-arm",
cross: false,
}
# FreeBSD
- {
target: "x86_64-unknown-freebsd",
os: "ubuntu-22.04",
cross: true,
}
# NetBSD
- { target: "x86_64-unknown-netbsd", os: "ubuntu-22.04", cross: true }
steps:
- name: Checkout repository
if: matrix.info.container == ''
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
# TODO: Make this and the toolchain step a separate wrapper action?
- name: Read Rust version
shell: bash
run: |
VER=$(cat .github/ci/rust_version.txt)
echo "RUST_VERSION=$VER" >> $GITHUB_ENV
echo "$VER"
- name: Set up Rust toolchain
if: matrix.info.container == ''
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: ${{ matrix.info.rust || env.RUST_VERSION }}
target: ${{ matrix.info.target }}
- name: Set up Rust toolchain (non-GitHub container)
if: matrix.info.container != ''
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs --output rustup.sh
sh rustup.sh --default-toolchain stable -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Set features
shell: bash
run: |
if [[ "${{ matrix.info.no-default-features }}" == "true" ]]; then
BUILD_FEATURES="--no-default-features"
else
BUILD_FEATURES="--features deploy"
fi
echo "Will build with the following features: $BUILD_FEATURES"
echo "BUILD_FEATURES=$BUILD_FEATURES" >> $GITHUB_ENV
- name: Build
uses: ClementTsang/cargo-action@2438cc5f3ba4e971289fffca2a00dedea6911f14 # v0.0.7
env:
BTM_GENERATE: true
BTM_BUILD_RELEASE_CALLER: ${{ inputs.caller }}
with:
command: build
args: --release --locked --target=${{ matrix.info.target }} ${{ env.BUILD_FEATURES }}
use-cross: ${{ matrix.info.cross }}
cross-version: ${{ matrix.info.cross-version || env.CROSS_VERSION }}
- name: Move automatically generated completion/manpage
shell: bash
run: |
mv "$COMPLETION_DIR" completion
mv "$MANPAGE_DIR" manpage
- name: Determine signing slug for Windows signing
id: get-signing-slug
if: startsWith(matrix.info.os, 'windows')
shell: bash
run: |
mkdir -p signed
if [[ ${{ inputs.caller }} == "nightly" ]]; then
echo "slug=test-signing" >> $GITHUB_OUTPUT
else
echo "slug=release-signing" >> $GITHUB_OUTPUT
fi
- name: Upload unsigned Windows artifact
id: upload-unsigned-artifact
if: startsWith(matrix.info.os, 'windows')
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
retention-days: 1
name: "unsigned-${{ matrix.info.target }}"
path: target/${{ matrix.info.target }}/release/btm.exe
- name: Sign Windows artifacts
if: startsWith(matrix.info.os, 'windows')
uses: signpath/github-action-submit-signing-request@3f9250c56651ff692d6729a2fbb0603a42d7d322 # v2.0
with:
api-token: "${{ secrets.SIGNPATH_API_TOKEN }}"
organization-id: "06b1a1ff-74e1-4d9d-93b1-fa8180c67727"
project-slug: "bottom"
signing-policy-slug: "${{ steps.get-signing-slug.outputs.slug }}"
github-artifact-id: "${{ steps.upload-unsigned-artifact.outputs.artifact-id }}"
wait-for-completion: true
output-artifact-directory: "signed"
- name: Bundle release and completion (Windows)
if: startsWith(matrix.info.os, 'windows')
shell: bash
run: |
mv signed/btm.exe btm.exe
7z a bottom_${{ matrix.info.target }}.zip "btm.exe"
7z a bottom_${{ matrix.info.target }}.zip "completion"
echo "ASSET=bottom_${{ matrix.info.target }}.zip" >> $GITHUB_ENV
- name: Bundle release and completion (Linux and macOS)
if: ${{ !(startsWith(matrix.info.os, 'windows')) }}
shell: bash
run: |
cp target/${{ matrix.info.target }}/release/btm ./btm
tar -czvf bottom_${{ matrix.info.target }}.tar.gz btm completion
echo "ASSET=bottom_${{ matrix.info.target }}.tar.gz" >> $GITHUB_ENV
- name: Generate artifact attestation for file
uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2
with:
subject-path: ${{ env.ASSET }}
- name: Create release directory for artifact, move file
shell: bash
run: |
mkdir release
mv ${{ env.ASSET }} release/
- name: Compress completion files
if: matrix.info.generate-other-artifacts == true
shell: bash
run: |
tar -C ./completion -czvf completion.tar.gz .
mv completion.tar.gz release/
- name: Compress manpage files
if: matrix.info.generate-other-artifacts == true
shell: bash
run: |
gzip ./manpage/btm.1
tar -C ./manpage -czvf manpage.tar.gz .
mv manpage.tar.gz release/
- name: Copy over .desktop file
if: matrix.info.generate-other-artifacts == true
shell: bash
run: |
cp ./desktop/bottom.desktop release/
- name: Save release as artifact
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
retention-days: 3
name: "release-${{ matrix.info.target }}"
path: release
build-msi:
name: "Build MSI (WiX) installer"
timeout-minutes: 12
strategy:
fail-fast: false
matrix:
info:
- {
os: "windows-2022",
target: "x86_64-pc-windows-msvc",
output: "bottom_x86_64_installer.msi",
}
- {
os: "windows-11-arm",
target: "aarch64-pc-windows-msvc",
output: "bottom_aarch64_installer.msi",
}
runs-on: ${{ matrix.info.os }}
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
- name: Install Net-Framework-Core
shell: powershell
run: |
choco install dotnet-sdk --pre -y --no-progress;
- name: Install wixtoolset
shell: powershell
run: |
choco install -y wixtoolset --no-progress;
- name: Read Rust version
shell: bash
run: |
VER=$(cat .github/ci/rust_version.txt)
echo "RUST_VERSION=$VER" >> $GITHUB_ENV
echo "$VER"
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.info.target }}
- name: Install cargo-wix
shell: powershell
run: |
cargo install cargo-wix --version 0.3.8 --locked
- name: Build MSI file
shell: powershell
env:
BTM_GENERATE: true
run: |
Import-Module "$env:ChocolateyInstall/helpers/chocolateyInstaller.psm1"
refreshenv
cargo wix --nocapture
mv bottom_installer.msi ${{ matrix.info.output }}
- name: Generate artifact attestation for file
uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2
with:
subject-path: ${{ matrix.info.output }}
- name: Create release directory for artifact, move files
shell: bash
run: |
mkdir release
mv ${{ matrix.info.output }} release/
- name: Save release as artifact
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
retention-days: 3
name: "release-${{ matrix.info.target }}-msi"
path: release
build-cirrus:
name: "Build using Cirrus CI"
runs-on: "ubuntu-24.04"
timeout-minutes: 12
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- name: Create release directory
run: |
mkdir -p release
- name: Execute Cirrus CI build script
env:
CIRRUS_KEY: ${{ secrets.CIRRUS_TOKEN }}
run: |
if [[ "${{ github.ref_type }}" == "branch" ]]; then
BRANCH="${{ github.ref_name }}";
else
raw=$(git branch -r --contains '${{ github.ref_name }}');
BRANCH=${raw##*/};
fi
python ./scripts/ci/cirrus_release.py "$BRANCH" "release/" "${{ inputs.caller }}"
- name: Generate artifact attestation for file
uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2
with:
subject-path: "release/**/*.tar.gz"
- name: Save release as artifact
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
retention-days: 3
name: release-build-cirrus
path: release
build-deb:
name: "Build .deb software packages"
runs-on: ${{ matrix.info.os || 'ubuntu-24.04' }}
timeout-minutes: 12
strategy:
fail-fast: false
matrix:
info:
- { target: "x86_64-unknown-linux-gnu", dpkg: amd64 }
- { target: "x86_64-unknown-linux-musl", cross: true, dpkg: amd64 }
- {
target: "aarch64-unknown-linux-gnu",
cross: false,
dpkg: arm64,
os: "ubuntu-22.04-arm",
}
# The cross images don't work with ARM runners, unfortunately. We could build it on x86 with cross
# and then copy it over to an ARM runner but that's kind of annoying, so I'll skip this for now.
# TODO: Maybe improve how we do the .deb software building step?
- {
target: "aarch64-unknown-linux-musl",
cross: true,
dpkg: arm64,
container: "ghcr.io/clementtsang/cargo-deb-aarch64-unknown-linux-gnu",
}
- {
target: "armv7-unknown-linux-gnueabihf",
cross: true,
dpkg: armhf,
container: "ghcr.io/clementtsang/cargo-deb-armv7-unknown-linux-gnueabihf",
}
- {
target: "armv7-unknown-linux-musleabihf",
cross: true,
dpkg: armhf,
container: "ghcr.io/clementtsang/cargo-deb-armv7-unknown-linux-gnueabihf",
}
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
- name: Read Rust version
shell: bash
run: |
VER=$(cat .github/ci/rust_version.txt)
echo "RUST_VERSION=$VER" >> $GITHUB_ENV
echo "$VER"
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: ${{ matrix.info.rust || env.RUST_VERSION }}
target: ${{ matrix.info.target }}
- name: Build
uses: ClementTsang/cargo-action@2438cc5f3ba4e971289fffca2a00dedea6911f14 # v0.0.7
env:
BTM_GENERATE: true
BTM_BUILD_RELEASE_CALLER: ${{ inputs.caller }}
with:
command: build
args: --release --locked --features deploy --target ${{ matrix.info.target }}
use-cross: ${{ matrix.info.cross || false }}
cross-version: ${{ env.CROSS_VERSION }}
- name: Move automatically generated completion/manpage
shell: bash
run: |
mv "$COMPLETION_DIR" completion
mv "$MANPAGE_DIR" manpage
- name: Zip manpage
run: |
gzip ./manpage/btm.1
- name: Build Debian release (non-container)
if: ${{ matrix.info.container == '' }}
env:
BTM_GENERATE: true
run: |
cargo install cargo-deb --version 3.5.0 --locked
cargo deb --no-build --target ${{ matrix.info.target }}
cp ./target/debian/bottom_*.deb .
- name: Build Debian release (container)
if: ${{ matrix.info.container != '' }}
env:
BTM_GENERATE: true
run: |
docker pull ${{ matrix.info.container }}
docker run -t --rm --mount type=bind,source="$(pwd)",target=/volume ${{ matrix.info.container }} "--no-build --variant ${{ matrix.info.dpkg }} --target ${{ matrix.info.target }}" "/volume"
cp ./target/debian/bottom-*.deb .
TMP_NAME=$(find bottom-*.deb)
VERSION=${{ matrix.info.dpkg }}
mv $TMP_NAME $(echo $TMP_NAME | sed "s/-$VERSION//")
- name: Rename if it is a musl target
if: contains(matrix.info.target, 'musl')
run: |
TMP_NAME=$(find bottom_*.deb)
mv $TMP_NAME $(echo $TMP_NAME | sed "s/bottom/bottom-musl/")
# TODO: Maybe rename version if nightly?
- name: Verify Debian release
id: verify
run: |
DEB_FILE=$(find bottom*_*.deb)
dpkg -I $DEB_FILE
dpkg -I $DEB_FILE | grep ${{ matrix.info.dpkg }} && echo "Found correct architecture"
echo "DEB_FILE=$DEB_FILE" >> $GITHUB_OUTPUT
- name: Delete generated Debian folder
run: |
sudo chown $USER ./target/debian/ 2>/dev/null || true
rm -r ./target/debian/
- name: Generate artifact attestation for file
uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2
with:
subject-path: ${{ steps.verify.outputs.DEB_FILE }}
- name: Create release directory for artifact, move file
shell: bash
run: |
mkdir release
mv ${{ steps.verify.outputs.DEB_FILE }} release/
- name: Save release as artifact
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
retention-days: 3
name: release-build-deb-${{ matrix.info.target }}
path: release
build-rpm:
name: "Build .rpm software packages"
runs-on: ubuntu-24.04
container: ghcr.io/clementtsang/almalinux-8
timeout-minutes: 12
strategy:
fail-fast: false
matrix:
info:
- { target: "x86_64-unknown-linux-gnu" }
- { target: "x86_64-unknown-linux-musl", cross: true }
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
- name: Read Rust version
shell: bash
run: |
VER=$(cat .github/ci/rust_version.txt)
echo "RUST_VERSION=$VER" >> $GITHUB_ENV
echo "$VER"
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: ${{ matrix.info.rust || env.RUST_VERSION }}
target: ${{ matrix.info.target }}
- name: Build
uses: ClementTsang/cargo-action@2438cc5f3ba4e971289fffca2a00dedea6911f14 # v0.0.7
env:
BTM_GENERATE: true
BTM_BUILD_RELEASE_CALLER: ${{ inputs.caller }}
CROSS_CONTAINER_IN_CONTAINER: true
with:
command: build
use-cross: ${{ matrix.info.cross || false }}
args: --release --locked --features deploy --target ${{ matrix.info.target }}
cross-version: ${{ env.CROSS_VERSION }}
- name: Move automatically generated completion/manpage
shell: bash
run: |
mv "$COMPLETION_DIR" completion
mv "$MANPAGE_DIR" manpage
- name: Zip manpage
run: |
gzip ./manpage/btm.1
- name: Build rpm release
env:
BTM_GENERATE: true
run: |
cargo install cargo-generate-rpm --version 0.20.0 --locked
cargo generate-rpm --target ${{ matrix.info.target }}
cp ./target/${{ matrix.info.target }}/generate-rpm/bottom-*.rpm .
- name: Rename if it is a musl target
if: contains(matrix.info.target, 'musl')
run: |
TMP_NAME=$(find bottom-*.rpm)
mv $TMP_NAME $(echo $TMP_NAME | sed "s/bottom/bottom-musl/")
- name: Verify generated rpm file
id: verify
run: |
RPM_FILE=$(find bottom-*.rpm)
rpm -qip $RPM_FILE
# Save for future jobs
echo "RPM_FILE=$RPM_FILE" >> $GITHUB_OUTPUT
- name: Check generated rpm file signatures
run: |
rpm --checksig --verbose ${{ steps.verify.outputs.RPM_FILE }}
# Validate modern signature digest exist, see https://github.com/ClementTsang/bottom/issues/1848
rpm --checksig --verbose ${{ steps.verify.outputs.RPM_FILE }} | grep -q "SHA256"
- name: Test installing generated rpm file
run: |
yum localinstall -y ${{ steps.verify.outputs.RPM_FILE }}
btm -V
- name: Delete generated rpm folder
run: |
sudo chown $USER ./target/${{ matrix.info.target }}/generate-rpm/ 2>/dev/null || true
rm -r ./target/${{ matrix.info.target }}/generate-rpm/
- name: Generate artifact attestation for file
uses: actions/attest-build-provenance@6149ea5740be74af77f260b9db67e633f6b0a9a1 # v1.4.2
with:
subject-path: ${{ steps.verify.outputs.RPM_FILE }}
- name: Create release directory for artifact, move file
shell: bash
run: |
mkdir release
mv ${{ steps.verify.outputs.RPM_FILE }} release/
- name: Save release as artifact
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
with:
retention-days: 3
name: release-build-rpm-${{ matrix.info.target }}
path: release
test-installing:
name: "Test Installing"
runs-on: ${{ matrix.info.os }}
container: ${{ matrix.info.container }}
timeout-minutes: 12
strategy:
fail-fast: false
matrix:
info:
- { os: "ubuntu-22.04", target: "x86_64-unknown-linux-gnu" }
- { os: "macos-15", target: "aarch64-apple-darwin" }
- { os: "windows-2022", target: "x86_64-pc-windows-msvc" }
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 1
- name: Read Rust version
shell: bash
run: |
VER=$(cat .github/ci/rust_version.txt)
echo "RUST_VERSION=$VER" >> $GITHUB_ENV
echo "$VER"
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@e97e2d8cc328f1b50210efc529dca0028893a2d9
with:
toolchain: ${{ matrix.info.rust || env.RUST_VERSION }}
target: ${{ matrix.info.target }}
- name: Install (locked)
shell: bash
run: |
cargo install --path . --locked
btm -V
cargo uninstall bottom
- name: Install (not locked)
shell: bash
run: |
cargo install --path .
btm -V
cargo uninstall bottom