Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions .github/workflows/build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,30 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
run: |
image=ghcr.io/archlinux/archlinux:base-devel@sha256:c3953446016873a756fb7814f10087cac1634c127f7302e80c81c512da796d05
# ghcr.io and the mirrors drop connections; one bad fetch shouldn't fail a release.
for attempt in 1 2 3; do
docker pull "$image" && break
[[ $attempt -lt 3 ]] || exit 1
sleep $((attempt * 20))
done
docker run --rm \
--volume "$GITHUB_WORKSPACE:/workspace" \
--workdir /workspace \
--env GH_TOKEN \
--env UPINFO \
--env APPIMAGE_NAME \
ghcr.io/archlinux/archlinux:base-devel@sha256:c3953446016873a756fb7814f10087cac1634c127f7302e80c81c512da796d05 bash -Eeuo pipefail -c '
"$image" bash -Eeuo pipefail -c '
for attempt in 1 2 3; do
pacman -Syu --noconfirm --needed \
cmake git ninja pkgconf lld sdl3 sdl3_ttf curl openssl \
nlohmann-json libyaml libelf minizip minizip-ng capstone gtk4 \
libadwaita libsecret webkitgtk-6.0 libutf8proc fontconfig libglvnd \
vulkan-headers zlib libplacebo ffmpeg bubblewrap xdg-dbus-proxy \
patchelf jq unzip file ca-certificates dbus zsync
patchelf jq unzip file ca-certificates dbus zsync && break
[[ $attempt -lt 3 ]] || exit 1
sleep 20
done

./scripts/install_anylinux_dependencies.sh

Expand Down Expand Up @@ -175,12 +186,18 @@ jobs:
else
version="$(./scripts/package_version.sh)"
fi
for attempt in 1 2 3; do
docker pull ubuntu:26.04 && break
[[ $attempt -lt 3 ]] || exit 1
sleep $((attempt * 20))
done
docker run --rm \
--volume "$GITHUB_WORKSPACE:/workspace" \
--workdir /workspace \
--env MOCKTAIL_PACKAGE_VERSION="$version" \
ubuntu:26.04 bash -Eeuo pipefail -c '
export DEBIAN_FRONTEND=noninteractive
echo "Acquire::Retries \"3\";" >/etc/apt/apt.conf.d/80-retries
apt-get update
apt-get install --yes --no-install-recommends \
build-essential cmake git ninja-build pkg-config lld fakeroot \
Expand Down Expand Up @@ -237,6 +254,11 @@ jobs:
else
version="$(./scripts/package_version.sh)"
fi
for attempt in 1 2 3; do
docker pull "fedora:$FEDORA" && break
[[ $attempt -lt 3 ]] || exit 1
sleep $((attempt * 20))
done
docker run --rm \
--volume "$GITHUB_WORKSPACE:/workspace" \
--workdir /workspace \
Expand Down Expand Up @@ -294,15 +316,25 @@ jobs:
version="$(./scripts/package_version.sh)"
fi
sed -i "s/^pkgver=.*/pkgver=${version}/" packaging/arch/PKGBUILD
image=ghcr.io/archlinux/archlinux:base-devel@sha256:c3953446016873a756fb7814f10087cac1634c127f7302e80c81c512da796d05
for attempt in 1 2 3; do
docker pull "$image" && break
[[ $attempt -lt 3 ]] || exit 1
sleep $((attempt * 20))
done
docker run --rm \
--volume "$GITHUB_WORKSPACE:/workspace" \
--workdir /workspace \
ghcr.io/archlinux/archlinux:base-devel@sha256:c3953446016873a756fb7814f10087cac1634c127f7302e80c81c512da796d05 bash -Eeuo pipefail -c '
"$image" bash -Eeuo pipefail -c '
for attempt in 1 2 3; do
pacman -Syu --needed --noconfirm \
cmake git ninja pkgconf lld sdl3 sdl3_ttf curl openssl \
nlohmann-json libyaml libelf minizip capstone gtk4 \
libadwaita libsecret webkitgtk-6.0 libutf8proc fontconfig libpng \
libplacebo ffmpeg vulkan-headers vulkan-icd-loader libglvnd zlib
libplacebo ffmpeg vulkan-headers vulkan-icd-loader libglvnd zlib && break
[[ $attempt -lt 3 ]] || exit 1
sleep 20
done
useradd --create-home builder
chown -R builder:builder /workspace
runuser -u builder -- env MOCKTAIL_SOURCE_DIR=/workspace \
Expand Down
28 changes: 23 additions & 5 deletions .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,30 @@ jobs:
shell: bash
timeout-minutes: 10
run: |
set -Eeuo pipefail
apt_opts=(-o Acquire::Retries=3 -o Acquire::http::Timeout=30)
sudo apt-get "${apt_opts[@]}" update
sudo apt-get "${apt_opts[@]}" install --yes \
flatpak flatpak-builder gnupg ostree
flatpak remote-add --user --if-not-exists flathub \
https://dl.flathub.org/repo/flathub.flatpakrepo
packages=(flatpak flatpak-builder gnupg ostree)
download() {
sudo apt-get "${apt_opts[@]}" update &&
sudo timeout 180 apt-get "${apt_opts[@]}" install --yes \
--download-only "${packages[@]}"
}
# Same slow Azure mirror as ci.yml; finished downloads stay cached.
if ! download; then
echo "::warning::Ubuntu mirror too slow, retrying on archive.ubuntu.com"
if [[ -f /etc/apt/apt-mirrors.txt ]]; then
echo "http://archive.ubuntu.com/ubuntu/" |
sudo tee /etc/apt/apt-mirrors.txt >/dev/null
fi
download
fi
sudo apt-get "${apt_opts[@]}" install --yes "${packages[@]}"
for attempt in 1 2 3; do
flatpak remote-add --user --if-not-exists flathub \
https://dl.flathub.org/repo/flathub.flatpakrepo && break
[[ $attempt -lt 3 ]] || exit 1
sleep $((attempt * 15))
done

