-
Notifications
You must be signed in to change notification settings - Fork 9
166 lines (142 loc) · 5.18 KB
/
package-deb.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
# 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: buildjet-16vcpu-ubuntu-2204${{ matrix.arch == 'arm64' && '-arm' || '' }}
strategy:
matrix:
include:
# minimum kernel version is 5.5
# debian kernels supported from bullseye and up
- { distro: debian, release: bullseye, arch: x86_64 }
- { distro: debian, release: bullseye, arch: arm64 }
- { distro: debian, release: bookworm, arch: x86_64 }
- { distro: debian, release: bookworm, arch: arm64 }
# ubuntu kernels supported from 20.10 and up
- { distro: ubuntu, release: jammy, arch: x86_64 } # 22.04
- { distro: ubuntu, release: jammy, arch: arm64 } # 22.04
- { distro: ubuntu, release: noble, arch: x86_64 } # 24.04
- { distro: ubuntu, release: noble, arch: arm64 } # 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: set release env var
if: ${{ github.event_name == 'workflow_dispatch' }}
shell: bash
run: |
echo 'RELEASE=${{ github.event.inputs.release }}' >> $GITHUB_ENV
- name: set release env var
if: ${{ github.event_name != 'workflow_dispatch' }}
shell: bash
run: |
echo 'RELEASE=0' >> $GITHUB_ENV
- name: run packaging script
run: |
mkdir -p target/debian
docker run --rm \
-v $(pwd):/mnt/rezolus \
-v $(pwd)/target/debian:/mnt/output \
${{ matrix.distro }}:${{ matrix.release }} \
/mnt/rezolus/debian/package.sh \
--release "$RELEASE" \
--chown "$(id -u)" \
--verbose
- uses: actions/upload-artifact@v4
with:
path: target/debian/*
name: ${{ matrix.distro }}_${{ matrix.release }}_${{ matrix.arch }}
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/[email protected]
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"
gcloud artifacts apt upload "$release-public" --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/[email protected]
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/*