-
-
Notifications
You must be signed in to change notification settings - Fork 387
187 lines (164 loc) · 6.74 KB
/
nightly.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: Nightly build
# Create nightly builds at the end of every day
on:
schedule:
- cron: '0 0 * * *'
repository_dispatch:
types: [hyperion_nightly_push]
jobs:
update:
name: Update Submodule rpi_ws281x
if: github.repository_owner == 'hyperion-project'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
submodules: recursive
- name: Update Submodule rpi_ws281x
id: update
run: git submodule update --remote --recursive dependencies/external/rpi_ws281x
- name: Check git status
id: status
run: echo "status=$(git status -s)" >> $GITHUB_OUTPUT
- name: Add and commit changes
if: ${{ steps.status.outputs.status }}
run: |
git config --local user.email "[email protected]"
git config --local user.name "Hyperion-Bot"
git config --local diff.ignoreSubmodules dirty
git commit -am "Update submodule rpi_ws281x"
- name: Push changes
if: ${{ steps.status.outputs.status }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.HYPERION_BOT_TOKEN }}
branch: ${{ github.ref }}
check:
name: Compare local <-> nightly
needs: [update]
if: github.repository_owner == 'hyperion-project'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check if commit has changed
id: build-necessary
run: |
if wget --spider "https://nightly.apt.hyperion-project.org/$(git rev-parse --short HEAD)" 2>/dev/null; then
echo "commit-has-changed=false" >> $GITHUB_OUTPUT
else
echo "commit-has-changed=true" >> $GITHUB_OUTPUT
fi
outputs:
build-nightly: ${{ steps.build-necessary.outputs.commit-has-changed }}
setup:
name: Setup nightly build
needs: [check]
if: ${{ needs.check.outputs.build-nightly == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set nightly matrix
id: nightly-ppa
run: |
NIGHTLY=$(jq -n '.include |= [ inputs[] | select(.["exclude"] != true)]' .github/workflows/apt/*.json --compact-output)
echo "nightly=$NIGHTLY" >> $GITHUB_OUTPUT
outputs:
nightly-matrix: ${{ steps.nightly-ppa.outputs.nightly }}
build:
name: ${{ matrix.description }}
needs: [setup]
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.setup.outputs.nightly-matrix) }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Generate environment variables
run: |
echo "$(tr -d '\n' < .version)+nightly$(date '+%Y%m%d')$(git rev-parse --short HEAD)" > .version
VERSION=$(cat .version)
echo VERSION=${VERSION} >> $GITHUB_ENV
if [[ $VERSION == *"-"* ]]; then
echo STANDARDS_VERSION=$(echo ${VERSION%-*}) >> $GITHUB_ENV
echo TARBALL_VERSION=$(echo ${VERSION%-*}) >> $GITHUB_ENV
echo DEBIAN_FORMAT='3.0 (quilt)' >> $GITHUB_ENV
else
echo STANDARDS_VERSION=$(echo ${VERSION%+*}) >> $GITHUB_ENV
echo TARBALL_VERSION=${VERSION}~$(echo ${{ matrix.distribution }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
echo DEBIAN_FORMAT='3.0 (native)' >> $GITHUB_ENV
fi
echo DISTRIBUTION=$(echo ${{ matrix.distribution }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
- name: Build package
shell: bash
run: |
mkdir -p "${GITHUB_WORKSPACE}/deploy"
docker run --rm \
-v "${GITHUB_WORKSPACE}/deploy:/deploy" \
-v "${GITHUB_WORKSPACE}:/source:rw" \
ghcr.io/hyperion-project/${{ matrix.architecture }}:${{ env.DISTRIBUTION }} \
/bin/bash -c "cd /source && \
mkdir -p debian/source && echo '${{ env.DEBIAN_FORMAT }}' > debian/source/format && \
dch --create --distribution ${{ env.DISTRIBUTION }} --package 'hyperion' -v '${{ env.VERSION }}~${{ env.DISTRIBUTION }}' '${{ github.event.commits[0].message }}' && \
cp -fr LICENSE debian/copyright && \
sed 's/@BUILD_DEPENDS@/${{ matrix.build-depends }}/g; s/@DEPENDS@/${{ matrix.package-depends }}/g; s/@ARCHITECTURE@/${{ matrix.architecture }}/g; s/@STANDARDS_VERSION@/${{ env.STANDARDS_VERSION }}/g' debian/control.in > debian/control && \
sed 's/@CMAKE_ENVIRONMENT@/${{ matrix.cmake-environment }}/g' debian/rules.in > debian/rules && \
tar -cJf ../hyperion_${{ env.TARBALL_VERSION }}.orig.tar.xz . && \
debuild --no-lintian -uc -us && \
cp ../hyperion_*.deb /deploy"
- name: Upload package artifact
uses: actions/upload-artifact@v3
with:
path: deploy
retention-days: 1
publish:
name: Publish nightly packages
needs: [setup, build]
if: github.repository_owner == 'hyperion-project'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Import GPG key
uses: crazy-max/[email protected]
with:
gpg_private_key: ${{ secrets.APT_GPG }}
- name: Install reprepro
run: sudo apt -y install reprepro
- name: Make build folders, export public GPG key, copy distributions file and create short sha file for nightly build check
run: |
mkdir -p nightly/{conf,dists,db}
gpg --armor --output nightly/hyperion.pub.key --export '[email protected]'
cp debian/distributions nightly/conf/distributions
touch "nightly/$(git rev-parse --short HEAD)"
- name: Create initial structure/packages files and symbolic links
run: |
reprepro -Vb nightly createsymlinks
reprepro -Vb nightly export
- name: Download artifacts
uses: actions/[email protected]
- name: Include artifacts into the package source
run: |
for file in artifact/*.deb; do
if [ -f "$file" ]; then
dist=${file#*~}
dist=${dist%_*}
reprepro -Vb nightly/ includedeb "$dist" "$file"
fi
done
- name: Upload packages to nightly server
uses: SamKirkland/[email protected]
with:
server: nightly.apt.hyperion-project.org
username: ${{ secrets.NIGHTLY_USER }}
password: ${{ secrets.NIGHTLY_PASSWORD }}
local-dir: "./nightly/"
server-dir: "./"
dangerous-clean-slate: true
- name: Remove intermediate artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: artifact
failOnError: false