Skip to content

Commit cb1942c

Browse files
committed
ign with multiple keys: import three keys at once
1 parent c216a42 commit cb1942c

File tree

1 file changed

+84
-37
lines changed

1 file changed

+84
-37
lines changed

.github/workflows/pack-debian.yml

Lines changed: 84 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,32 @@ on:
3636
type: string
3737

3838
secrets:
39-
GPG_PRIVATE_KEY:
40-
required: true
41-
PASSPHRASE:
42-
required: true
43-
SSH_KEY_TORRENTS:
39+
PRIMARY_KEY:
40+
required: false
41+
PRIMARY_PASS:
42+
required: false
43+
SECONDARY_KEY:
44+
required: false
45+
SECONDARY_PASS:
46+
required: false
47+
TERTIARY_KEY:
4448
required: false
45-
KNOWN_HOSTS_UPLOAD:
49+
TERTIARY_PASS:
4650
required: false
4751

52+
env:
53+
PRIMARY_KEY: ${{ secrets.PRIMARY_KEY }}
54+
PRIMARY_PASS: ${{ secrets.PRIMARY_PASS }}
55+
SECONDARY_KEY: ${{ secrets.SECONDARY_KEY }}
56+
SECONDARY_PASS: ${{ secrets.SECONDARY_PASS }}
57+
TERTIARY_KEY: ${{ secrets.TERTIARY_KEY }}
58+
TERTIARY_PASS: ${{ secrets.TERTIARY_PASS }}
59+
4860
jobs:
4961

