build: sign the release package and complete its metadata

This commit is contained in:
BlackAngelTV committed 2026-11-20 09:19:51 +01:00
1 parent a4fb5da5d1
commit 08986e210e
3 files changed
+97 -23

No files matched your search

+75 -19
View File
@@ -23,6 +23,10 @@ jobs:
runs-on: arch-host
env:
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
# makepkg writes the keyring it imports into; the job keeps it out of the
# checkout and removes it with the runner's temporary directory.
GNUPGHOME: ${{ runner.temp }}/gnupg
steps:
- uses: actions/checkout@v4
@@ -37,6 +41,15 @@ jobs:
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Import the package signing key
if: env.GPG_PRIVATE_KEY != ''
run: |
set -euo pipefail
mkdir -p "$GNUPGHOME"
chmod 700 "$GNUPGHOME"
printf '%s' "$GPG_PRIVATE_KEY" | base64 -d | gpg --batch --import
gpg --batch --list-secret-keys --keyid-format=long
- name: Build the Arch package
id: package
run: |
@@ -51,57 +64,100 @@ jobs:
# makepkg needs the PKGBUILD, the version file it reads and the source
# tarball in one directory; the runner's checkout stays untouched.
cd "$work"
makepkg --noconfirm --nodeps --force --cleanbuild
# The packager and the signing key live in makepkg's configuration, and
# makepkg has no command-line flag for either.
conf="$work/makepkg.conf"
cp /etc/makepkg.conf "$conf"
printf 'PACKAGER="%s"\n' 'BlackAngelTVdev <dami.scoot3@gmail.com>' >> "$conf"
sign=()
if gpg --batch --list-secret-keys 2>/dev/null | grep -q '^sec'; then
gpgkey="$(gpg --batch --with-colons --list-secret-keys \
| awk -F: '/^fpr:/{print $10; exit}')"
printf 'GPGKEY="%s"\n' "$gpgkey" >> "$conf"
sign=(--sign)
else
echo "::warning::no signing key available, releasing an unsigned package"
fi
makepkg --config "$conf" --noconfirm --nodeps --force --cleanbuild "${sign[@]}"
asset="$(ls -1 ./*.pkg.tar.zst | grep -v -- '-debug-' | head -1)"
echo "file=$work/${asset##*/}" >> "$GITHUB_OUTPUT"
echo "name=${asset##*/}" >> "$GITHUB_OUTPUT"
if [ -f "${asset}.sig" ]; then
echo "sig=$work/${asset##*/}.sig" >> "$GITHUB_OUTPUT"
fi
- name: Create the release and attach the package
- name: Verify the signature
if: steps.package.outputs.sig != ''
env:
PACKAGE_FILE: ${{ steps.package.outputs.file }}
SIGNATURE: ${{ steps.package.outputs.sig }}
run: |
set -euo pipefail
gpg --batch --verify "$SIGNATURE" "$PACKAGE_FILE"
- name: Create the release and attach the artefacts
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
PACKAGE_FILE: ${{ steps.package.outputs.file }}
PACKAGE_NAME: ${{ steps.package.outputs.name }}
SIGNATURE: ${{ steps.package.outputs.sig }}
run: |
set -euo pipefail
api="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY"
version='${{ steps.version.outputs.version }}'
tag="v$version"
name="${{ steps.package.outputs.name }}"
file="${{ steps.package.outputs.file }}"
auth="Authorization: token $GITEA_TOKEN"
release_id="$(curl -sS -H "$auth" "$api/releases/tags/$tag" | jq -r 'if type == "object" then (.id // empty) else empty end')"
if [ -z "$release_id" ]; then
body="FWS-DeskManager $version
Arch package: \`$name\`"
Arch package: \`$PACKAGE_NAME\`
Signature: \`$PACKAGE_NAME.sig\`, key \`fws-package-signing.asc\`
Verify the download with:
\`\`\`
gpg --verify $PACKAGE_NAME.sig $PACKAGE_NAME
\`\`\`"
release_id="$(curl -sS --fail-with-body -X POST -H "$auth" -H 'Content-Type: application/json' \
-d "$(jq -n --arg tag "$tag" --arg name "FWS-DeskManager $version" \
--arg body "$body" '{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')" \
"$api/releases" | jq -r '.id')"
fi
# A re-run must not fail on its own previous asset.
previous="$(curl -sS -H "$auth" "$api/releases/$release_id/assets" \
| jq -r --arg n "$name" '.[] | select(.name == $n) | .id')"
if [ -n "$previous" ]; then
curl -sS -X DELETE -H "$auth" "$api/releases/assets/$previous" -o /dev/null
fi
# A re-run must not fail on its own previous asset, so an asset with the
# same name is replaced rather than duplicated.
previous="$(curl -sS -H "$auth" "$api/releases/$release_id/assets")"
attach() {
local file="$1" name="$2" id
id="$(jq -r --arg n "$name" '.[] | select(.name == $n) | .id' <<<"$previous")"
if [ -n "$id" ]; then
curl -sS -X DELETE -H "$auth" "$api/releases/assets/$id" -o /dev/null
fi
curl -sS --fail-with-body -X POST -H "$auth" \
-F "attachment=@$file" \
"$api/releases/$release_id/assets?name=$name" -o /dev/null
echo "attached $name"
}
curl -sS --fail-with-body -X POST -H "$auth" \
-F "attachment=@$file" \
"$api/releases/$release_id/assets?name=$name" -o /dev/null
echo "attached $name to release $tag"
attach "$PACKAGE_FILE" "$PACKAGE_NAME"
if [ -n "$SIGNATURE" ]; then
attach "$SIGNATURE" "$PACKAGE_NAME.sig"
attach packaging/fws-package-signing.asc fws-package-signing.asc
fi
- name: Publish to repo.laxacube.ch
if: env.REPO_TOKEN != ''
env:
PACKAGE_FILE: ${{ steps.package.outputs.file }}
PACKAGE_NAME: ${{ steps.package.outputs.name }}
run: |
set -euo pipefail
file="${{ steps.package.outputs.file }}"
name="${{ steps.package.outputs.name }}"
curl -sS --fail-with-body -X POST https://repo.laxacube.ch/api/packages \
-H "Authorization: Bearer $REPO_TOKEN" \
-H "X-Filename: $name" \
-H "X-Filename: $PACKAGE_NAME" \
-H 'Content-Type: application/octet-stream' \
--data-binary "@$file"
--data-binary "@$PACKAGE_FILE"
echo
- name: Warn when the upload token is missing
+13 -4
View File
@@ -1,4 +1,4 @@
# Maintainer: FWS
# Maintainer: BlackAngelTVdev <dami.scoot3@gmail.com>
# The version file is the single source of truth for releases, so the package
# version follows it instead of being duplicated here.
#
@@ -8,15 +8,24 @@
pkgname=fws-deskmanager
pkgver=$(tr -d '[:space:]' < version)
pkgrel=1
pkgdesc="Switch desktop environments on Arch Linux without rebooting"
pkgdesc="Switch between installed desktop sessions without rebooting"
arch=('x86_64')
url="https://gitea.nocode-var.tech/FWS/FWS-DeskManger"
license=('unknown')
depends=('gtk4' 'systemd' 'polkit')
license=('GPL-3.0-or-later')
# loginctl, systemctl and pacman come from packages every Arch install already
# has; only the toolkit and the polkit helper are real additions.
depends=('gtk4' 'polkit')
optdepends=(
'sddm: display manager for the login screen and the one-off autologin'
'gdm: display manager for the login screen'
'lightdm: display manager for the login screen, needs dm-tool'
)
makedepends=('cmake' 'pkgconf')
# Release packages only: the debug split package has no use for end users.
options=('!debug')
source=("$pkgname-$pkgver.tar.gz")
# The tarball is produced from the commit being packaged, so there is no
# published checksum to pin here.
sha256sums=('SKIP')
build() {
+9
View File
@@ -0,0 +1,9 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEawAB3hYJKwYBBAHaRw8BAQdAFe/ubNzQiCNE+s8m9L9hE2sL4RQDFSxvsmJV
bEkNGwy0J0ZXUyBQYWNrYWdlcyAoQXJjaCBwYWNrYWdlIHNpZ25pbmcga2V5KYiQ
BBMWCgA4FiEEyHUfq4EPLOrc78rY5rPJ3q89U4sFAmsAAd4CGwMFCwkIBwIGFQoJ
CAsCBBYCAwECHgECF4AACgkQ5rPJ3q89U4sZjwEAmf5pq9/RIgeuESztQbpS4YCc
DSFqgqFdfFmyicZVnzIA/j4ztCyJR+l4iy2QV/C0vaPploQNIstsCHUidnw/gpML
=XJmF
-----END PGP PUBLIC KEY BLOCK-----