Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to create and upload apt packages #31

Merged
merged 27 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3ee6329
Add workflow to create and upload apt packages
swlynch99 Jul 14, 2023
1e5a7fc
Fix gen-changelog.sh
swlynch99 Jul 14, 2023
f9c7b1d
Bump to ensure package.yml gets built
swlynch99 Jul 14, 2023
dc0a146
Fix package used to look up the version number
swlynch99 Jul 14, 2023
cd0519a
Bump package.yml again
swlynch99 Jul 14, 2023
8235f8b
Install cmake in setup
swlynch99 Jul 14, 2023
d82b49f
Disable upload-to-apt-repo preconditions
swlynch99 Jul 14, 2023
92cd3a6
Install libclang-dev during setup
swlynch99 Jul 14, 2023
5fd2fa7
Install protoc during setup
swlynch99 Jul 14, 2023
a97722f
Automatically extract package archives
swlynch99 Jul 14, 2023
0ff4190
Run the package workflow when debian/ is modified
swlynch99 Jul 14, 2023
ce50557
Use zstd compression for generated debs on platforms that support it
swlynch99 Jul 14, 2023
463e2c5
Fix globbing
swlynch99 Jul 14, 2023
6248213
Add some grouping commands
swlynch99 Jul 14, 2023
37410ef
Rework artifact extraction
swlynch99 Jul 15, 2023
cbafcfe
fix artifact tarring again
swlynch99 Jul 15, 2023
2ded007
Revert back to old artifact method
swlynch99 Jul 15, 2023
99aa181
Undo testing changes
swlynch99 Jul 15, 2023
5c71b6d
Drop older ubuntu releases
swlynch99 Jul 15, 2023
d73e624
Add clang as a build dependency
swlynch99 Jul 24, 2023
c88fe8f
Manually install protoc when on ubuntu
swlynch99 Jul 24, 2023
ef94da3
Disable trusty and xenial again
swlynch99 Jul 24, 2023
3944c28
Don't install protoc via apt if also installing from source
swlynch99 Jul 24, 2023
7855b7f
Print protoc version
swlynch99 Jul 24, 2023
cee86f2
Reduce backtrace verbosity
swlynch99 Jul 24, 2023
f2c91d3
Delete protoc.zip
swlynch99 Jul 24, 2023
13148f3
fix protoc install path for manual install
swlynch99 Jul 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: package

"on":
push:
paths:
- .github/actions/**
- .github/workflows/package.yml
- debian/**
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: 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 }}
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 \
cmake libclang-dev clang unzip

# Older ubuntu versions have a protoc version that is too old to build
# momento-protos. To work around this we manually install protoc.
- name: Manually install protoc
if: ${{ steps.vars.outputs.distro == 'ubuntu' }}
shell: bash
run: |
curl -sSL https://github.com/protocolbuffers/protobuf/releases/download/v${{ env.PROTOC_VERSION }}/protoc-${{ env.PROTOC_VERSION }}-linux-x86_64.zip -o protoc.zip
unzip protoc.zip -d /usr/local
rm protoc.zip

- name: Manually install protoc
if: ${{ steps.vars.outputs.distro != 'ubuntu' }}
shell: bash
run: |
apt-get install -y protobuf-compiler

- run: protoc --version

- 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/

- uses: actions/upload-artifact@v3
with:
path: target/debian/*
name: ${{ steps.vars.outputs.distro }}_${{ steps.vars.outputs.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@v3
- 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: 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
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: rpc-perf
Section: devel
Priority: optional
Maintainer: IOP Systems <[email protected]>
Build-Depends: build-essential, debhelper (>= 10), jq
Build-Depends: build-essential, debhelper (>= 10), jq, clang

Package: rpc-perf
Architecture: any
Expand Down
12 changes: 12 additions & 0 deletions debian/gen-changelog.sh
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 == "rpc-perf") | .version')
RELEASE=${RELEASE:-1}

cat <<EOM
rpc-perf ($VERSION-$RELEASE) $(lsb_release -sc); urgency=medium

* Automated update package for rpc-perf $VERSION

-- IOP Systems <[email protected]> $(date -R)
EOM
Loading