-
Notifications
You must be signed in to change notification settings - Fork 6
260 lines (250 loc) · 11.1 KB
/
build-deb-v4.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: Debian Package Builder v4
on:
workflow_dispatch:
concurrency:
group: debian_builder_v4
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.host-os }}
strategy:
matrix:
stage: [experimental, unstable, testing ] #release-3_2, release-3_1, release-3_0, release-2_2, release-2_1]
distro-codename: [
ubuntu-jammy-amd64,
ubuntu-jammy-arm64,
ubuntu-noble-amd64,
ubuntu-noble-arm64,
ubuntu-oracular-amd64,
ubuntu-oracular-arm64,
debian-bookworm-amd64,
debian-bookworm-arm64,
debian-testing-amd64,
debian-testing-arm64
]
exclude:
- stage: release-3_2
distro-codename: debian-testing-amd64 # debian testing is never released
- stage: release-3_2
distro-codename: debian-testing-arm64 # debian testing is never released
- stage: release-3_2
distro-codename: ubuntu-oracular-amd64 # 3.2 released before oracular
- stage: release-3_2
distro-codename: ubuntu-oracular-arm64
include:
- distro-codename: ubuntu-jammy-amd64
host-os: ubuntu-22.04
arch: amd64
distro: ubuntu
codename: jammy
- distro-codename: ubuntu-jammy-arm64
host-os: [self-hosted, Linux, arm64, jammy]
arch: arm64
distro: ubuntu
codename: jammy
- distro-codename: ubuntu-noble-amd64
host-os: [self-hosted, Linux, X64, noble]
arch: amd64
distro: ubuntu
codename: noble
- distro-codename: ubuntu-noble-arm64
host-os: [self-hosted, Linux, arm64, noble]
arch: arm64
distro: ubuntu
codename: noble
- distro-codename: ubuntu-oracular-amd64
host-os: [self-hosted, Linux, X64, oracular]
arch: amd64
distro: ubuntu
codename: oracular
- distro-codename: ubuntu-oracular-arm64
host-os: [self-hosted, Linux, arm64, oracular]
arch: arm64
distro: ubuntu
codename: oracular
- distro-codename: debian-bookworm-amd64
host-os: [self-hosted, Linux, X64, bookworm]
arch: amd64
distro: debian
codename: bookworm
- distro-codename: debian-bookworm-arm64
host-os: [self-hosted, Linux, arm64, bookworm]
arch: arm64
distro: debian
codename: bookworm
- distro-codename: debian-testing-amd64
host-os: [self-hosted, Linux, X64, testing]
arch: amd64
distro: debian
codename: testing
- distro-codename: debian-testing-arm64
host-os: [self-hosted, Linux, arm64, testing]
arch: arm64
distro: debian
codename: testing
steps:
- uses: actions/checkout@v4
- name: Set Job Parameters
id: init
run: |
echo "SIGNING_KEY_ID=C91ECAB862037F9474087DBC7107DED133505B88" >> $GITHUB_OUTPUT
echo "MANIFEST_PATH=${{ github.workspace }}/manifests" >> $GITHUB_OUTPUT
echo "PKG_REPO_PATH=${{ github.workspace }}/repo" >> $GITHUB_OUTPUT
echo "PKG_BUILD_DIR=${{ github.workspace }}/packages" >> $GITHUB_OUTPUT
echo "GH_REPO_ROOT=${{ github.workspace }}" >> $GITHUB_OUTPUT
echo "stage=${{ matrix.stage }}" >> $GITHUB_OUTPUT
echo "distro=${{ matrix.distro }}" >> $GITHUB_OUTPUT
echo "codename=${{ matrix.codename }}" >> $GITHUB_OUTPUT
echo "arch=${{ matrix.arch }}" >> $GITHUB_OUTPUT
echo "target=${{ matrix.stage }}-${{ matrix.distro }}-${{ matrix.codename }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
echo "repo_url=https://regolith-desktop.org/${{ matrix.stage }}-${{ matrix.distro }}-${{ matrix.codename }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
- name: Env setup
run: |
set -e
mkdir ${{ steps.init.outputs.MANIFEST_PATH }} || true
mkdir ${{ steps.init.outputs.PKG_BUILD_DIR }} || true
# Following allows for internal dependencies
# FIXME(kgilmer): extract following logic to distro specific script
rm /tmp/manifest.txt || true
wget -P /tmp "https://regolith-desktop.org/${{ steps.init.outputs.target }}/manifest.txt" || true
if [ -f /tmp/manifest.txt ]; then
echo "Adding repo to apt: ${{ steps.init.outputs.target }}"
rm /tmp/manifest.txt
wget -qO - https://regolith-desktop.org/regolith3.key | sudo apt-key add -
echo deb "[arch=${{ steps.init.outputs.arch }}] ${{ steps.init.outputs.repo_url }} ${{ steps.init.outputs.codename }} main" | sudo tee /etc/apt/sources.list.d/regolith.list
fi
if [ -f "/etc/apt/sources.list.d/regolith-local.list" ]; then
sudo rm /etc/apt/sources.list.d/regolith-local.list
echo "Cleaned up temp apt repo"
fi
sudo apt update
DEBIAN_FRONTEND=noninteractive sudo apt install -y --no-install-recommends jq git devscripts reprepro wget dput
- name: Pull Manifest
run: |
set -e
wget -P "${{ steps.init.outputs.PKG_REPO_PATH }}" "https://regolith-desktop.org/${{ steps.init.outputs.target }}/manifest.txt" || true
echo "Previous manifest:"
cat ${{ steps.init.outputs.PKG_REPO_PATH }}/manifest.txt || true
- name: Check for changes
id: changes
run: |
set -e
set -x
CHANGE_OUTPUT=$(${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/main.sh \
${{ steps.init.outputs.GH_REPO_ROOT }} \
${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-debian.sh \
"${{ steps.init.outputs.stage }}" \
"${{ steps.init.outputs.distro }}" \
"${{ steps.init.outputs.codename }}" \
"${{ steps.init.outputs.arch }}" \
"unneeded to check change" \
"unneeded to check change" \
check \
${{ steps.init.outputs.MANIFEST_PATH }} \
${{ steps.init.outputs.PKG_REPO_PATH }} \
${{ steps.init.outputs.PKG_BUILD_DIR }} | tail -n1)
if [ "$CHANGE_OUTPUT" == "No package changes found, exiting." ]; then
echo "changed=0" >> $GITHUB_OUTPUT
echo "No package changes to build"
else
echo "changed=1" >> $GITHUB_OUTPUT
echo "New Manifest: "
cat ${{ steps.init.outputs.MANIFEST_PATH }}/next-manifest.txt
fi
- uses: webfactory/ssh-agent@v0.9.0
if: steps.changes.outputs.changed == 1
with:
ssh-private-key: ${{ secrets.KAMATERA_SSH_KEY }}
- name: Pull repo
if: steps.changes.outputs.changed == 1
run: |
set -e
set -x
ssh-keyscan -H ${{ secrets.KAMATERA_HOSTNAME }} >> ~/.ssh/known_hosts
scp -r root@${{ secrets.KAMATERA_HOSTNAME }}:/var/www/html/${{ steps.init.outputs.target }}/* "${{ steps.init.outputs.PKG_REPO_PATH }}" || true
if [ ! -d ${{ steps.init.outputs.PKG_REPO_PATH }} ]; then
mkdir -p "${{ steps.init.outputs.PKG_REPO_PATH }}"
fi
- name: Build
if: steps.changes.outputs.changed == 1
run: |
set -e
export DEBEMAIL="regolith.linux@gmail.com"
export DEBFULLNAME="Regolith Linux"
export DEBIAN_FRONTEND=noninteractive
mkdir -p ~/.gnupg/
printf "${{ secrets.PACKAGE_PRIVATE_KEY2 }}" | base64 --decode > ~/.gnupg/private.key
gpg --batch --import ~/.gnupg/private.key
${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/main.sh \
${{ steps.init.outputs.GH_REPO_ROOT }} \
${{ steps.init.outputs.GH_REPO_ROOT }}/.github/scripts/ext-debian.sh \
"${{ steps.init.outputs.stage }}" \
"${{ steps.init.outputs.distro }}" \
"${{ steps.init.outputs.codename }}" \
"${{ steps.init.outputs.arch }}" \
"${{ steps.init.outputs.repo_url }}" \
"${{ steps.init.outputs.SIGNING_KEY_ID }}" \
build \
${{ steps.init.outputs.MANIFEST_PATH }} \
${{ steps.init.outputs.PKG_REPO_PATH }} \
${{ steps.init.outputs.PKG_BUILD_DIR }} | tee -a ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt
if [ -f ${{ steps.init.outputs.MANIFEST_PATH }}/next-manifest.txt ]; then
echo "Temp manifest not deleted by main.sh, build aborted/failed."
echo "changed=0" >> $GITHUB_OUTPUT
exit 1
else
cat ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.raw.txt | grep ^CHLOG: | cut -c 7- > ${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.txt
fi
- name: Deploy via rsync
if: steps.changes.outputs.changed == 1
run: |
set -e
set -x
for i in 1 2 3 4 5; do echo "Attempt $i" && rsync -avzh ${{ steps.init.outputs.PKG_REPO_PATH }}/* root@${{ secrets.KAMATERA_HOSTNAME }}:/var/www/html/${{ steps.init.outputs.target }} && break || sleep 5; done
- name: Log Build Output
if: steps.changes.outputs.changed == 1
run: |
cat ${{ steps.init.outputs.PKG_REPO_PATH }}/manifest.txt || true
echo "PKG_BUILD_DIR:"
find ${{ steps.init.outputs.PKG_BUILD_DIR }}
- name: Cleanup
run: |
# FIXME(kgilmer) extract following logic to distro-specific script
# Remove regolith repo from build system apt config
if [ -f /etc/apt/sources.list.d/regolith.list ]; then
sudo rm -f /etc/apt/sources.list.d/regolith.list
fi
- uses: actions/upload-artifact@v4
if: steps.changes.outputs.changed == 1
with:
name: CHANGELOG_${{ steps.init.outputs.target }}
path: |
${{ steps.init.outputs.GH_REPO_ROOT }}/CHANGELOG_${{ steps.init.outputs.target }}.txt
test:
needs: build
uses: ./.github/workflows/test-desktop-installable2.yml
generate-release:
needs: build
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v4
- name: Concat Release Notes
id: release-setup
run: |
set -e
echo "TIMESTAMP=$(date +%Y%m%d_%H%M%S)" >> $GITHUB_OUTPUT
FILES=$(find . -name CHANGELOG\*)
if [ -n "$FILES" ]; then
cat CHANGELOG_*/CHANGELOG_*.txt >> CHANGELOG.txt
echo "changed=1" >> $GITHUB_OUTPUT
else
echo "changed=0" >> $GITHUB_OUTPUT
fi
- uses: softprops/action-gh-release@v2
if: steps.release-setup.outputs.changed == 1
with:
body: See CHANGELOG.txt for updates and manifests for current state of repos.
name: Package Build ${{ steps.release-setup.outputs.TIMESTAMP }}
tag_name: pkgbuild-${{ steps.release-setup.outputs.TIMESTAMP }}
files: |
*.txt