-
Notifications
You must be signed in to change notification settings - Fork 1
157 lines (136 loc) · 7.3 KB
/
create_dpkg.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
name: Create Debian packages
on:
workflow_dispatch:
inputs:
raspbian-buster-armhf:
type: boolean
raspbian-bullseye-armhf:
type: boolean
raspbian-bookworm-armhf:
type: boolean
raspberrypi-bullseye-arm64:
type: boolean
raspberrypi-bookworm-arm64:
type: boolean
debian-bullseye-amd64:
type: boolean
debian-bookworm-amd64:
type: boolean
schedule:
# Rebuild once a month. Could be 0 0 1, but Github servers are probably
# quite busy at that time.
- cron: '7 7 24 * *'
# Use FLAGS to only build sources for one of the packages. The below could also
# be imported from files, but that would add a checkout step, plus makes it more
# important to support multiline json as per:
# https://github.community/t/set-output-truncates-multiline-strings/16852
env:
raspbian-buster-armhf: '{"image":"raspbian-buster-armhf","OS":"raspbian","DIST":"buster","ARCH":"armhf","FLAGS":""}'
raspbian-bullseye-armhf: '{"image":"raspbian-bullseye-armhf","OS":"raspbian","DIST":"bullseye","ARCH":"armhf","FLAGS":"-- --binary-arch"}'
raspbian-bookworm-armhf: '{"image":"raspbian-bookworm-armhf","OS":"raspbian","DIST":"bookworm","ARCH":"armhf","FLAGS":"-- --binary-arch"}'
raspberrypi-bullseye-arm64: '{"image":"raspberrypi-bullseye-arm64","OS":"raspberrypi","DIST":"bullseye","ARCH":"arm64","FLAGS":"-- --binary-arch"}'
raspberrypi-bookworm-arm64: '{"image":"raspberrypi-bookworm-arm64","OS":"raspberrypi","DIST":"bookworm","ARCH":"arm64","FLAGS":"-- --binary-arch"}'
debian-bullseye-amd64: '{"image":"debian-bullseye-amd64","OS":"debian","DIST":"bullseye","ARCH":"amd64","FLAGS":"-- --binary-arch"}'
debian-bookworm-amd64: '{"image":"debian-bookworm-amd64","OS":"debian","DIST":"bookworm","ARCH":"amd64","FLAGS":"-- --binary-arch"}'
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
env:
PKGCONF: pkgconf
BUILD_raspbian-buster-armhf: ${{ github.event.inputs.raspbian-buster-armhf || 'true' }}
BUILD_raspbian-bullseye-armhf: ${{ github.event.inputs.raspbian-bullseye-armhf || 'true' }}
BUILD_raspbian-bookworm-armhf: ${{ github.event.inputs.raspbian-bookworm-armhf || 'true' }}
BUILD_raspberrypi-bullseye-arm64: ${{ github.event.inputs.raspberrypi-bullseye-arm64 || 'true' }}
BUILD_raspberrypi-bookworm-arm64: ${{ github.event.inputs.raspberrypi-bookworm-arm64 || 'true' }}
BUILD_debian-bullseye-amd64: ${{ github.event.inputs.debian-bullseye-amd64 || 'true' }}
BUILD_debian-bookworm-amd64: ${{ github.event.inputs.debian-bookworm-amd64 || 'true' }}
steps:
- name: Add raspbian-buster-armhf
if: ${{ env.BUILD_raspbian-buster-armhf == 'true' }}
run: echo -n '${{ env.raspbian-buster-armhf }},' >> $PKGCONF
- name: Add raspbian-bullseye-armhf
if: ${{ env.BUILD_raspbian-bullseye-armhf == 'true' }}
run: echo -n '${{ env.raspbian-bullseye-armhf }},' >> $PKGCONF
- name: Add raspbian-bookworm-armhf
if: ${{ env.BUILD_raspbian-bookworm-armhf == 'true' }}
run: echo -n '${{ env.raspbian-bookworm-armhf }},' >> $PKGCONF
- name: Add raspberrypi-bullseye-arm64
if: ${{ env.BUILD_raspberrypi-bullseye-arm64 == 'true' }}
run: echo -n '${{ env.raspberrypi-bullseye-arm64 }},' >> $PKGCONF
- name: Add raspberrypi-bookworm-arm64
if: ${{ env.BUILD_raspberrypi-bookworm-arm64 == 'true' }}
run: echo -n '${{ env.raspberrypi-bookworm-arm64 }},' >> $PKGCONF
- name: Add debian-bullseye-amd64
if: ${{ env.BUILD_debian-bullseye-amd64 == 'true' }}
run: echo -n '${{ env.debian-bullseye-amd64 }},' >> $PKGCONF
- name: Add debian-bookworm-amd64
if: ${{ env.BUILD_debian-bookworm-amd64 == 'true' }}
run: echo -n '${{ env.debian-bookworm-amd64 }},' >> $PKGCONF
- name: Set matrix
id: set-matrix
run: |
test -f $PKGCONF || { echo "No packages selected"; exit 1; }
echo -e "`cat $PKGCONF`\n"
echo "matrix={\"include\":[`cat $PKGCONF`]}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- name: Load package info into environment
run: |
cat ./pkginfo >> $GITHUB_ENV
- name: Prepare directories
run: |
mkdir dl
mkdir build_dir
mkdir cache
# dh-make and devscripts are only used for the package build
- name: Install pbuilder, Debian tools, keyrings
run: |
sudo apt-get update
sudo apt-get install -yq pbuilder qemu-user-static debian-archive-keyring devscripts dh-make
wget -O dl/raspbian-archive-keyring.deb http://archive.raspbian.org/raspbian/pool/main/r/raspbian-archive-keyring/raspbian-archive-keyring_20120528.2_all.deb
sudo dpkg -i dl/raspbian-archive-keyring.deb
wget -O dl/raspberrypi-archive-keyring.deb http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-archive-keyring/raspberrypi-archive-keyring_2016.10.31_all.deb
sudo dpkg -i dl/raspberrypi-archive-keyring.deb
- name: Cache pbuilder image
id: cache-image
uses: actions/cache@v3
with:
path: cache/${{ matrix.image }}-base.tgz
key: ${{ matrix.image }}
- name: Restore image from cache
if: steps.cache-image.outputs.cache-hit == 'true'
run: |
sudo cp cache/${{ matrix.image }}-base.tgz /var/cache/pbuilder/
- name: Or create pbuilder image
if: steps.cache-image.outputs.cache-hit != 'true'
run: |
sudo OS=${{ matrix.OS }} DIST=${{ matrix.DIST }} ARCH=${{ matrix.ARCH }} pbuilder create --configfile pbuilderrc
cp /var/cache/pbuilder/${{ matrix.image }}-base.tgz cache/
- name: Download and unpack OwnTone
run: |
wget -O build_dir/${{ env.PKGNAME }}_${{ env.VER }}.orig.tar.gz https://github.com/${{ env.OWNER }}/${{ env.REPOSITORY }}/archive/${{ env.COMMIT }}.tar.gz
tar xzf build_dir/${{ env.PKGNAME }}_${{ env.VER }}.orig.tar.gz --directory build_dir
mv build_dir/${{ env.REPOSITORY }}-$COMMIT build_dir/${{ env.PKGNAME }}-${{ env.VER }}
cp -a ${{ env.REPOSITORY }}/debian build_dir/${{ env.PKGNAME }}-${{ env.VER }}
# The below uses a method of creating changelog and setting versions that
# isn't very kosher. I don't know how to use the proper method while still
# creating different packages for different distributions that can be
# served from one repo.
- name: Build OwnTone package
working-directory: build_dir/${{ env.PKGNAME }}-${{ env.VER }}
run: |
dch --create --package ${{ env.PKGNAME }} --newversion ${{ env.VER }}-${{ env.DEB }}+${{ matrix.DIST }} --distribution ${{ matrix.DIST }} --force-distribution "Dummy changelog @commit ${{ env.COMMIT }}"
sudo OS=${{ matrix.OS }} DIST=${{ matrix.DIST }} ARCH=${{ matrix.ARCH }} DEB_BUILD_OPTIONS="parallel=$(nproc) nocheck" pdebuild --configfile ../../pbuilderrc ${{ matrix.FLAGS }}
rm debian/changelog
- name: Upload dpkg
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.image }}
path: /var/cache/pbuilder/result/${{ matrix.image }}