- name: Import signing key
if: env.MOCKTAIL_PUBLISH == 'true'
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,28 @@ concurrency:
cancel-in-progress: false

jobs:
# Catches a mistagged release before anything is built or signed. It runs from
# the tagged commit, so it is no defense against a malicious tag; the "Release
# tags" ruleset, which lets only admins create v* tags, is.
gate:
name: Check release tag
runs-on: ubuntu-24.04
timeout-minutes: 5
steps:
- name: Check out source
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0

- name: Check tag against VERSION and main
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: scripts/check_release_tag.sh "$GITHUB_REF_NAME" origin/main

build:
name: Build
needs: [gate]
uses: ./.github/workflows/build-packages.yml
with:
channel: release
Expand All @@ -23,6 +43,7 @@ jobs:
flatpak:
name: Flatpak
if: startsWith(github.ref, 'refs/tags/v')
needs: [gate]
uses: ./.github/workflows/flatpak.yml
permissions:
contents: read
Expand Down
35 changes: 35 additions & 0 deletions scripts/check_release_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
#
# Release gate.
# check_release_tag.sh --version prints the CMake project VERSION
# check_release_tag.sh <tag> <main> fails unless <tag> is v<VERSION> and
# HEAD is already on <main>
# Pitfall: a mismatched tag makes the self-updater re-offer that release forever.

set -Eeuo pipefail

root="$(git rev-parse --show-toplevel)"
version="$(sed -nE '/^project\(/,/\)/s/^[[:space:]]+VERSION[[:space:]]+([0-9]+\.[0-9]+\.[0-9]+)[[:space:]]*$/\1/p' \
"${root}/CMakeLists.txt")"
if [[ ! "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::no project VERSION in CMakeLists.txt" >&2
exit 1
fi

if [[ "${1:-}" == --version ]]; then
printf '%s\n' "${version}"
exit 0
fi

tag="${1:?usage: check_release_tag.sh <tag> <main-ref>}"
main_ref="${2:?usage: check_release_tag.sh <tag> <main-ref>}"

if [[ "${tag}" != "v${version}" ]]; then
echo "::error::tag ${tag} does not match CMakeLists.txt VERSION ${version}" >&2
exit 1
fi
if ! git merge-base --is-ancestor HEAD "${main_ref}"; then
echo "::error::${tag} points at a commit that is not on ${main_ref}" >&2
exit 1
fi
27 changes: 26 additions & 1 deletion tests/native_packaging_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,12 @@ grep -Fq 'git describe' "${AUR_PKGBUILD}" ||
Fail 'AUR VCS package does not version from the release tag'
grep -Fq 'git describe' "${AUR_WORKFLOW}" ||
Fail 'AUR workflow does not version from the release tag'
GATE_SCRIPT="$(realpath -- "${ROOT}/scripts/check_release_tag.sh")"
readonly GATE_SCRIPT
cmake_version="$(cd "${ROOT}" && bash "${GATE_SCRIPT}" --version)" ||
Fail 'release gate cannot read the CMake project VERSION'
for pkgbuild in "${PKGBUILD}" "${AUR_STABLE_PKGBUILD}" "${AUR_BIN_PKGBUILD}"; do
grep -Fqx 'pkgver=0.5.7' "${pkgbuild}" ||
grep -Fqx "pkgver=${cmake_version}" "${pkgbuild}" ||
Fail "package version does not match the release being prepared: ${pkgbuild}"
done

Expand Down Expand Up @@ -268,6 +272,27 @@ VersionGit tag continuous
[[ "$(VersionIn main)" == 0.0.0 ]] ||
Fail 'a branch does not give the placeholder version'

GateIn() {
(cd "${version_repo}" && bash "${GATE_SCRIPT}" "$@") >/dev/null 2>&1
}
printf 'project(Nightcap\n VERSION 0.4.0\n LANGUAGES CXX\n)\n' \
>"${version_repo}/CMakeLists.txt"
VersionGit add CMakeLists.txt
VersionGit commit --quiet -m bump
VersionGit update-ref refs/heads/released HEAD
GateIn v0.4.0 released ||
Fail 'release gate refuses a tag that matches the CMake VERSION on main'
! GateIn v0.4.1 released ||
Fail 'release gate accepts a tag that does not match the CMake VERSION'
VersionGit commit --quiet --allow-empty -m unmerged
! GateIn v0.4.0 released ||
Fail 'release gate accepts a commit that is not on main'
grep -Fq -- 'scripts/check_release_tag.sh "$GITHUB_REF_NAME" origin/main' \
"${RELEASE_WORKFLOW}" ||
Fail 'release workflow does not run the release gate'
[[ "$(grep -Fcx -- ' needs: [gate]' "${RELEASE_WORKFLOW}")" == 2 ]] ||
Fail 'release build and Flatpak jobs do not both wait for the release gate'

grep -Fq 'Ubuntu 26.04+' "${README}" ||
Fail 'README has no Ubuntu source dependency guide'
grep -Fq 'Arch Linux' "${README}" ||
Expand Down