ci(release): build the package once and check that build
CI / check (push) Successful in 2m40s

The release pipeline compiled the project twice: ./dev.sh build in the check
job, then makepkg in the release job. A single job now builds with makepkg and
runs go vet, the tests and the smoke test on that tree, so publishing starts
only after the shipped build passed.

CI skips version-only pushes, which package.yml already covers, and the release
fails early when RELEASE_TOKEN is missing instead of reporting a bogus 401. The
package name no longer keeps the ./ prefix from ls, which corrupted the asset
and X-Filename names.
This commit is contained in:
BlackAngelTV committed 2026-11-25 11:05:40 +01:00
1 parent f38246f71d
commit aa1fff96b4
4 files changed
+62 -44

No files matched your search

+3
View File
@@ -7,6 +7,9 @@ on:
pull_request: pull_request:
push: push:
branches: [main] branches: [main]
# A version-only commit is released by package.yml, which runs the same
# checks on the package build; CI would build that commit a second time.
paths-ignore: [version]
workflow_dispatch: workflow_dispatch:
# A new push on the same branch supersedes the previous run, but main builds run # A new push on the same branch supersedes the previous run, but main builds run
+48 -36
View File
@@ -1,6 +1,7 @@
# Release pipeline. A change to the version file on main is the only thing that # Release pipeline. A change to the version file on main is the only thing that
# publishes: the package is built from that exact commit, attached to a Gitea # publishes: the package is built once from that exact commit, the checks run on
# release and pushed to the pacman repository at repo.laxacube.ch. # that same build, and it is attached to a Gitea release and pushed to the
# pacman repository at repo.laxacube.ch.
# #
# Required secrets: RELEASE_TOKEN (release API), REPO_TOKEN (pacman repository). # Required secrets: RELEASE_TOKEN (release API), REPO_TOKEN (pacman repository).
name: Release name: Release
@@ -21,9 +22,10 @@ concurrency:
cancel-in-progress: false cancel-in-progress: false
jobs: jobs:
# Keep in sync with .gitea/workflows/ci.yml: a release must never ship a # A single job so the package is compiled only once: makepkg builds kitty and
# commit that the CI job would have rejected. # the Go tools, the checks below run on that build tree, and publishing comes
check: # last, so a release never pays for a second build of the same commit.
release:
runs-on: arch-host runs-on: arch-host
defaults: defaults:
run: run:
@@ -51,35 +53,6 @@ jobs:
exit 1 exit 1
fi fi
- name: Build
run: ./dev.sh build
- name: Vet
run: go vet ./kittens/file_manager/
- name: Test
run: go test --tags testing ./kittens/file_manager/
- name: Smoke test the binaries
run: |
./kitty/launcher/kitty --version
./kitty/launcher/kitten --version
release:
needs: [check]
# makepkg on the Arch host: an Arch container cannot be used because the
# pacman database uses ':' in epoch directory names, which some runner disks
# reject, and the host already has the package dependencies installed.
runs-on: arch-host
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Install the build dependencies
run: ./packaging/install-ci-deps.sh
- name: Read the version file - name: Read the version file
id: version id: version
run: echo "version=$(./packaging/check-version.sh)" >> "$GITHUB_OUTPUT" run: echo "version=$(./packaging/check-version.sh)" >> "$GITHUB_OUTPUT"
@@ -96,15 +69,48 @@ jobs:
cp packaging/PKGBUILD "$work/" cp packaging/PKGBUILD "$work/"
cd "$work" cd "$work"
# Pin the build to the commit being released: main may already have # Pin the build to the commit being released: main may already have
# moved on by the time makepkg clones the repository. # moved on by the time makepkg clones the repository. The source tree
# is kept (no --cleanbuild) so the checks below run in it instead of
# rebuilding the project a second time.
FWS_SOURCE_REF="commit=$GITHUB_SHA" \ FWS_SOURCE_REF="commit=$GITHUB_SHA" \
makepkg --noconfirm --nodeps --force --cleanbuild makepkg --noconfirm --nodeps --force
echo "FWS_SRC=$work/src/fws-kitty" >> "$GITHUB_ENV"
# kitty's linux-package target installs straight into the staging root,
# so the built binaries live there rather than in the source tree.
echo "FWS_PKG=$work/pkg/fws-kitty" >> "$GITHUB_ENV"
# ls prints ./*, which must not leak into the asset name or the
# X-Filename header of the pacman upload.
asset="$(ls -1 ./*.pkg.tar.zst | grep -v -- '-debug-' | head -n 1)" asset="$(ls -1 ./*.pkg.tar.zst | grep -v -- '-debug-' | head -n 1)"
asset="${asset#./}"
sha256sum "$asset" > "$asset.sha256" sha256sum "$asset" > "$asset.sha256"
cat "$asset.sha256" cat "$asset.sha256"
echo "file=$work/$asset" >> "$GITHUB_OUTPUT" echo "file=$work/$asset" >> "$GITHUB_OUTPUT"
echo "name=$asset" >> "$GITHUB_OUTPUT" echo "name=$asset" >> "$GITHUB_OUTPUT"
# These import generated code and embedded data that only exist after a
# build, so they run in the makepkg tree above, not on the bare checkout.
- name: Vet the Go code
run: |
set -euo pipefail
cd "$FWS_SRC"
go vet ./kittens/file_manager/
- name: Test the Go code
run: |
set -euo pipefail
cd "$FWS_SRC"
go test --tags testing ./kittens/file_manager/
- name: Smoke test the binaries
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
"$FWS_PKG/usr/bin/kitty" --version
"$FWS_PKG/usr/bin/kitten" --version
# The release announces the fork version, not the kitty one.
"$FWS_PKG/usr/bin/kitty" --version | grep -qF "fws-kitty $VERSION"
- name: Publish the Gitea release - name: Publish the Gitea release
env: env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }} RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
@@ -113,6 +119,12 @@ jobs:
PACKAGE_FILE: ${{ steps.package.outputs.file }} PACKAGE_FILE: ${{ steps.package.outputs.file }}
run: | run: |
set -euo pipefail set -euo pipefail
# Without the token every API call answers 401 and the failure would
# look like a missing release instead of a missing secret.
if [ -z "${RELEASE_TOKEN:-}" ]; then
echo "::error::RELEASE_TOKEN is not set: cannot create the release."
exit 1
fi
api="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY" api="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY"
tag="v$VERSION" tag="v$VERSION"
auth="Authorization: token $RELEASE_TOKEN" auth="Authorization: token $RELEASE_TOKEN"
+6 -4
View File
@@ -310,10 +310,12 @@ c'est elle qui nomme le tag, la release et le paquet
vérifie l'ensemble, ainsi que `_kittyver` du `PKGBUILD` contre vérifie l'ensemble, ainsi que `_kittyver` du `PKGBUILD` contre
`kitty/constants.py`, et échoue sinon. Un push sur `main` qui modifie `version` `kitty/constants.py`, et échoue sinon. Un push sur `main` qui modifie `version`
déclenche déclenche
`.gitea/workflows/package.yml` : lint, build, tests, paquet `makepkg`, release `.gitea/workflows/package.yml`, qui compile le paquet une seule fois
Gitea `v<version>` avec le paquet en pièce jointe, puis envoi à (`makepkg`, seul build), lance lint, `go vet`, tests et smoke test sur cet
`repo.laxacube.ch`. `.gitea/workflows/ci.yml` rejoue les mêmes contrôles sur arbre, puis crée la release Gitea `v<version>` avec le paquet en pièce jointe
chaque PR et chaque push sur `main`. et l'envoie à `repo.laxacube.ch`. `.gitea/workflows/ci.yml` rejoue les mêmes
contrôles sur chaque PR et chaque push sur `main` qui ne modifie pas que
`version`.
Pour reconstruire la même version du fork (correctif de packaging), incrémentez Pour reconstruire la même version du fork (correctif de packaging), incrémentez
`pkgrel` dans `packaging/PKGBUILD` puis lancez le workflow à la main `pkgrel` dans `packaging/PKGBUILD` puis lancez le workflow à la main
+5 -4
View File
@@ -71,10 +71,11 @@ nginx (ou des assets de release) fournit directement.
## Publication automatique ## Publication automatique
Le fichier `version`, à la racine du dépôt, déclenche tout : un push sur `main` Le fichier `version`, à la racine du dépôt, déclenche tout : un push sur `main`
qui le modifie lance `.gitea/workflows/package.yml`, qui rejoue le lint, le qui le modifie lance `.gitea/workflows/package.yml` : lint, puis construction du
build et les tests, construit le paquet avec ce `PKGBUILD` depuis le commit paquet avec ce `PKGBUILD` depuis le commit exact — c'est le seul build, les
exact, crée la release Gitea `v<version>` (paquet + empreinte SHA-256 en pièces `go vet`, tests et smoke test tournent sur cet arbre — avant de créer la
jointes) puis envoie le paquet à `repo.laxacube.ch`. release Gitea `v<version>` (paquet + empreinte SHA-256 en pièces jointes) et
d'envoyer le paquet à `repo.laxacube.ch`.
Le workflow a besoin de deux secrets du dépôt : Le workflow a besoin de deux secrets du dépôt :