-
Notifications
You must be signed in to change notification settings - Fork 10
195 lines (168 loc) · 6.67 KB
/
package.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# 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 }}:${{ matrix.release }}"
runs-on: ubuntu-latest
container: "${{ matrix.distro }}:${{ matrix.release }}"
strategy:
matrix:
include:
- { distro: debian, release: buster } # LTS until July 2024
- { distro: debian, release: bullseye } # LTS until July 2026
- { distro: debian, release: bookworm } # LTS until July 2028
# trusty and xenial are too old to properly support cross compiling
# (or a compiler that supports C++17).
# - { distro: ubuntu, release: trusty } # LTS until Apr 2024
# - { distro: ubuntu, release: xenial } # LTS until Apr 2026
# - { distro: ubuntu, release: bionic } # LTS until Apr 2028
- { distro: ubuntu, release: focal } # LTS until Apr 2030
- { distro: ubuntu, release: jammy } # LTS until Apr 2032
# - { distro: ubuntu, release: lunar } # Previous release
- { distro: ubuntu, release: mantic } # Current release
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@v3
- 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 \
pkg-config libzstd-dev
- name: install rust
run: |
curl -sSf https://sh.rustup.rs | sh /dev/stdin -y --profile minimal
echo "PATH=$HOME/.cargo/bin:$PATH" >> "$GITHUB_ENV"
- name: enable additional rustup targets
run: rustup target add aarch64-unknown-linux-gnu
# 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: ${{ matrix.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: 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
# Cross-compiling for arm64 fails with boring-ssl errors; disable for now.
# - name: install arm64 build dependencies
# run: apt-get build-dep -y -a arm64 ../rpc-perf*.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 ../rpc-perf*.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@v3
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@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