-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add workflow to create and upload apt packages
- Loading branch information
Showing
2 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
|
||
name: package | ||
|
||
"on": | ||
push: | ||
paths: | ||
- .github/actions/** | ||
- .github/workflows/package.yml | ||
release: | ||
types: [published] | ||
workflow_dispatch: | ||
inputs: | ||
release: | ||
description: 'Debian package release number' | ||
default: '1' | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
CARGO_INCREMENTAL: 0 | ||
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse | ||
RUST_BACKTRACE: full | ||
# Most docker images seem to get this right but not ubuntu:focal | ||
DEBIAN_FRONTEND: noninteractive | ||
|
||
jobs: | ||
build-deb: | ||
name: ${{ matrix.distro }} | ||
runs-on: ubuntu-latest | ||
container: ${{ matrix.distro }} | ||
strategy: | ||
matrix: | ||
distro: | ||
# - debian:buster # oldstable | ||
# - debian:bullseye # stable | ||
- debian:bookworm # testing | ||
|
||
# - ubuntu:trusty # LTS until Apr 2024 | ||
# - ubuntu:xenial # LTS until Apr 2026 | ||
# - ubuntu:bionic # LTS until Apr 2028 | ||
# - ubuntu:focal # LTS until Apr 2030 | ||
# - ubuntu:jammy # LTS until Apr 2032 | ||
# - ubuntu:kinetic # Previous release | ||
# - ubuntu:lunar # Current release | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: setup some variables | ||
id: vars | ||
shell: bash | ||
run: | | ||
echo distro="$(echo '${{ matrix.distro }}' | cut -d : -f 1)" >> "$GITHUB_OUTPUT" | ||
echo release="$(echo '${{ matrix.distro }}' | cut -d : -f 2)" >> "$GITHUB_OUTPUT" | ||
- name: Install apt dependencies | ||
shell: bash | ||
run: | | ||
apt-get update | ||
apt-get install -y curl build-essential pkg-config libssl-dev jq debhelper lsb-release | ||
- name: install rust | ||
shell: bash | ||
run: | | ||
curl https://static.rust-lang.org/rustup/rustup-init.sh -o rustup-init.sh | ||
chmod +x rustup-init.sh | ||
./rustup-init.sh -y | ||
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH | ||
rm -f rustup-init.sh | ||
- 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 | ||
- name: generate changelog | ||
shell: bash | ||
run: ./debian/gen-changelog.sh > debian/changelog | ||
|
||
- name: build debs | ||
shell: bash | ||
run: dpkg-buildpackage -b -us -uc | ||
|
||
- name: copy debs | ||
shell: bash | ||
run: | | ||
shopt -s nullglob | ||
mkdir -p target/debian | ||
cp ../*.deb ../*.ddeb target/debian/ | ||
tar cJf target/${{ steps.vars.outputs.distro }}_${{ steps.vars.outputs.release}}.tar.xz target/debian/* | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
path: target/${{ steps.vars.outputs.distro }}_${{ steps.vars.outputs.release }}.tar.xz | ||
|
||
upload-to-apt-repo: | ||
if: ${{ github.event_name == 'release' || github.event_name == 'workflow_dispatch' }} | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build-deb | ||
steps: | ||
- 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@v3 | ||
with: | ||
path: . | ||
|
||
- name: configure artifact registry | ||
run: | | ||
gcloud config set artifacts/repository systemslab | ||
gcloud config set artifacts/location us | ||
- name: upload package | ||
if: false | ||
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
VERSION=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "systemslab-server") | .version') | ||
RELEASE=${RELEASE:-1} | ||
|
||
cat <<EOM | ||
($VERSION-$RELEASE) $(lsb_release -sc); urgency=medium | ||
* Automated update package for rpc-perf $VERSION | ||
-- IOP Systems <[email protected]> $(date -R) | ||
EOM |