build rpm in ci #43
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: package-deb | |
"on": | |
push: | |
paths: | |
- .github/actions/** | |
- .github/workflows/package-deb.yml | |
- debian/** | |
pull_request: | |
paths: | |
- .github/actions/** | |
- .github/workflows/package-deb.yml | |
- debian/** | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
release: | |
description: 'Debian package release number' | |
default: '1' | |
permissions: write-all | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CARGO_TERM_COLOR: always | |
CARGO_INCREMENTAL: 0 | |
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse | |
RUST_BACKTRACE: 1 | |
# Most docker images seem to get this right but not ubuntu:focal | |
DEBIAN_FRONTEND: noninteractive | |
# Use zstd maximum compression for versions of dpkg which support it. | |
# | |
# Note that dpkg only checks these environment variables after version 1.21.10 | |
DPKG_DEB_COMPRESSOR_TYPE: zstd | |
DPKG_DEB_COMPRESSOR_LEVEL: 22 | |
PROTOC_VERSION: "23.4" | |
jobs: | |
build-deb: | |
name: "${{ matrix.distro }}:${{ matrix.release }}" | |
runs-on: ubuntu-24.04 | |
container: "${{ matrix.distro }}:${{ matrix.release }}" | |
strategy: | |
matrix: | |
include: | |
# minimum kernel version is 5.5 | |
# debian kernels supported from bullseye and up | |
- { distro: debian, release: bullseye } | |
- { distro: debian, release: bookworm } | |
# ubuntu kernels supported from 20.10 and up | |
- { distro: ubuntu, release: jammy } # 22.04 | |
# - { distro: ubuntu, release: noble } # 24.04 | |
fail-fast: false | |
env: | |
# dpkg-buildpackage issues a warning if we attempt to cross compile and | |
# tests are still enabled. Disabling the test step fixes this. | |
# | |
# Note that we don't run tests anyway so this doesn't really change | |
# anything for us. | |
DEB_BUILD_OPTS: nocheck | |
steps: | |
- uses: actions/checkout@v4 | |
- name: modify /etc/apt/sources.list | |
if: ${{ matrix.distro == 'ubuntu' }} | |
run: | | |
cat /etc/apt/sources.list | \ | |
sed 's/^deb /deb [arch=amd64] /g' | \ | |
grep '^deb ' \ | |
> amd64.list | |
cat /etc/apt/sources.list | \ | |
sed 's/^deb /deb [arch=arm64] /g' | \ | |
grep archive.ubuntu.com | \ | |
grep '^deb ' | \ | |
sed 's|archive.ubuntu.com/ubuntu|ports.ubuntu.com|g' \ | |
> arm64.list | |
cat amd64.list arm64.list > /etc/apt/sources.list | |
rm amd64.list arm64.list | |
- name: enable arm64 dpkg architecture | |
run: dpkg --add-architecture arm64 | |
- name: install buildsystem apt dependencies | |
run: | | |
apt-get update | |
apt-get install -y \ | |
build-essential \ | |
crossbuild-essential-arm64 \ | |
curl jq lsb-release unzip gpg | |
- name: install rust | |
run: | | |
curl -sSf https://sh.rustup.rs | sh /dev/stdin -y | |
echo "PATH=$HOME/.cargo/bin:$PATH" >> "$GITHUB_ENV" | |
- name: enable additional rustup targets | |
run: rustup target add aarch64-unknown-linux-gnu | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: build-deb-${{ matrix.distro }}-${{ matrix.release }} | |
- name: check cargo | |
shell: bash | |
run: | | |
echo "::group::rustc -vV" | |
rustc -vV | |
echo "::endgroup::" | |
echo "::group::cargo -vV" | |
cargo -vV | |
echo "::endgroup::" | |
- name: set release env var | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
shell: bash | |
run: | | |
echo 'RELEASE=${{ github.event.inputs.release }}' >> $GITHUB_ENV | |
# Changelogs with revisions cause dpkg-source to emit an error when | |
# building. We only use the source package to install the build deps | |
# so building it with an invalid version is ok. | |
- name: build source package | |
run: dpkg-source --build . | |
- name: generate changelog | |
shell: bash | |
run: ./debian/gen-changelog.sh > debian/changelog | |
- name: install arm64 build dependencies | |
run: apt-get build-dep -y -a arm64 ../rezolus*.dsc | |
- name: build arm64 package | |
run: dpkg-buildpackage -b -us -uc --host-arch arm64 | |
- name: install x86_64 build dependencies | |
run: apt-get build-dep -y -a amd64 ../rezolus*.dsc | |
- name: build x86_64 package | |
run: dpkg-buildpackage -b -us -uc --host-arch amd64 | |
- name: copy debs | |
shell: bash | |
run: | | |
shopt -s nullglob | |
mkdir -p target/debian | |
cp ../*.deb ../*.ddeb target/debian/ | |
- uses: actions/upload-artifact@v4 | |
with: | |
path: target/debian/* | |
name: ${{ matrix.distro }}_${{ matrix.release }}_all | |
upload-to-apt-repo: | |
if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }} | |
runs-on: ubuntu-latest | |
needs: | |
- build-deb | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: google-github-actions/auth@v1 | |
id: auth | |
with: | |
credentials_json: "${{ secrets.GCP_CREDENTIALS }}" | |
- uses: google-github-actions/setup-gcloud@v1 | |
- uses: actions/download-artifact@v4.1.7 | |
with: | |
path: target/debian/ | |
- name: configure artifact registry | |
run: | | |
gcloud config set artifacts/repository systemslab | |
gcloud config set artifacts/location us | |
- name: upload package | |
run: | | |
for artifact in target/debian/*/*; do | |
name="$(basename "$artifact")" | |
distro="$(echo "$artifact" | cut -d _ -f 1)" | |
release="$(echo "$artifact" | cut -d _ -f 2)" | |
echo "::group::upload $release $name" | |
gcloud artifacts apt upload "$release" --source "$artifact" | |
echo "::endgroup::" | |
done | |
upload-release-artifacts: | |
if: ${{ github.event_name == 'release' }} | |
runs-on: ubuntu-latest | |
needs: | |
- build-deb | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4.1.7 | |
with: | |
path: target/debian/ | |
- name: upload packages | |
shell: bash | |
run: | | |
set -x | |
shopt -s nullglob | |
mkdir -p target/artifacts | |
for artifact in target/debian/**/*; do | |
name="$(basename "$artifact")" | |
directory="$(basename "$(dirname "$artifact")")" | |
distro="$(echo "$directory" | cut -d _ -f 1)" | |
release="$(echo "$directory" | cut -d _ -f 2)" | |
mv "$artifact" "target/artifacts/${distro}_${release}_${name}" | |
done | |
gh release upload "${{ github.event.release.tag_name }}" target/artifacts/* |