5062
prepare:
63+
name: Prepare releases
64+
if: ${{ github.repository_owner == 'Armbian' }}
5165
runs-on: ubuntu-latest
5266
outputs:
5367
matrix: ${{ steps.prep.outputs.matrix }}
@@ -59,6 +73,8 @@ jobs:
5973
echo "matrix=[\"${{ inputs.matrix }}\"]" >> "$GITHUB_OUTPUT"
6074
6175
build:
76+
name: Build Debian packages
77+
if: ${{ github.repository_owner == 'Armbian' }}
6278
needs: [ prepare ]
6379
runs-on: ubuntu-latest
6480
outputs:
@@ -150,15 +166,17 @@ jobs:
150166
path: output/*.tar.gz
151167

152168
release:
169+
name: Generate repository
170+
if: ${{ github.repository_owner == 'Armbian' }}
153171
needs: [ prepare, build ]
154-
if: "${{ always() }}"
155172
runs-on: ubuntu-latest
156173
steps:
157174

158-
- name: Install dependencies
159-
run: |
160-
echo 'man-db man-db/auto-update boolean false' | sudo debconf-set-selections
161-
sudo apt-get -q -y install reprepro
175+
- name: "Install dependencies"
176+
uses: awalsh128/cache-apt-pkgs-action@latest
177+
with:
178+
packages: reprepro
179+
version: 1.0
162180

163181
- uses: actions/download-artifact@v4
164182
name: Download deb artifacts
@@ -178,23 +196,42 @@ jobs:
178196
path: repository
179197
ref: repository
180198

181-
- name: Import GPG key
182-
id: import_gpg
199+
- name: Import PRIMARY GPG key
200+
id: import_gpg_primary
201+
if: env.PRIMARY_KEY != ''
183202
uses: crazy-max/ghaction-import-gpg@v6
184203
with:
185-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
186-
passphrase: ${{ secrets.PASSPHRASE }}
187-
188-
- name: Configure git identity
189-
working-directory: repository
190-
run: |
204+
gpg_private_key: ${{ secrets.PRIMARY_KEY }}
205+
passphrase: ${{ secrets.PRIMARY_PASS || '' }}
191206

192-
echo "Testing signing" | gpg --sign --armor
207+
- name: Import SECONDARY GPG key
208+
id: import_gpg_secondary
209+
if: env.SECONDARY_KEY != ''
210+
uses: crazy-max/ghaction-import-gpg@v6
211+
with:
212+
gpg_private_key: ${{ secrets.SECONDARY_KEY }}
213+
passphrase: ${{ secrets.SECONDARY_PASS || '' }}
193214

194-
gpg -K
195-
echo "#"
196-
git config user.name github-actions
197-
git config user.email [email protected]
215+
- name: Import TERTIARY GPG key
216+
id: import_gpg_tertiary
217+
if: env.TERTIARY_KEY != ''
218+
uses: crazy-max/ghaction-import-gpg@v6
219+
with:
220+
gpg_private_key: ${{ secrets.TERTIARY_KEY }}
221+
passphrase: ${{ secrets.TERTIARY_PASS || '' }}
222+
223+
- name: Generate GPG_PARAMETERS array
224+
id: build_gpg_parameters
225+
env:
226+
FPR_PRIMARY: ${{ steps.import_gpg_primary.outputs.fingerprint }}
227+
FPR_SECONDARY: ${{ steps.import_gpg_secondary.outputs.fingerprint }}
228+
FPR_TERTIARY: ${{ steps.import_gpg_tertiary.outputs.fingerprint }}
229+
run: |
230+
GPG_PARAMETERS="--yes --armor"
231+
[ -n "$FPR_PRIMARY" ] && GPG_PARAMETERS+=" -u $FPR_PRIMARY"
232+
[ -n "$FPR_SECONDARY" ] && GPG_PARAMETERS+=" -u $FPR_SECONDARY"
233+
[ -n "$FPR_TERTIARY" ] && GPG_PARAMETERS+=" -u $FPR_TERTIARY"
234+
echo "GPG_PARAMETERS=$GPG_PARAMETERS" >> "$GITHUB_ENV"
198235
199236
- name: Deploy packages
200237
run: |
@@ -214,35 +251,45 @@ jobs:
214251
Architectures: amd64 arm64 armhf riscv64
215252
Components: main
216253
Description: Armbian development repo
217-
SignWith: DF00FAF1C577104B50BF1D0093D6889F9F0E78D5
218254
EOD
219255
220256
# Determine a list of binary debs to include in the repo
221257
# reprepro does not accept identical package(-names) with different contents (sha1)
222258
# our build does generate different contents (in different runs) and I'd like to keep old versions around
223259
LIST_DEBS_NEW=""
224260
for ONE_DEB in ${PACKAGES_DIR}/*.deb; do
225-
echo "Considering adding to repo: $ONE_DEB"
226-
BASE_ONE_DEB=$(basename ${ONE_DEB})
227-
EXISTING_DEB_IN_REPO=$(find ${REPO_DIR}/pool -type f -name ${BASE_ONE_DEB})
228-
if [[ "a${EXISTING_DEB_IN_REPO}" == "a" ]]; then
229-
echo "- New .deb to include in repo: ${BASE_ONE_DEB}"
230-
LIST_DEBS_NEW="${LIST_DEBS_NEW} ${ONE_DEB}"
231-
else
232-
echo "- Existing .deb: ${BASE_ONE_DEB}"
233-
fi
261+
echo "Considering adding to repo: $ONE_DEB"
262+
BASE_ONE_DEB=$(basename ${ONE_DEB})
263+
EXISTING_DEB_IN_REPO=$(find ${REPO_DIR}/pool -type f -name ${BASE_ONE_DEB})
264+
if [[ "a${EXISTING_DEB_IN_REPO}" == "a" ]]; then
265+
echo "- New .deb to include in repo: ${BASE_ONE_DEB}"
266+
LIST_DEBS_NEW="${LIST_DEBS_NEW} ${ONE_DEB}"
267+
else
268+
echo "- Existing .deb: ${BASE_ONE_DEB}"
269+
fi
234270
done
235271
236272
echo "** Final list of DEBs to include: ${LIST_DEBS_NEW}"
237273
if [[ "a${LIST_DEBS_NEW}a" == "aa" ]]; then
238274
echo "No new packages, nothing to do."
239275
else
240-
echo "New packages, running reprepro..."
241-
reprepro -b "${REPO_DIR}" includedeb stable ${LIST_DEBS_NEW}
242-
echo "Repository generated at ${REPO_DIR}/"
276+
echo "New packages, running reprepro..."
277+
reprepro -b "${REPO_DIR}" includedeb stable ${LIST_DEBS_NEW}
278+
echo "Repository generated at ${REPO_DIR}/"
243279
fi
244280
281+
echo "Sign repo with multiple keys"
282+
for i in ${REPO_DIR}/dists/*/Release
283+
do
284+
DISTRO_PATH="$(dirname "$i")"
285+
echo $DISTRO_PATH
286+
gpg ${{ env.GPG_PARAMETERS }} --clear-sign -o "$DISTRO_PATH/InRelease" "$i"
287+
gpg ${{ env.GPG_PARAMETERS }} --detach-sign -o "$DISTRO_PATH/Release.gpg" "$i"
288+
done
289+
245290
cd ${REPO_DIR}
291+
git config user.name "github-actions"
292+
git config user.email "[email protected]"
246293
git add .
247294
git commit -m "Updating repo" || true
248295
git push origin repository || true

0 commit comments

Comments
 (0)