Skip to content

Commit 59834bf

Browse files
authored
Fixes to publishing of DEB packages to APT repo (#124)
* Fixes to publishing of DEB packages to APT repo * Fix package name to be "stackit"
1 parent 2772c28 commit 59834bf

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

.aptly.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"rootDir": "./.aptly",
32
"downloadConcurrency": 4,
43
"downloadSpeedLimit": 0,
54
"downloadRetries": 0,

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI Workflow
1+
name: CI
22

33
on: [pull_request, workflow_dispatch]
44

.github/workflows/release.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# STACKIT CLI release workflow.
22
name: Release
33

4-
# This GitHub action creates a release when a tag that matches the pattern
5-
# "v*" (e.g. v0.1.0) is created.
4+
# This GitHub action creates a release when a tag that matches one of the patterns below
5+
# E.g. v0.1.0, v0.1.0-something.1, etc
66
on:
77
push:
88
tags:
@@ -17,6 +17,7 @@ permissions:
1717

1818
jobs:
1919
goreleaser:
20+
name: Release
2021
runs-on: macOS-latest
2122
env:
2223
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
@@ -71,5 +72,5 @@ jobs:
7172
if: contains(github.ref_name, '-') == false
7273
env:
7374
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
74-
GPG_PRIVATE_KEY_ID: ${{ steps.import_gpg.outputs.keyid }}
75+
GPG_PRIVATE_KEY_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
7576
run: ./scripts/publish-apt-packages.sh

.goreleaser.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ nfpms:
6060
# IDs of the builds for which to create packages for
6161
builds:
6262
- linux-builds
63+
package_name: stackit
6364
vendor: STACKIT
6465
homepage: https://github.com/stackitcloud/stackit-cli
6566
maintainer: STACKIT <[email protected]>

scripts/publish-apt-packages.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,32 @@ OBJECT_STORAGE_ENDPOINT="https://object.storage.eu01.onstackit.cloud"
1010
APT_BUCKET_NAME="stackit-cli-apt"
1111
PUBLIC_KEY_BUCKET_NAME="stackit-public-key"
1212
PUBLIC_KEY_FILE="key.gpg"
13-
CUSTOM_KEYRING="custom-keyring"
13+
CUSTOM_KEYRING_FILE="aptly-keyring.gpg"
14+
DISTRIBUTION="stackit"
1415
APTLY_CONFIG_FILE_PATH="./.aptly.conf"
1516
GORELEASER_PACKAGES_FOLDER="dist/"
1617

18+
# We need to disable the key database daemon (keyboxd)
19+
# This can be done by removing "use-keyboxd" from ~/.gnupg/common.conf (see https://github.com/gpg/gnupg/blob/master/README)
20+
echo -n >~/.gnupg/common.conf
21+
1722
# Create a local mirror of the current state of the remote APT repository
1823
printf ">>> Creating mirror \n"
1924
curl ${OBJECT_STORAGE_ENDPOINT}/${PUBLIC_KEY_BUCKET_NAME}/${PUBLIC_KEY_FILE} >public.asc
20-
gpg --no-default-keyring --keyring ./${CUSTOM_KEYRING}.gpg --import public.asc
21-
aptly mirror create -keyring="${CUSTOM_KEYRING}.gpg" current "${OBJECT_STORAGE_ENDPOINT}/${APT_BUCKET_NAME}" stackit
25+
gpg --no-default-keyring --keyring=${CUSTOM_KEYRING_FILE} --import public.asc
26+
aptly mirror create -config "${APTLY_CONFIG_FILE_PATH}" -keyring="${CUSTOM_KEYRING_FILE}" current "${OBJECT_STORAGE_ENDPOINT}/${APT_BUCKET_NAME}" ${DISTRIBUTION}
2227

2328
# Update the mirror to the latest state
2429
printf "\n>>> Updating mirror \n"
25-
aptly mirror update current
30+
aptly mirror update -keyring="${CUSTOM_KEYRING_FILE}" current
2631

2732
# Create a snapshot of the mirror
2833
printf "\n>>> Creating snapshop from mirror \n"
2934
aptly snapshot create current-snapshot from mirror current
3035

3136
# Create a new fresh local APT repo
3237
printf "\n>>> Creating fresh local repo \n"
33-
aptly repo create -distribution="stackit-cli" new-repo
38+
aptly repo create -distribution="${DISTRIBUTION}" new-repo
3439

3540
# Add new generated .deb packages to the new local repo
3641
printf "\n>>> Adding new packages to local repo \n"
@@ -42,8 +47,8 @@ aptly snapshot create new-snapshot from repo new-repo
4247

4348
# Merge new-snapshot into current-snapshot creating a new snapshot updated-snapshot
4449
printf "\n>>> Merging snapshots \n"
45-
aptly snapshot pull -no-remove -architectures="amd64,i386,arm64" current-snapshot new-snapshot updated-snapshot stackit
50+
aptly snapshot pull -no-remove -architectures="amd64,i386,arm64" current-snapshot new-snapshot updated-snapshot ${DISTRIBUTION}
4651

4752
# Publish the new snapshot to the remote repo
4853
printf "\n>>> Publishing updated snapshot \n"
49-
aptly publish switch -gpg-key="${GPG_PRIVATE_KEY_ID}" -passphrase "${GPG_PASSPHRASE}" -config "${APTLY_CONFIG_FILE_PATH}" stackit "s3:${APT_BUCKET_NAME}:" updated-snapshot
54+
aptly publish snapshot -keyring="${CUSTOM_KEYRING_FILE}" -gpg-key="${GPG_PRIVATE_KEY_FINGERPRINT}" -passphrase "${GPG_PASSPHRASE}" -config "${APTLY_CONFIG_FILE_PATH}" updated-snapshot "s3:${APT_BUCKET_NAME}:"

0 commit comments

Comments
 (0)