BlueGit

timfa posprint

Files

posprint / .gitlab-ci.yml

.gitlab-ci.yml

fix: restore tag release downloads and AUR bin publish
timfa project_84475926_bot_764f118ece54db37209130d2bbcb4ae7 · pushed by timfa · 2 months ago
65a63b91 History
.gitlab-ci.yml 5.5 KiB Download Raw
1# posprint — GitLab CI/CD (GitLab.com SaaS runners)
2# Tests on merge requests; release builds on tags only.
3
4# Skip empty pipelines on branch pushes (jobs are MR- or tag-only).
5workflow:
6 rules:
7 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
8 - if: $CI_COMMIT_TAG
9
10stages:
11 - test
12 - build
13 - release
14
15variables:
16 CARGO_TERM_COLOR: always
17 RUST_BACKTRACE: "1"
18
19# Linux Docker jobs: untagged → saas-linux-small-amd64 by default.
20.default_rust:
21 image: rust:1.96-bookworm
22 before_script:
23 - rustc --version
24 - cargo --version
25
26# Windows SaaS runner (PowerShell). Rust is not preinstalled — install via rustup.
27.windows_saas:
28 tags:
29 - saas-windows-medium-amd64
30 before_script:
31 - |
32 if (-not (Get-Command rustc -ErrorAction SilentlyContinue)) {
33 Write-Host "Installing Rust via rustup..."
34 Invoke-WebRequest -Uri https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
35 .\rustup-init.exe -y --default-toolchain stable --profile minimal
36 Remove-Item rustup-init.exe
37 }
38 $env:Path = "$env:USERPROFILE\.cargo\bin;$env:Path"
39 rustc --version
40 cargo --version
41
42test:linux:
43 extends: .default_rust
44 stage: test
45 rules:
46 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
47 script:
48 - apt-get update -qq
49 - apt-get install -y -qq libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
50 libxkbcommon-dev libssl-dev libudev-dev pkg-config
51 - cargo test --verbose
52
53test:windows:
54 extends: .windows_saas
55 stage: test
56 rules:
57 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
58 script:
59 - cargo test --verbose
60
61build:linux-deb:
62 extends: .default_rust
63 stage: build
64 rules:
65 - if: $CI_COMMIT_TAG
66 before_script:
67 - apt-get update -qq
68 - apt-get install -y -qq libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
69 libxkbcommon-dev libssl-dev libudev-dev pkg-config dpkg-dev
70 - cargo install cargo-deb --locked
71 script:
72 - cargo deb
73 - mkdir -p dist
74 - cp target/debian/*.deb dist/
75 artifacts:
76 name: "posprint-linux-$CI_COMMIT_TAG"
77 paths:
78 - dist/*.deb
79 expire_in: 1 year
80
81build:linux-arch:
82 stage: build
83 image: archlinux/archlinux:base-devel
84 rules:
85 - if: $CI_COMMIT_TAG
86 script:
87 - pacman -Syu --noconfirm
88 - pacman -S --noconfirm --needed rust pkgconf openssl libxkbcommon libxcb dbus
89 wayland libx11 fontconfig freetype2 libglvnd git rsync
90 - rustc --version
91 - export PKGVER="${CI_COMMIT_TAG#v}"
92 - sed -i "s/^pkgver=.*/pkgver=${PKGVER}/" packaging/arch/PKGBUILD
93 - useradd -m builduser
94 - chown -R builduser:builduser "$CI_PROJECT_DIR"
95 - su builduser -c "cd $CI_PROJECT_DIR/packaging/arch && makepkg -f --noconfirm"
96 - mkdir -p "$CI_PROJECT_DIR/dist"
97 - chmod +x "$CI_PROJECT_DIR/scripts/make-linux-bin-tarball.sh"
98 # Select the non-debug package only. A glob of *.pkg.tar.zst also matches
99 # posprint-debug-*.pkg.tar.zst and used to scramble $2/$3 so the AUR tarball
100 # never landed in dist/.
101 - |
102 set -euo pipefail
103 shopt -s nullglob
104 mains=("$CI_PROJECT_DIR"/packaging/arch/posprint-${PKGVER}-*-x86_64.pkg.tar.zst)
105 shopt -u nullglob
106 if [[ ${#mains[@]} -ne 1 ]]; then
107 echo "Expected one non-debug Arch package, found ${#mains[@]}" >&2
108 ls -la "$CI_PROJECT_DIR/packaging/arch" >&2 || true
109 exit 1
110 fi
111 cp "${mains[0]}" "$CI_PROJECT_DIR/dist/"
112 out="$CI_PROJECT_DIR/dist/posprint-${PKGVER}-x86_64.tar.gz"
113 "$CI_PROJECT_DIR/scripts/make-linux-bin-tarball.sh" "${mains[0]}" "$out" "$PKGVER"
114 test -s "$out"
115 artifacts:
116 name: "posprint-arch-$CI_COMMIT_TAG"
117 paths:
118 - dist/*.pkg.tar.zst
119 - dist/posprint-*-x86_64.tar.gz
120 expire_in: 1 year
121
122build:windows:
123 extends: .windows_saas
124 stage: build
125 rules:
126 - if: $CI_COMMIT_TAG
127 script:
128 - cargo build --release
129 - New-Item -ItemType Directory -Force -Path dist | Out-Null
130 - Copy-Item target\release\posprint.exe dist\
131 artifacts:
132 name: "posprint-windows-$CI_COMMIT_TAG"
133 paths:
134 - dist/posprint.exe
135 expire_in: 1 year
136
137release:gitlab:
138 stage: release
139 image: alpine:3.21
140 rules:
141 - if: $CI_COMMIT_TAG
142 needs:
143 - job: build:linux-deb
144 artifacts: true
145 - job: build:linux-arch
146 artifacts: true
147 - job: build:windows
148 artifacts: true
149 before_script:
150 - apk add --no-cache bash curl jq
151 - chmod +x scripts/publish-gitlab-release.sh
152 script:
153 # Discover real filenames in dist/ (cargo-deb uses posprint_<ver>-1_amd64.deb;
154 # makepkg uses posprint-<ver>-1-x86_64.pkg.tar.zst). Upload them to the
155 # Generic Package Registry and attach durable Release download links.
156 - ./scripts/publish-gitlab-release.sh
157
158publish:aur:
159 stage: release
160 image: archlinux/archlinux:base-devel
161 rules:
162 - if: $CI_COMMIT_TAG
163 # AUR outage must not fail the whole tag pipeline (job-artifact permalinks
164 # 404 when the latest pipeline for the tag is failed). Prefer success; this
165 # is only a safety net.
166 allow_failure: true
167 needs:
168 - release:gitlab
169 - job: build:linux-arch
170 artifacts: true
171 before_script:
172 # Only tools needed to update the AUR git repo (no Rust GUI build deps).
173 # Do not install package name "cargo" — it prompts for a provider (rust vs rustup).
174 - pacman -Syu --noconfirm
175 - pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux
176 - chmod +x scripts/aur-ssh-setup.sh
177 - ./scripts/aur-ssh-setup.sh
178 script:
179 - chmod +x scripts/publish-aur.sh
180 - ./scripts/publish-aur.sh "$CI_COMMIT_TAG"