# posprint — BlueGit CI (git.timfalken.com/timfa/posprint).
# Migrated from the old .gitlab-ci.yml (GitLab is now a backup only).
#
# Merge request / any branch push: test.
# Master: test + all release builds + AUR dry run (nothing is published).
# `release` runs automatically after green builds on master: it creates the next tag (highest tag + 1
# patch, or Cargo.toml if higher; override with RELEASE_VERSION) through the
# BlueGit release API, but only if HEAD is untagged and something outside
# docs/CI changed since the last tag (scripts/ci/release.sh); otherwise it
# writes `skip` and publish:aur does nothing. Release notes: RELEASE_NOTES.md.
#
# BlueGit release API with the build artifacts as assets. Then publish:aur
# updates the AUR packages posprint and posprint-bin.
# Tag pushes never run a pipeline (old tags must not rebuild).
#
# Secrets (repository, protected): AUR_SSH_PRIVATE_KEY_B64,
# AUR_GIT_AUTHOR_NAME, AUR_GIT_AUTHOR_EMAIL.
stages: [test, build, release, publish]
variables:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: "1"
CARGO_BUILD_JOBS: "3"
CARGO_PROFILE_DEV_DEBUG: "false"
CARGO_PROFILE_TEST_DEBUG: "false"
workflow:
rules:
- if: $CI_COMMIT_TAG != ""
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == "master"
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "api"
.master:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_COMMIT_BRANCH == "master"
.rust:
image: rust:1.96-bookworm
timeout: 2h
before_script:
- export CARGO_HOME="$CI_PROJECT_DIR/cargo-home"
- export PATH="$CARGO_HOME/bin:$PATH"
- apt-get update -qq
- apt-get install -y -qq libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev libudev-dev libdbus-1-dev pkg-config
test:
extends: .rust
stage: test
cache:
key: cargo-test
paths: [target/, cargo-home/]
script:
- cargo test --verbose
version:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_COMMIT_BRANCH == "master"
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "api"
stage: test
image: bluegit/base
needs: []
script:
- mkdir -p artifacts
- bash scripts/ci/next-version.sh | tee artifacts/version.txt
artifacts:
paths: [artifacts/version.txt]
expire_in: 14d
build:linux-deb:
extends: [.rust, .master]
stage: build
needs: [version, test]
cache:
key: cargo-deb
paths: [target/, cargo-home/]
script:
- apt-get install -y -qq dpkg-dev
- cargo install cargo-deb --locked
- bash scripts/ci/set-version.sh
- cargo deb
- mkdir -p dist
- cp target/debian/posprint_$(cat artifacts/version.txt)-1_amd64.deb dist/amd64.deb
artifacts:
# BlueGit artifacts are exact file paths (no globs or directories).
paths: [dist/amd64.deb]
expire_in: 30d
build:linux-arch:
extends: .master
stage: build
image: archlinux/archlinux:base-devel
timeout: 2h
needs: [version, test]
script:
# BlueGit sets no CI_PROJECT_DIR; jobs start in the checkout.
- export CI_PROJECT_DIR="$PWD"
- pacman -Syu --noconfirm
- pacman -S --noconfirm --needed rust pkgconf openssl libxkbcommon libxcb dbus wayland libx11 fontconfig freetype2 libglvnd git rsync
- bash scripts/ci/set-version.sh
- export PKGVER="$(cat artifacts/version.txt)"
- sed -i "s/^pkgver=.*/pkgver=${PKGVER}/" packaging/arch/PKGBUILD
- useradd -m builduser
- chown -R builduser:builduser "$CI_PROJECT_DIR"
- su builduser -c "cd $CI_PROJECT_DIR/packaging/arch && makepkg -f --noconfirm"
- mkdir -p "$CI_PROJECT_DIR/dist"
- |
set -euo pipefail
shopt -s nullglob
mains=("$CI_PROJECT_DIR"/packaging/arch/posprint-${PKGVER}-*-x86_64.pkg.tar.zst)
shopt -u nullglob
if [[ ${#mains[@]} -ne 1 ]]; then
echo "Expected one non-debug Arch package, found ${#mains[@]}" >&2
exit 1
fi
cp "${mains[0]}" "$CI_PROJECT_DIR/dist/x86_64.pkg.tar.zst"
out="$CI_PROJECT_DIR/dist/x86_64-bin.tar.gz"
bash "$CI_PROJECT_DIR/scripts/make-linux-bin-tarball.sh" "${mains[0]}" "$out" "$PKGVER"
test -s "$out"
artifacts:
paths: [dist/x86_64.pkg.tar.zst, dist/x86_64-bin.tar.gz]
expire_in: 30d
# Cross-compiled with MinGW (no Windows runner on BlueGit).
build:windows:
extends: [.rust, .master]
stage: build
needs: [version, test]
cache:
key: cargo-windows
paths: [target/, cargo-home/]
before_script:
- export CARGO_HOME="$CI_PROJECT_DIR/cargo-home"
- export PATH="$CARGO_HOME/bin:$PATH"
- apt-get update -qq
- apt-get install -y -qq gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64
- rustup target add x86_64-pc-windows-gnu
# winres calls plain `windres`; use the MinGW one.
- ln -sf /usr/bin/x86_64-w64-mingw32-windres /usr/local/bin/windres
script:
- bash scripts/ci/set-version.sh
- cargo build --release --locked --target x86_64-pc-windows-gnu
- mkdir -p dist
- cp target/x86_64-pc-windows-gnu/release/posprint.exe dist/
artifacts:
paths: [dist/posprint.exe]
expire_in: 30d
# Cross-built on Linux (no macOS runner): universal Posprint.app as zip.
# Untested on a real Mac in CI; not notarized.
build:macos:
stage: build
image: ghcr.io/rust-cross/cargo-zigbuild:latest
timeout: 2h
needs: [version, test]
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_COMMIT_BRANCH == "master"
# Manual pipeline on a branch: build-check macOS only.
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "api"
cache:
key: cargo-macos
paths: [target/, cargo-home/]
script:
- export CARGO_HOME="$PWD/cargo-home" PATH="$PWD/cargo-home/bin:$PATH"
- bash scripts/ci/set-version.sh
- bash scripts/ci/build-macos.sh
artifacts:
paths: [dist/macos-universal.zip]
expire_in: 30d
# Safe AUR check on every master pipeline: real SSH key and AUR clone,
# PKGBUILD/.SRCINFO generation, but AUR_DRY_RUN=1 never pushes.
aur:dry-run:
extends: .master
stage: release
image: archlinux/archlinux:base-devel
needs: [version, build:linux-arch]
allow_failure: true
script:
- pacman -Syu --noconfirm --needed git openssh curl coreutils shadow util-linux
- bash scripts/aur-ssh-setup.sh
- last="$(git tag -l | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1)"
- export POSPRINT_SOURCE_ARCHIVE_URL="$CI_API_URL/projects/$CI_PROJECT_PATH/repository/tags/$last/archive"
- cp dist/x86_64-bin.tar.gz "dist/posprint-$(cat artifacts/version.txt)-x86_64.tar.gz"
- AUR_DRY_RUN=1 bash scripts/publish-aur.sh "$(cat artifacts/version.txt)"
release:
extends: .master
stage: release
image: bluegit/base
needs: [version, build:linux-deb, build:linux-arch, build:windows, build:macos]
resource_group: release
script:
- bash scripts/ci/release.sh
artifacts:
paths: [artifacts/released.txt]
expire_in: 30d
publish:aur:
extends: .master
stage: publish
image: archlinux/archlinux:base-devel
needs: [version, release, build:linux-arch]
allow_failure: true
resource_group: aur
script:
- pacman -Syu --noconfirm --needed git openssh curl coreutils shadow util-linux
- bash scripts/aur-ssh-setup.sh
- if [ "$(cat artifacts/released.txt)" = "skip" ]; then echo "No new release in this pipeline; AUR unchanged."; exit 0; fi
- cp dist/x86_64-bin.tar.gz "dist/posprint-$(cat artifacts/version.txt)-x86_64.tar.gz"
- bash scripts/publish-aur.sh "$(cat artifacts/version.txt)"