-
Notifications
You must be signed in to change notification settings - Fork 1
187 lines (165 loc) · 6.18 KB
/
deb-build.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
name: Debian Package Build
on:
pull_request:
push:
branches:
- master
- bullseye
workflow_dispatch:
env:
DEB_BUILD_DOCKER_IMAGE: "pitop/pi-top-os-deb-build"
DEB_BUILD_DOCKER_BRANCH: "master"
CHANGELOG_AUTHOR_NAME: "pi-top"
CHANGELOG_AUTHOR_EMAIL: "deb-maintainers@pi-top.com"
PACKAGECLOUD_REPO: "experimental"
OS: "debian"
HOST_COMPILE: "\"architecture\":[\"amd64\"]"
X_COMPILE: "\"architecture\":[\"armhf\", \"arm64\"]" # ARM 32 and 64 bit
jobs:
check-architecture:
runs-on: ubuntu-20.04
outputs:
architecture: ${{ steps.set-arch.outputs.architecture }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
- name: Determine target architecture
id: set-arch
# If any packages define architecture as other than 'all'
# then it can't be compiled on host architecture
run: |
architecture=$HOST_COMPILE
if grep '^Architecture:' debian/control | grep -q -v 'all'; then
architecture=$X_COMPILE
fi
echo "Building for $architecture"
echo "architecture=$architecture">>$GITHUB_OUTPUT
check-distro:
runs-on: ubuntu-20.04
outputs:
distros: ${{ steps.set-distros.outputs.distros }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Determine build distro
id: set-distros
run: |
distros="\"distro\":[\"bookworm\", \"bullseye\"]"
# if bullseye branch exists, build for bookworm only
if git branch -r | grep -Eq "origin/bullseye$"; then
distros="\"distro\":[\"bookworm\"]"
fi
# if pull request to bullseye branch or current branch is bullseye, build only for bullseye
if [ $(echo ${{ github.head_ref }} | grep -qE "bullseye$") ] || [ ${{ github.ref }} = 'refs/heads/bullseye' ]; then
distros="\"distro\":[\"bullseye\"]"
fi
echo "Building for $distros"
echo "distros=$distros">>$GITHUB_OUTPUT
set-build-matrix:
needs: [check-distro, check-architecture]
runs-on: ubuntu-20.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Determine build matrix
id: set-matrix
run: |
matrix='{${{needs.check-distro.outputs.distros}}, ${{needs.check-architecture.outputs.architecture}}}'
echo "Building for $matrix"
echo "matrix=$matrix">>$GITHUB_OUTPUT
build-debian-package:
runs-on: ubuntu-20.04
needs: set-build-matrix
strategy:
fail-fast: false
matrix: ${{fromJSON(needs.set-build-matrix.outputs.matrix)}}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: true
- id: version
uses: docker://lpenz/ghaction-version-gen:0.11.0
- name: Add changelog entry for latest snapshot version
uses: pi-top/git-debian-changelog-bump-action@master
with:
release: false
author_name: ${{ env.CHANGELOG_AUTHOR_NAME }}
author_email: ${{ env.CHANGELOG_AUTHOR_EMAIL }}
snapshot_number: ${{ steps.version.outputs.distance }}
since: ${{ steps.version.outputs.tag_latest }}
- name: Patch lintian-overrides
if: matrix.distro == 'bullseye'
run:
cp -r debian/bullseye-overrides/* debian/ || true
- name: Build Debian package
uses: pi-top/debian-package-build-action@master
with:
# https://github.com/pi-top/debian-package-build-action/pull/19
# lintian_check_changelog_spelling: false
target_architecture: ${{ matrix.architecture }}
docker_image: ${{ env.DEB_BUILD_DOCKER_IMAGE }}:${{ matrix.distro }}-${{ env.DEB_BUILD_DOCKER_BRANCH }}
signing_key: ${{ secrets.DEB_SIGNING_GPG_KEY }}
signing_passphrase: ${{ secrets.DEB_SIGNING_GPG_PASSPHRASE }}
build_directory: ./artifacts
LINTIAN_SHOW_OVERRIDES: 0
# Optional, repo-specific build environment variables
additional_env: |
DATA="${{ secrets.DATA }}"
TLS_KEY="${{ secrets.CERT_PRIVATE_KEY }}"
PYTHON_PACKAGE_VERSION="${{ steps.version.outputs.tag_latest_ltrimv }}"
- name: Generate artifact name
run: |
echo "ARTIFACT_PREFIX=$(basename -s .dsc "$(find . -name "*.dsc")")" >> $GITHUB_ENV
- name: Upload binary package artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.distro }}-${{ env.ARTIFACT_PREFIX }}.deb
path: ./artifacts/*.deb
- name: Upload source package artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.distro }}-${{ env.ARTIFACT_PREFIX }}.deb-src
path: ./artifacts/*.tar.xz
- name: Upload package build metadata artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_PREFIX }}.metadata
path: |
./artifacts/**
!./artifacts/*.deb
!./artifacts/*.tar.xz
- name: Upload .dsc to PackageCloud
uses: pi-top/ghaction-packagecloud@main
# Only 1 .dsc is required for source so take armhf if there's multiple
if: |
(
(
github.ref == 'refs/heads/master' ||
github.ref == 'refs/heads/bullseye'
) &&
(
matrix.architecture == 'amd64' ||
matrix.architecture == 'armhf'
)
)
with:
repository: ${{ env.PACKAGECLOUD_REPO }}/${{ env.OS }}/${{ matrix.distro }}
files: |
./artifacts/*.dsc
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
- name: Upload .deb to PackageCloud
uses: pi-top/ghaction-packagecloud@main
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bullseye'
with:
repository: ${{ env.PACKAGECLOUD_REPO }}/${{ env.OS }}/${{ matrix.distro }}
files: |
./artifacts/*.deb
env:
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}