BlueGit

timfa posprint

Files

posprint / blue-ci-cd.yml

blue-ci-cd.yml

blue-ci-cd.yml 5.6 KiB Download Raw
1# posprint — BlueGit CI (git.timfalken.com/timfa/posprint).
2# Migrated from the old .gitlab-ci.yml (GitLab is now a backup only).
3#
4# Merge request / any branch push: test.
5# Master: test + all release builds + AUR dry run (nothing is published).
6# `release` is manual on master: it creates the next tag (highest tag + 1
7# patch, or Cargo.toml if higher; override with RELEASE_VERSION) through the
8# BlueGit release API with the build artifacts as assets. Then publish:aur
9# updates the AUR packages posprint and posprint-bin.
10# Tag pushes never run a pipeline (old tags must not rebuild).
11#
12# Secrets (repository, protected): AUR_SSH_PRIVATE_KEY_B64,
13# AUR_GIT_AUTHOR_NAME, AUR_GIT_AUTHOR_EMAIL.
14
15stages: [test, build, release, publish]
16
17variables:
18 CARGO_TERM_COLOR: always
19 RUST_BACKTRACE: "1"
20 CARGO_BUILD_JOBS: "3"
21 CARGO_PROFILE_DEV_DEBUG: "false"
22 CARGO_PROFILE_TEST_DEBUG: "false"
23
24workflow:
25 rules:
26 - if: $CI_COMMIT_TAG != ""
27 when: never
28 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
29 - if: $CI_COMMIT_BRANCH == "master"
30 - if: $CI_PIPELINE_SOURCE == "web"
31 - if: $CI_PIPELINE_SOURCE == "api"
32
33.master:
34 rules:
35 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
36 when: never
37 - if: $CI_COMMIT_BRANCH == "master"
38
39.rust:
40 image: rust:1.96-bookworm
41 timeout: 2h
42 before_script:
43 - export CARGO_HOME="$CI_PROJECT_DIR/cargo-home"
44 - export PATH="$CARGO_HOME/bin:$PATH"
45 - apt-get update -qq
46 - 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
47
48test:
49 extends: .rust
50 stage: test
51 cache:
52 key: cargo-test
53 paths: [target/, cargo-home/]
54 script:
55 - cargo test --verbose
56
57version:
58 extends: .master
59 stage: test
60 image: bluegit/base
61 needs: []
62 script:
63 - mkdir -p artifacts
64 - bash scripts/ci/next-version.sh | tee artifacts/version.txt
65 artifacts:
66 paths: [artifacts/version.txt]
67 expire_in: 14d
68
69build:linux-deb:
70 extends: [.rust, .master]
71 stage: build
72 needs: [version, test]
73 cache:
74 key: cargo-deb
75 paths: [target/, cargo-home/]
76 script:
77 - apt-get install -y -qq dpkg-dev
78 - cargo install cargo-deb --locked
79 - bash scripts/ci/set-version.sh
80 - cargo deb
81 - mkdir -p dist
82 - cp target/debian/*.deb dist/
83 artifacts:
84 paths: [dist/*.deb]
85 expire_in: 30d
86
87build:linux-arch:
88 extends: .master
89 stage: build
90 image: archlinux/archlinux:base-devel
91 timeout: 2h
92 needs: [version, test]
93 script:
94 - pacman -Syu --noconfirm
95 - pacman -S --noconfirm --needed rust pkgconf openssl libxkbcommon libxcb dbus wayland libx11 fontconfig freetype2 libglvnd git rsync
96 - bash scripts/ci/set-version.sh
97 - export PKGVER="$(cat artifacts/version.txt)"
98 - sed -i "s/^pkgver=.*/pkgver=${PKGVER}/" packaging/arch/PKGBUILD
99 - useradd -m builduser
100 - chown -R builduser:builduser "$CI_PROJECT_DIR"
101 - su builduser -c "cd $CI_PROJECT_DIR/packaging/arch && makepkg -f --noconfirm"
102 - mkdir -p "$CI_PROJECT_DIR/dist"
103 - |
104 set -euo pipefail
105 shopt -s nullglob
106 mains=("$CI_PROJECT_DIR"/packaging/arch/posprint-${PKGVER}-*-x86_64.pkg.tar.zst)
107 shopt -u nullglob
108 if [[ ${#mains[@]} -ne 1 ]]; then
109 echo "Expected one non-debug Arch package, found ${#mains[@]}" >&2
110 exit 1
111 fi
112 cp "${mains[0]}" "$CI_PROJECT_DIR/dist/"
113 out="$CI_PROJECT_DIR/dist/posprint-${PKGVER}-x86_64.tar.gz"
114 bash "$CI_PROJECT_DIR/scripts/make-linux-bin-tarball.sh" "${mains[0]}" "$out" "$PKGVER"
115 test -s "$out"
116 artifacts:
117 paths: [dist/*.pkg.tar.zst, dist/posprint-*-x86_64.tar.gz]
118 expire_in: 30d
119
120# Cross-compiled with MinGW (no Windows runner on BlueGit).
121build:windows:
122 extends: [.rust, .master]
123 stage: build
124 needs: [version, test]
125 cache:
126 key: cargo-windows
127 paths: [target/, cargo-home/]
128 before_script:
129 - export CARGO_HOME="$CI_PROJECT_DIR/cargo-home"
130 - export PATH="$CARGO_HOME/bin:$PATH"
131 - apt-get update -qq
132 - apt-get install -y -qq gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64
133 - rustup target add x86_64-pc-windows-gnu
134 script:
135 - bash scripts/ci/set-version.sh
136 - cargo build --release --locked --target x86_64-pc-windows-gnu
137 - mkdir -p dist
138 - cp target/x86_64-pc-windows-gnu/release/posprint.exe dist/
139 artifacts:
140 paths: [dist/posprint.exe]
141 expire_in: 30d
142
143# Safe AUR check on every master pipeline: real SSH key and AUR clone,
144# PKGBUILD/.SRCINFO generation, but AUR_DRY_RUN=1 never pushes.
145aur:dry-run:
146 extends: .master
147 stage: release
148 image: archlinux/archlinux:base-devel
149 needs: [version, build:linux-arch]
150 allow_failure: true
151 script:
152 - pacman -Syu --noconfirm --needed git openssh curl coreutils shadow util-linux
153 - bash scripts/aur-ssh-setup.sh
154 - last="$(git tag -l | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1)"
155 - export POSPRINT_SOURCE_ARCHIVE_URL="$CI_API_URL/projects/$CI_PROJECT_PATH/repository/tags/$last/archive"
156 - AUR_DRY_RUN=1 bash scripts/publish-aur.sh "$(cat artifacts/version.txt)"
157
158release:
159 extends: .master
160 stage: release
161 image: bluegit/base
162 needs: [version, build:linux-deb, build:linux-arch, build:windows]
163 when: manual
164 resource_group: release
165 script:
166 - bash scripts/ci/release.sh
167
168publish:aur:
169 extends: .master
170 stage: publish
171 image: archlinux/archlinux:base-devel
172 needs: [version, release, build:linux-arch]
173 allow_failure: true
174 resource_group: aur
175 script:
176 - pacman -Syu --noconfirm --needed git openssh curl coreutils shadow util-linux
177 - bash scripts/aur-ssh-setup.sh
178 - bash scripts/publish-aur.sh "$(cat artifacts/version.txt)"