BlueGit

timfa posprint

fix: restore tag release downloads and AUR bin publish

Job-artifact permalinks 404 while a tag pipeline is still running or
after a later job fails. The Arch *.pkg.tar.zst glob also passed the
debug package as \$2, so the AUR tarball never reached dist/. Upload
real filenames to the Generic Package Registry and hash the local
tarball in publish:aur.

Co-authored-by: tim <tim@timfalken.com>

timfa project_84475926_bot_764f118ece54db37209130d2bbcb4ae7 · pushed by timfa

Authored 2026-09-19 · 8 weeks ago

Hash
65a63b91ee275508f4e32a3f3b4a814bd60f295a
Parent
93686de0
13 files changed +878 −221
.gitattributes +1 −0
@@ -1,5 +1,6 @@
1 1 *.sh text eol=lf
2 2 *.ps1 text eol=crlf
3 .gitlab-ci.yml text eol=lf
3 4 PKGBUILD text eol=lf
4 5 *.desktop text eol=lf
5 6 *.xml text eol=lf
@@ -1,5 +1,6 @@
1*.sh text eol=lf
1*.sh text eol=lf
2*.ps1 text eol=crlf
2*.ps1 text eol=crlf
3.gitlab-ci.yml text eol=lf
3PKGBUILD text eol=lf
4PKGBUILD text eol=lf
4*.desktop text eol=lf
5*.desktop text eol=lf
5*.xml text eol=lf
6*.xml text eol=lf
.gitlab-ci.yml +180 −162
@@ -1,162 +1,180 @@
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).
5 workflow:
6 rules:
7 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
8 - if: $CI_COMMIT_TAG
9
10 stages:
11 - test
12 - build
13 - release
14
15 variables:
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
42 test: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
53 test: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
61 build: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
81 build: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 - cp packaging/arch/*.pkg.tar.zst "$CI_PROJECT_DIR/dist/"
98 - chmod +x "$CI_PROJECT_DIR/scripts/make-linux-bin-tarball.sh"
99 # Quoted-then-unquoted tokens are invalid YAML (breaks every pipeline).
100 - |
101 "$CI_PROJECT_DIR/scripts/make-linux-bin-tarball.sh" packaging/arch/*.pkg.tar.zst "$CI_PROJECT_DIR/dist/posprint-${PKGVER}-x86_64.tar.gz" "$PKGVER"
102 artifacts:
103 name: "posprint-arch-$CI_COMMIT_TAG"
104 paths:
105 - dist/*.pkg.tar.zst
106 - dist/posprint-*-x86_64.tar.gz
107 expire_in: 1 year
108
109 build:windows:
110 extends: .windows_saas
111 stage: build
112 rules:
113 - if: $CI_COMMIT_TAG
114 script:
115 - cargo build --release
116 - New-Item -ItemType Directory -Force -Path dist | Out-Null
117 - Copy-Item target\release\posprint.exe dist\
118 artifacts:
119 name: "posprint-windows-$CI_COMMIT_TAG"
120 paths:
121 - dist/posprint.exe
122 expire_in: 1 year
123
124 release:gitlab:
125 stage: release
126 image: registry.gitlab.com/gitlab-org/release-cli:latest
127 rules:
128 - if: $CI_COMMIT_TAG
129 needs:
130 - build:linux-deb
131 - build:linux-arch
132 - build:windows
133 script:
134 - |
135 release-cli create \
136 --name "posprint $CI_COMMIT_TAG" \
137 --tag-name "$CI_COMMIT_TAG" \
138 --description "Cross-platform POS print designer release $CI_COMMIT_TAG" \
139 --assets-link "{\"name\":\"Linux .deb (amd64)\",\"url\":\"${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/posprint_${CI_COMMIT_TAG#v}_amd64.deb?job=build%3Alinux-deb\",\"link_type\":\"package\"}" \
140 --assets-link "{\"name\":\"Arch Linux .pkg.tar.zst (x86_64)\",\"url\":\"${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/posprint_${CI_COMMIT_TAG#v}-1-x86_64.pkg.tar.zst?job=build%3Alinux-arch\",\"link_type\":\"package\"}" \
141 --assets-link "{\"name\":\"Linux binary tarball (x86_64, AUR posprint-bin)\",\"url\":\"${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/posprint-${CI_COMMIT_TAG#v}-x86_64.tar.gz?job=build%3Alinux-arch\",\"link_type\":\"package\"}" \
142 --assets-link "{\"name\":\"Windows .exe\",\"url\":\"${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/posprint.exe?job=build%3Awindows\",\"link_type\":\"package\"}"
143
144 publish:aur:
145 stage: release
146 image: archlinux/archlinux:base-devel
147 rules:
148 - if: $CI_COMMIT_TAG
149 needs:
150 - release:gitlab
151 - job: build:linux-arch
152 artifacts: true
153 before_script:
154 # Only tools needed to update the AUR git repo (no Rust GUI build deps).
155 # Do not install package name "cargo" — it prompts for a provider (rust vs rustup).
156 - pacman -Syu --noconfirm
157 - pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux
158 - chmod +x scripts/aur-ssh-setup.sh
159 - ./scripts/aur-ssh-setup.sh
160 script:
161 - chmod +x scripts/publish-aur.sh
162 - ./scripts/publish-aur.sh "$CI_COMMIT_TAG"
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).
5 workflow:
6 rules:
7 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
8 - if: $CI_COMMIT_TAG
9
10 stages:
11 - test
12 - build
13 - release
14
15 variables:
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
42 test: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
53 test: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
61 build: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
81 build: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
122 build: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
137 release: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
158 publish: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"
@@ -1,162 +1,180 @@
1# posprint — GitLab CI/CD (GitLab.com SaaS runners)
1# posprint — GitLab CI/CD (GitLab.com SaaS runners)
2# Tests on merge requests; release builds on tags only.
2# Tests on merge requests; release builds on tags only.
3
3
4# Skip empty pipelines on branch pushes (jobs are MR- or tag-only).
4# Skip empty pipelines on branch pushes (jobs are MR- or tag-only).
5workflow:
5workflow:
6 rules:
6 rules:
7 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
7 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
8 - if: $CI_COMMIT_TAG
8 - if: $CI_COMMIT_TAG
9
9
10stages:
10stages:
11 - test
11 - test
12 - build
12 - build
13 - release
13 - release
14
14
15variables:
15variables:
16 CARGO_TERM_COLOR: always
16 CARGO_TERM_COLOR: always
17 RUST_BACKTRACE: "1"
17 RUST_BACKTRACE: "1"
18
18
19# Linux Docker jobs: untagged → saas-linux-small-amd64 by default.
19# Linux Docker jobs: untagged → saas-linux-small-amd64 by default.
20.default_rust:
20.default_rust:
21 image: rust:1.96-bookworm
21 image: rust:1.96-bookworm
22 before_script:
22 before_script:
23 - rustc --version
23 - rustc --version
24 - cargo --version
24 - cargo --version
25
25
26# Windows SaaS runner (PowerShell). Rust is not preinstalled — install via rustup.
26# Windows SaaS runner (PowerShell). Rust is not preinstalled — install via rustup.
27.windows_saas:
27.windows_saas:
28 tags:
28 tags:
29 - saas-windows-medium-amd64
29 - saas-windows-medium-amd64
30 before_script:
30 before_script:
31 - |
31 - |
32 if (-not (Get-Command rustc -ErrorAction SilentlyContinue)) {
32 if (-not (Get-Command rustc -ErrorAction SilentlyContinue)) {
33 Write-Host "Installing Rust via rustup..."
33 Write-Host "Installing Rust via rustup..."
34 Invoke-WebRequest -Uri https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
34 Invoke-WebRequest -Uri https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
35 .\rustup-init.exe -y --default-toolchain stable --profile minimal
35 .\rustup-init.exe -y --default-toolchain stable --profile minimal
36 Remove-Item rustup-init.exe
36 Remove-Item rustup-init.exe
37 }
37 }
38 $env:Path = "$env:USERPROFILE\.cargo\bin;$env:Path"
38 $env:Path = "$env:USERPROFILE\.cargo\bin;$env:Path"
39 rustc --version
39 rustc --version
40 cargo --version
40 cargo --version
41
41
42test:linux:
42test:linux:
43 extends: .default_rust
43 extends: .default_rust
44 stage: test
44 stage: test
45 rules:
45 rules:
46 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
46 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
47 script:
47 script:
48 - apt-get update -qq
48 - apt-get update -qq
49 - apt-get install -y -qq libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
49 - apt-get install -y -qq libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
50 libxkbcommon-dev libssl-dev libudev-dev pkg-config
50 libxkbcommon-dev libssl-dev libudev-dev pkg-config
51 - cargo test --verbose
51 - cargo test --verbose
52
52
53test:windows:
53test:windows:
54 extends: .windows_saas
54 extends: .windows_saas
55 stage: test
55 stage: test
56 rules:
56 rules:
57 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
57 - if: $CI_PIPELINE_SOURCE == "merge_request_event"
58 script:
58 script:
59 - cargo test --verbose
59 - cargo test --verbose
60
60
61build:linux-deb:
61build:linux-deb:
62 extends: .default_rust
62 extends: .default_rust
63 stage: build
63 stage: build
64 rules:
64 rules:
65 - if: $CI_COMMIT_TAG
65 - if: $CI_COMMIT_TAG
66 before_script:
66 before_script:
67 - apt-get update -qq
67 - apt-get update -qq
68 - apt-get install -y -qq libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
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
69 libxkbcommon-dev libssl-dev libudev-dev pkg-config dpkg-dev
70 - cargo install cargo-deb --locked
70 - cargo install cargo-deb --locked
71 script:
71 script:
72 - cargo deb
72 - cargo deb
73 - mkdir -p dist
73 - mkdir -p dist
74 - cp target/debian/*.deb dist/
74 - cp target/debian/*.deb dist/
75 artifacts:
75 artifacts:
76 name: "posprint-linux-$CI_COMMIT_TAG"
76 name: "posprint-linux-$CI_COMMIT_TAG"
77 paths:
77 paths:
78 - dist/*.deb
78 - dist/*.deb
79 expire_in: 1 year
79 expire_in: 1 year
80
80
81build:linux-arch:
81build:linux-arch:
82 stage: build
82 stage: build
83 image: archlinux/archlinux:base-devel
83 image: archlinux/archlinux:base-devel
84 rules:
84 rules:
85 - if: $CI_COMMIT_TAG
85 - if: $CI_COMMIT_TAG
86 script:
86 script:
87 - pacman -Syu --noconfirm
87 - pacman -Syu --noconfirm
88 - pacman -S --noconfirm --needed rust pkgconf openssl libxkbcommon libxcb dbus
88 - pacman -S --noconfirm --needed rust pkgconf openssl libxkbcommon libxcb dbus
89 wayland libx11 fontconfig freetype2 libglvnd git rsync
89 wayland libx11 fontconfig freetype2 libglvnd git rsync
90 - rustc --version
90 - rustc --version
91 - export PKGVER="${CI_COMMIT_TAG#v}"
91 - export PKGVER="${CI_COMMIT_TAG#v}"
92 - sed -i "s/^pkgver=.*/pkgver=${PKGVER}/" packaging/arch/PKGBUILD
92 - sed -i "s/^pkgver=.*/pkgver=${PKGVER}/" packaging/arch/PKGBUILD
93 - useradd -m builduser
93 - useradd -m builduser
94 - chown -R builduser:builduser "$CI_PROJECT_DIR"
94 - chown -R builduser:builduser "$CI_PROJECT_DIR"
95 - su builduser -c "cd $CI_PROJECT_DIR/packaging/arch && makepkg -f --noconfirm"
95 - su builduser -c "cd $CI_PROJECT_DIR/packaging/arch && makepkg -f --noconfirm"
96 - mkdir -p "$CI_PROJECT_DIR/dist"
96 - mkdir -p "$CI_PROJECT_DIR/dist"
97 - cp packaging/arch/*.pkg.tar.zst "$CI_PROJECT_DIR/dist/"
97 - chmod +x "$CI_PROJECT_DIR/scripts/make-linux-bin-tarball.sh"
98 - 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 # Quoted-then-unquoted tokens are invalid YAML (breaks every pipeline).
99 # posprint-debug-*.pkg.tar.zst and used to scramble $2/$3 so the AUR tarball
100 - |
100 # never landed in dist/.
101 "$CI_PROJECT_DIR/scripts/make-linux-bin-tarball.sh" packaging/arch/*.pkg.tar.zst "$CI_PROJECT_DIR/dist/posprint-${PKGVER}-x86_64.tar.gz" "$PKGVER"
101 - |
102 artifacts:
102 set -euo pipefail
103 name: "posprint-arch-$CI_COMMIT_TAG"
103 shopt -s nullglob
104 paths:
104 mains=("$CI_PROJECT_DIR"/packaging/arch/posprint-${PKGVER}-*-x86_64.pkg.tar.zst)
105 - dist/*.pkg.tar.zst
105 shopt -u nullglob
106 - dist/posprint-*-x86_64.tar.gz
106 if [[ ${#mains[@]} -ne 1 ]]; then
107 expire_in: 1 year
107 echo "Expected one non-debug Arch package, found ${#mains[@]}" >&2
108
108 ls -la "$CI_PROJECT_DIR/packaging/arch" >&2 || true
109build:windows:
109 exit 1
110 extends: .windows_saas
110 fi
111 stage: build
111 cp "${mains[0]}" "$CI_PROJECT_DIR/dist/"
112 rules:
112 out="$CI_PROJECT_DIR/dist/posprint-${PKGVER}-x86_64.tar.gz"
113 - if: $CI_COMMIT_TAG
113 "$CI_PROJECT_DIR/scripts/make-linux-bin-tarball.sh" "${mains[0]}" "$out" "$PKGVER"
114 script:
114 test -s "$out"
115 - cargo build --release
115 artifacts:
116 - New-Item -ItemType Directory -Force -Path dist | Out-Null
116 name: "posprint-arch-$CI_COMMIT_TAG"
117 - Copy-Item target\release\posprint.exe dist\
117 paths:
118 artifacts:
118 - dist/*.pkg.tar.zst
119 name: "posprint-windows-$CI_COMMIT_TAG"
119 - dist/posprint-*-x86_64.tar.gz
120 paths:
120 expire_in: 1 year
121 - dist/posprint.exe
121
122 expire_in: 1 year
122build:windows:
123
123 extends: .windows_saas
124release:gitlab:
124 stage: build
125 stage: release
125 rules:
126 image: registry.gitlab.com/gitlab-org/release-cli:latest
126 - if: $CI_COMMIT_TAG
127 rules:
127 script:
128 - if: $CI_COMMIT_TAG
128 - cargo build --release
129 needs:
129 - New-Item -ItemType Directory -Force -Path dist | Out-Null
130 - build:linux-deb
130 - Copy-Item target\release\posprint.exe dist\
131 - build:linux-arch
131 artifacts:
132 - build:windows
132 name: "posprint-windows-$CI_COMMIT_TAG"
133 script:
133 paths:
134 - |
134 - dist/posprint.exe
135 release-cli create \
135 expire_in: 1 year
136 --name "posprint $CI_COMMIT_TAG" \
136
137 --tag-name "$CI_COMMIT_TAG" \
137release:gitlab:
138 --description "Cross-platform POS print designer release $CI_COMMIT_TAG" \
138 stage: release
139 --assets-link "{\"name\":\"Linux .deb (amd64)\",\"url\":\"${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/posprint_${CI_COMMIT_TAG#v}_amd64.deb?job=build%3Alinux-deb\",\"link_type\":\"package\"}" \
139 image: alpine:3.21
140 --assets-link "{\"name\":\"Arch Linux .pkg.tar.zst (x86_64)\",\"url\":\"${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/posprint_${CI_COMMIT_TAG#v}-1-x86_64.pkg.tar.zst?job=build%3Alinux-arch\",\"link_type\":\"package\"}" \
140 rules:
141 --assets-link "{\"name\":\"Linux binary tarball (x86_64, AUR posprint-bin)\",\"url\":\"${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/posprint-${CI_COMMIT_TAG#v}-x86_64.tar.gz?job=build%3Alinux-arch\",\"link_type\":\"package\"}" \
141 - if: $CI_COMMIT_TAG
142 --assets-link "{\"name\":\"Windows .exe\",\"url\":\"${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_TAG}/raw/dist/posprint.exe?job=build%3Awindows\",\"link_type\":\"package\"}"
142 needs:
143
143 - job: build:linux-deb
144publish:aur:
144 artifacts: true
145 stage: release
145 - job: build:linux-arch
146 image: archlinux/archlinux:base-devel
146 artifacts: true
147 rules:
147 - job: build:windows
148 - if: $CI_COMMIT_TAG
148 artifacts: true
149 needs:
149 before_script:
150 - release:gitlab
150 - apk add --no-cache bash curl jq
151 - job: build:linux-arch
151 - chmod +x scripts/publish-gitlab-release.sh
152 artifacts: true
152 script:
153 before_script:
153 # Discover real filenames in dist/ (cargo-deb uses posprint_<ver>-1_amd64.deb;
154 # Only tools needed to update the AUR git repo (no Rust GUI build deps).
154 # makepkg uses posprint-<ver>-1-x86_64.pkg.tar.zst). Upload them to the
155 # Do not install package name "cargo" — it prompts for a provider (rust vs rustup).
155 # Generic Package Registry and attach durable Release download links.
156 - pacman -Syu --noconfirm
156 - ./scripts/publish-gitlab-release.sh
157 - pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux
157
158 - chmod +x scripts/aur-ssh-setup.sh
158publish:aur:
159 - ./scripts/aur-ssh-setup.sh
159 stage: release
160 script:
160 image: archlinux/archlinux:base-devel
161 - chmod +x scripts/publish-aur.sh
161 rules:
162 - ./scripts/publish-aur.sh "$CI_COMMIT_TAG"
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"
README.md +3 −3
@@ -46,10 +46,10 @@ All `${Parameters}` must be supplied via `--set NAME=VALUE` or the command fails
46 46 | Platform | Artifact | Install |
47 47 |----------|----------|---------|
48 48 | Linux (Debian/Ubuntu) | `.deb` (amd64) | `sudo dpkg -i posprint_*_amd64.deb` then `sudo apt-get install -f` |
49 | Linux (Arch) | `.pkg.tar.zst` (x86_64) | `sudo pacman -U posprint_*_x86_64.pkg.tar.zst` or AUR `posprint` / `posprint-bin` |
50 | Windows | `posprint.exe` | Download from GitLab release job artifacts |
49 | Linux (Arch) | `.pkg.tar.zst` (x86_64) | `sudo pacman -U posprint-*-x86_64.pkg.tar.zst` or AUR `posprint` / `posprint-bin` |
50 | Windows | `posprint.exe` | Download from the GitLab Release / Package Registry |
51 51
52 Tag a version (e.g. `0.4.0`) to trigger release builds. If AUR publishing is configured, the same tag pipeline also updates the `posprint` and `posprint-bin` AUR packages.
52 Tag a version (e.g. `0.4.0`) to trigger release builds. Downloads are uploaded to the **Generic Package Registry** and attached to the GitLab Release (job-artifact permalinks are not used). If AUR publishing is configured, the same tag pipeline also updates the `posprint` and `posprint-bin` AUR packages.
53 53
54 54 ## Features
55 55
@@ -46,10 +46,10 @@ All `${Parameters}` must be supplied via `--set NAME=VALUE` or the command fails
46| Platform | Artifact | Install |
46| Platform | Artifact | Install |
47|----------|----------|---------|
47|----------|----------|---------|
48| Linux (Debian/Ubuntu) | `.deb` (amd64) | `sudo dpkg -i posprint_*_amd64.deb` then `sudo apt-get install -f` |
48| Linux (Debian/Ubuntu) | `.deb` (amd64) | `sudo dpkg -i posprint_*_amd64.deb` then `sudo apt-get install -f` |
49| Linux (Arch) | `.pkg.tar.zst` (x86_64) | `sudo pacman -U posprint_*_x86_64.pkg.tar.zst` or AUR `posprint` / `posprint-bin` |
49| Linux (Arch) | `.pkg.tar.zst` (x86_64) | `sudo pacman -U posprint-*-x86_64.pkg.tar.zst` or AUR `posprint` / `posprint-bin` |
50| Windows | `posprint.exe` | Download from GitLab release job artifacts |
50| Windows | `posprint.exe` | Download from the GitLab Release / Package Registry |
51
51
52Tag a version (e.g. `0.4.0`) to trigger release builds. If AUR publishing is configured, the same tag pipeline also updates the `posprint` and `posprint-bin` AUR packages.
52Tag a version (e.g. `0.4.0`) to trigger release builds. Downloads are uploaded to the **Generic Package Registry** and attached to the GitLab Release (job-artifact permalinks are not used). If AUR publishing is configured, the same tag pipeline also updates the `posprint` and `posprint-bin` AUR packages.
53
53
54## Features
54## Features
55
55
docs/ARCHITECTURE.md +1 −1
@@ -174,7 +174,7 @@ Run: `cargo test` (~100 tests). CI: tests on merge requests; release artifacts o
174 174 ## Build and release
175 175
176 176 - **CI:** GitLab (`.gitlab-ci.yml`)
177 - **Artifacts:** Windows `.exe`, Debian `.deb`, Arch `.pkg.tar.zst`, Linux `posprint-<ver>-x86_64.tar.gz` (AUR `posprint-bin`)
177 - **Artifacts:** Windows `.exe`, Debian `posprint_<ver>-1_amd64.deb`, Arch `posprint-<ver>-1-x86_64.pkg.tar.zst`, Linux `posprint-<ver>-x86_64.tar.gz` (AUR `posprint-bin`). Tag pipelines upload these to the **Generic Package Registry** and attach them to the GitLab Release.
178 178 - **AUR:** source package `posprint` and binary package `posprint-bin` (see [AUR.md](AUR.md))
179 179 - **Versioning:** Semver in `Cargo.toml`; `.pos` `version` for file-format migrations
180 180
@@ -174,7 +174,7 @@ Run: `cargo test` (~100 tests). CI: tests on merge requests; release artifacts o
174## Build and release
174## Build and release
175
175
176- **CI:** GitLab (`.gitlab-ci.yml`)
176- **CI:** GitLab (`.gitlab-ci.yml`)
177- **Artifacts:** Windows `.exe`, Debian `.deb`, Arch `.pkg.tar.zst`, Linux `posprint-<ver>-x86_64.tar.gz` (AUR `posprint-bin`)
177- **Artifacts:** Windows `.exe`, Debian `posprint_<ver>-1_amd64.deb`, Arch `posprint-<ver>-1-x86_64.pkg.tar.zst`, Linux `posprint-<ver>-x86_64.tar.gz` (AUR `posprint-bin`). Tag pipelines upload these to the **Generic Package Registry** and attach them to the GitLab Release.
178- **AUR:** source package `posprint` and binary package `posprint-bin` (see [AUR.md](AUR.md))
178- **AUR:** source package `posprint` and binary package `posprint-bin` (see [AUR.md](AUR.md))
179- **Versioning:** Semver in `Cargo.toml`; `.pos` `version` for file-format migrations
179- **Versioning:** Semver in `Cargo.toml`; `.pos` `version` for file-format migrations
180
180
docs/AUR.md +37 −8
@@ -16,13 +16,15 @@ The source package downloads:
16 16 https://gitlab.com/Timfa/posprint/-/archive/<version>/posprint-<version>.tar.gz
17 17 ```
18 18
19 The binary package downloads:
19 The binary package downloads the **Generic Package Registry** tarball (durable; does not depend on job-artifact permalinks):
20 20
21 21 ```text
22 https://gitlab.com/Timfa/posprint/-/jobs/artifacts/<version>/raw/dist/posprint-<version>-x86_64.tar.gz?job=build:linux-arch
22 https://gitlab.com/api/v4/projects/Timfa%2Fposprint/packages/generic/posprint/<version>/posprint-<version>-x86_64.tar.gz
23 23 ```
24 24
25 That tarball is packed from the Arch CI package (`usr/` only). `posprint` and `posprint-bin` **conflict**; `posprint-bin` **provides** `posprint`.
25 Do **not** use `/-/jobs/artifacts/<tag>/raw/...?job=build:linux-arch`. That permalink only serves the latest *successful* pipeline for the tag, so it 404s while the tag pipeline is still running and after a later job (for example AUR publish) fails.
26
27 That tarball is packed from the **non-debug** Arch CI package (`usr/` only). `posprint` and `posprint-bin` **conflict**; `posprint-bin` **provides** `posprint`.
26 28
27 29 ## Files in this repo
28 30
@@ -32,7 +34,8 @@ That tarball is packed from the Arch CI package (`usr/` only). `posprint` and `p
32 34 | `packaging/aur/.SRCINFO` | Initial generated metadata (source) |
33 35 | `packaging/aur-bin/PKGBUILD` | AUR binary package template |
34 36 | `packaging/aur-bin/.SRCINFO` | Initial generated metadata (binary) |
35 | `scripts/make-linux-bin-tarball.sh` | Pack `usr/` from `.pkg.tar.zst` for `posprint-bin` |
37 | `scripts/make-linux-bin-tarball.sh` | Pack `usr/` from the non-debug `.pkg.tar.zst` for `posprint-bin` |
38 | `scripts/publish-gitlab-release.sh` | Upload `dist/` files to the Generic Package Registry and attach them to the GitLab Release |
36 39 | `scripts/publish-aur.sh` | Update both AUR repos (`posprint` and `posprint-bin`) |
37 40 | `scripts/aur-ssh-setup.sh` | Install SSH key from GitLab File or base64 variable |
38 41 | `scripts/bootstrap-aur-repo.sh` | One-time initial push to create an AUR repo |
@@ -42,18 +45,44 @@ That tarball is packed from the Arch CI package (`usr/` only). `posprint` and `p
42 45
43 46 When a Git tag is pushed:
44 47
45 1. GitLab builds the normal release artifacts, including `posprint-<version>-x86_64.tar.gz`.
46 2. GitLab creates the upstream release (with a link to that tarball).
47 3. GitLab runs `scripts/publish-aur.sh "$CI_COMMIT_TAG"`.
48 1. GitLab builds the normal release artifacts, including `posprint-<version>-x86_64.tar.gz` from the **non-debug** Arch package.
49 2. `release:gitlab` uploads those files to the Generic Package Registry and creates/updates the GitLab Release (download URLs stay valid even if a later job fails).
50 3. GitLab runs `scripts/publish-aur.sh "$CI_COMMIT_TAG"` with `needs:` artifacts from `build:linux-arch` (the tarball is already in `dist/`).
48 51 4. The script:
49 52 - downloads the tagged **source** tarball and hashes it
50 - uses the CI **binary** tarball from `dist/` (or downloads the job artifact) and hashes it
53 - uses the CI **binary** tarball from `dist/` (or, if missing, the Generic Package Registry) and hashes it
51 54 - clones each AUR repo (`posprint`, `posprint-bin`), or creates it on first push
52 55 - updates `pkgver`, `pkgrel`, and `sha256sums`
53 56 - regenerates `.SRCINFO` via `makepkg --printsrcinfo` (as non-root `aurbuild` when CI runs as root; parent tempdir is made traversable and `BUILDDIR` is forced under that user)
54 57 - strips a leading `v` from the tag when resolving GitLab URLs
55 58 - commits and pushes to each AUR `master`
56 59
60 `publish:aur` has `allow_failure: true` so an AUR outage cannot mark the whole tag pipeline failed (that used to 404 every `jobs/artifacts/<tag>` download). Prefer the job succeeding.
61
62 ### Refreshing tag 0.5.7 (or any already-pushed tag)
63
64 CI YAML is read from the **tagged commit**. Retrying jobs on an old 0.5.7 pipeline will not pick up these fixes.
65
66 After this change is on `master`:
67
68 1. Delete the GitLab Release for `0.5.7` if it still exists (Deploy → Releases), or let the new pipeline update it.
69 2. Delete and recreate the tag on the merge commit:
70
71 ```bash
72 git checkout master
73 git pull origin master
74 git tag -d 0.5.7
75 git push origin :refs/tags/0.5.7
76 git tag 0.5.7
77 git push origin 0.5.7
78 ```
79
80 3. Wait for the new tag pipeline. Source AUR `posprint` is already 0.5.7; a retag changes the GitLab archive hash, so publish will push an updated `sha256sums` (same `pkgver`, not a second version bump). `posprint-bin` was never published for 0.5.7 and will be created on the first successful run.
81
82 Do **not** only retry `publish:aur` on the failed 0.5.7 pipeline — that job still has no `dist/*.tar.gz` and still curls a 404 permalink.
83
84 Alternative if you do not want to move the tag: bump to **0.5.8** and tag that instead.
85
57 86 ## GitLab CI secrets
58 87
59 88 GitLab **masked** variables cannot contain spaces or newlines. An OpenSSH private key is multiline, so do **not** paste the raw private key into a masked **Variable**.
@@ -16,13 +16,15 @@ The source package downloads:
16https://gitlab.com/Timfa/posprint/-/archive/<version>/posprint-<version>.tar.gz
16https://gitlab.com/Timfa/posprint/-/archive/<version>/posprint-<version>.tar.gz
17```
17```
18
18
19The binary package downloads:
19The binary package downloads the **Generic Package Registry** tarball (durable; does not depend on job-artifact permalinks):
20
20
21```text
21```text
22https://gitlab.com/Timfa/posprint/-/jobs/artifacts/<version>/raw/dist/posprint-<version>-x86_64.tar.gz?job=build:linux-arch
22https://gitlab.com/api/v4/projects/Timfa%2Fposprint/packages/generic/posprint/<version>/posprint-<version>-x86_64.tar.gz
23```
23```
24
24
25That tarball is packed from the Arch CI package (`usr/` only). `posprint` and `posprint-bin` **conflict**; `posprint-bin` **provides** `posprint`.
25Do **not** use `/-/jobs/artifacts/<tag>/raw/...?job=build:linux-arch`. That permalink only serves the latest *successful* pipeline for the tag, so it 404s while the tag pipeline is still running and after a later job (for example AUR publish) fails.
26
27That tarball is packed from the **non-debug** Arch CI package (`usr/` only). `posprint` and `posprint-bin` **conflict**; `posprint-bin` **provides** `posprint`.
26
28
27## Files in this repo
29## Files in this repo
28
30
@@ -32,7 +34,8 @@ That tarball is packed from the Arch CI package (`usr/` only). `posprint` and `p
32| `packaging/aur/.SRCINFO` | Initial generated metadata (source) |
34| `packaging/aur/.SRCINFO` | Initial generated metadata (source) |
33| `packaging/aur-bin/PKGBUILD` | AUR binary package template |
35| `packaging/aur-bin/PKGBUILD` | AUR binary package template |
34| `packaging/aur-bin/.SRCINFO` | Initial generated metadata (binary) |
36| `packaging/aur-bin/.SRCINFO` | Initial generated metadata (binary) |
35| `scripts/make-linux-bin-tarball.sh` | Pack `usr/` from `.pkg.tar.zst` for `posprint-bin` |
37| `scripts/make-linux-bin-tarball.sh` | Pack `usr/` from the non-debug `.pkg.tar.zst` for `posprint-bin` |
38| `scripts/publish-gitlab-release.sh` | Upload `dist/` files to the Generic Package Registry and attach them to the GitLab Release |
36| `scripts/publish-aur.sh` | Update both AUR repos (`posprint` and `posprint-bin`) |
39| `scripts/publish-aur.sh` | Update both AUR repos (`posprint` and `posprint-bin`) |
37| `scripts/aur-ssh-setup.sh` | Install SSH key from GitLab File or base64 variable |
40| `scripts/aur-ssh-setup.sh` | Install SSH key from GitLab File or base64 variable |
38| `scripts/bootstrap-aur-repo.sh` | One-time initial push to create an AUR repo |
41| `scripts/bootstrap-aur-repo.sh` | One-time initial push to create an AUR repo |
@@ -42,18 +45,44 @@ That tarball is packed from the Arch CI package (`usr/` only). `posprint` and `p
42
45
43When a Git tag is pushed:
46When a Git tag is pushed:
44
47
451. GitLab builds the normal release artifacts, including `posprint-<version>-x86_64.tar.gz`.
481. GitLab builds the normal release artifacts, including `posprint-<version>-x86_64.tar.gz` from the **non-debug** Arch package.
462. GitLab creates the upstream release (with a link to that tarball).
492. `release:gitlab` uploads those files to the Generic Package Registry and creates/updates the GitLab Release (download URLs stay valid even if a later job fails).
473. GitLab runs `scripts/publish-aur.sh "$CI_COMMIT_TAG"`.
503. GitLab runs `scripts/publish-aur.sh "$CI_COMMIT_TAG"` with `needs:` artifacts from `build:linux-arch` (the tarball is already in `dist/`).
484. The script:
514. The script:
49 - downloads the tagged **source** tarball and hashes it
52 - downloads the tagged **source** tarball and hashes it
50 - uses the CI **binary** tarball from `dist/` (or downloads the job artifact) and hashes it
53 - uses the CI **binary** tarball from `dist/` (or, if missing, the Generic Package Registry) and hashes it
51 - clones each AUR repo (`posprint`, `posprint-bin`), or creates it on first push
54 - clones each AUR repo (`posprint`, `posprint-bin`), or creates it on first push
52 - updates `pkgver`, `pkgrel`, and `sha256sums`
55 - updates `pkgver`, `pkgrel`, and `sha256sums`
53 - regenerates `.SRCINFO` via `makepkg --printsrcinfo` (as non-root `aurbuild` when CI runs as root; parent tempdir is made traversable and `BUILDDIR` is forced under that user)
56 - regenerates `.SRCINFO` via `makepkg --printsrcinfo` (as non-root `aurbuild` when CI runs as root; parent tempdir is made traversable and `BUILDDIR` is forced under that user)
54 - strips a leading `v` from the tag when resolving GitLab URLs
57 - strips a leading `v` from the tag when resolving GitLab URLs
55 - commits and pushes to each AUR `master`
58 - commits and pushes to each AUR `master`
56
59
60`publish:aur` has `allow_failure: true` so an AUR outage cannot mark the whole tag pipeline failed (that used to 404 every `jobs/artifacts/<tag>` download). Prefer the job succeeding.
61
62### Refreshing tag 0.5.7 (or any already-pushed tag)
63
64CI YAML is read from the **tagged commit**. Retrying jobs on an old 0.5.7 pipeline will not pick up these fixes.
65
66After this change is on `master`:
67
681. Delete the GitLab Release for `0.5.7` if it still exists (Deploy → Releases), or let the new pipeline update it.
692. Delete and recreate the tag on the merge commit:
70
71```bash
72git checkout master
73git pull origin master
74git tag -d 0.5.7
75git push origin :refs/tags/0.5.7
76git tag 0.5.7
77git push origin 0.5.7
78```
79
803. Wait for the new tag pipeline. Source AUR `posprint` is already 0.5.7; a retag changes the GitLab archive hash, so publish will push an updated `sha256sums` (same `pkgver`, not a second version bump). `posprint-bin` was never published for 0.5.7 and will be created on the first successful run.
81
82Do **not** only retry `publish:aur` on the failed 0.5.7 pipeline — that job still has no `dist/*.tar.gz` and still curls a 404 permalink.
83
84Alternative if you do not want to move the tag: bump to **0.5.8** and tag that instead.
85
57## GitLab CI secrets
86## GitLab CI secrets
58
87
59GitLab **masked** variables cannot contain spaces or newlines. An OpenSSH private key is multiline, so do **not** paste the raw private key into a masked **Variable**.
88GitLab **masked** variables cannot contain spaces or newlines. An OpenSSH private key is multiline, so do **not** paste the raw private key into a masked **Variable**.
docs/BUILD.md +10 −6
@@ -65,8 +65,9 @@ Outputs:
65 65 | Artifact | Path |
66 66 |----------|------|
67 67 | Binary | `target/release/posprint` |
68 | Debian package | `target/debian/*.deb` |
69 | Arch package | `packaging/arch/posprint-*-x86_64.pkg.tar.zst` |
68 | Debian package | `target/debian/posprint_<ver>-1_amd64.deb` (`cargo-deb` revision defaults to `1`) |
69 | Arch package | `packaging/arch/posprint-<ver>-1-x86_64.pkg.tar.zst` (hyphens; not `posprint_<ver>`) |
70 | AUR bin tarball | `dist/posprint-<ver>-x86_64.tar.gz` (packed from the non-debug Arch package) |
70 71
71 72 ### Linux targets we support
72 73
@@ -109,12 +110,15 @@ Automated AUR publishing uses:
109 110
110 111 - `packaging/aur/PKGBUILD` — source package (`posprint`)
111 112 - `packaging/aur-bin/PKGBUILD` — binary package (`posprint-bin`)
112 - `scripts/publish-aur.sh` — updates both AUR repos on tags
113 - `scripts/make-linux-bin-tarball.sh` — packs `usr/` from the Arch CI `.pkg.tar.zst`
113 - `scripts/publish-aur.sh` — updates both AUR repos on tags (uses the local `dist/` tarball from `build:linux-arch`)
114 - `scripts/make-linux-bin-tarball.sh` — packs `usr/` from the **non-debug** Arch CI `.pkg.tar.zst`
115 - `scripts/publish-gitlab-release.sh` — uploads real `dist/` filenames to the Generic Package Registry and attaches them to the GitLab Release
114 116
115 The source package builds from the GitLab tag tarball. The binary package installs a prebuilt tree from CI.
117 The source package builds from the GitLab tag tarball. The binary package installs a prebuilt tree from the Generic Package Registry (not `jobs/artifacts/<tag>` permalinks).
116 118
117 Setup and required GitLab secrets are documented in [AUR.md](AUR.md).
119 Tag pipelines also keep job artifacts for a year, but **Release / Package Registry URLs are the ones that stay downloadable** if a later job fails.
120
121 Setup and required GitLab secrets are documented in [AUR.md](AUR.md). To refresh an already-shipped tag (for example 0.5.7), delete and recreate that tag on a commit that contains the current `.gitlab-ci.yml` — see [AUR.md](AUR.md#refreshing-tag-057-or-any-already-pushed-tag).
118 122
119 123 ### File association (`.pos` → posprint)
120 124
@@ -65,8 +65,9 @@ Outputs:
65| Artifact | Path |
65| Artifact | Path |
66|----------|------|
66|----------|------|
67| Binary | `target/release/posprint` |
67| Binary | `target/release/posprint` |
68| Debian package | `target/debian/*.deb` |
68| Debian package | `target/debian/posprint_<ver>-1_amd64.deb` (`cargo-deb` revision defaults to `1`) |
69| Arch package | `packaging/arch/posprint-*-x86_64.pkg.tar.zst` |
69| Arch package | `packaging/arch/posprint-<ver>-1-x86_64.pkg.tar.zst` (hyphens; not `posprint_<ver>`) |
70| AUR bin tarball | `dist/posprint-<ver>-x86_64.tar.gz` (packed from the non-debug Arch package) |
70
71
71### Linux targets we support
72### Linux targets we support
72
73
@@ -109,12 +110,15 @@ Automated AUR publishing uses:
109
110
110- `packaging/aur/PKGBUILD` — source package (`posprint`)
111- `packaging/aur/PKGBUILD` — source package (`posprint`)
111- `packaging/aur-bin/PKGBUILD` — binary package (`posprint-bin`)
112- `packaging/aur-bin/PKGBUILD` — binary package (`posprint-bin`)
112- `scripts/publish-aur.sh` — updates both AUR repos on tags
113- `scripts/publish-aur.sh` — updates both AUR repos on tags (uses the local `dist/` tarball from `build:linux-arch`)
113- `scripts/make-linux-bin-tarball.sh` — packs `usr/` from the Arch CI `.pkg.tar.zst`
114- `scripts/make-linux-bin-tarball.sh` — packs `usr/` from the **non-debug** Arch CI `.pkg.tar.zst`
115- `scripts/publish-gitlab-release.sh` — uploads real `dist/` filenames to the Generic Package Registry and attaches them to the GitLab Release
114
116
115The source package builds from the GitLab tag tarball. The binary package installs a prebuilt tree from CI.
117The source package builds from the GitLab tag tarball. The binary package installs a prebuilt tree from the Generic Package Registry (not `jobs/artifacts/<tag>` permalinks).
116
118
117Setup and required GitLab secrets are documented in [AUR.md](AUR.md).
119Tag pipelines also keep job artifacts for a year, but **Release / Package Registry URLs are the ones that stay downloadable** if a later job fails.
120
121Setup and required GitLab secrets are documented in [AUR.md](AUR.md). To refresh an already-shipped tag (for example 0.5.7), delete and recreate that tag on a commit that contains the current `.gitlab-ci.yml` — see [AUR.md](AUR.md#refreshing-tag-057-or-any-already-pushed-tag).
118
122
119### File association (`.pos` → posprint)
123### File association (`.pos` → posprint)
120
124
packaging/arch/PKGBUILD +3 −1
@@ -20,7 +20,9 @@ depends=(
20 20 'libglvnd'
21 21 )
22 22 makedepends=('rust' 'cargo' 'pkgconf' 'git')
23 options=('!lto')
23 # !debug: recent makepkg.conf enables debug split packages; those scramble
24 # CI globs (posprint-*.pkg.tar.zst) and are not shipped as release assets.
25 options=('!lto' '!debug')
24 26 source=()
25 27 sha256sums=()
26 28
@@ -20,7 +20,9 @@ depends=(
20 'libglvnd'
20 'libglvnd'
21)
21)
22makedepends=('rust' 'cargo' 'pkgconf' 'git')
22makedepends=('rust' 'cargo' 'pkgconf' 'git')
23options=('!lto')
23# !debug: recent makepkg.conf enables debug split packages; those scramble
24# CI globs (posprint-*.pkg.tar.zst) and are not shipped as release assets.
25options=('!lto' '!debug')
24source=()
26source=()
25sha256sums=()
27sha256sums=()
26
28
packaging/aur-bin/.SRCINFO +25 −25
@@ -1,25 +1,25 @@
1 pkgbase = posprint-bin
2 pkgdesc = Designer for POS-print documents with live preview and USB ESC/POS printing (prebuilt binary)
3 pkgver = 0.5.7
4 pkgrel = 1
5 url = https://gitlab.com/Timfa/posprint
6 arch = x86_64
7 license = MIT
8 provides = posprint=0.5.7
9 conflicts = posprint
10 depends = gcc-libs
11 depends = libxkbcommon
12 depends = libxcb
13 depends = openssl
14 depends = dbus
15 depends = wayland
16 depends = libx11
17 depends = fontconfig
18 depends = freetype2
19 depends = libglvnd
20 options = !strip
21 options = !debug
22 source = posprint-0.5.7-x86_64.tar.gz::https://gitlab.com/Timfa/posprint/-/jobs/artifacts/0.5.7/raw/dist/posprint-0.5.7-x86_64.tar.gz?job=build:linux-arch
23 sha256sums = 0000000000000000000000000000000000000000000000000000000000000000
24
25 pkgname = posprint-bin
1 pkgbase = posprint-bin
2 pkgdesc = Designer for POS-print documents with live preview and USB ESC/POS printing (prebuilt binary)
3 pkgver = 0.5.7
4 pkgrel = 1
5 url = https://gitlab.com/Timfa/posprint
6 arch = x86_64
7 license = MIT
8 provides = posprint=0.5.7
9 conflicts = posprint
10 depends = gcc-libs
11 depends = libxkbcommon
12 depends = libxcb
13 depends = openssl
14 depends = dbus
15 depends = wayland
16 depends = libx11
17 depends = fontconfig
18 depends = freetype2
19 depends = libglvnd
20 options = !strip
21 options = !debug
22 source = posprint-0.5.7-x86_64.tar.gz::https://gitlab.com/api/v4/projects/Timfa%2Fposprint/packages/generic/posprint/0.5.7/posprint-0.5.7-x86_64.tar.gz
23 sha256sums = 0000000000000000000000000000000000000000000000000000000000000000
24
25 pkgname = posprint-bin
@@ -1,25 +1,25 @@
1pkgbase = posprint-bin
1pkgbase = posprint-bin
2 pkgdesc = Designer for POS-print documents with live preview and USB ESC/POS printing (prebuilt binary)
2 pkgdesc = Designer for POS-print documents with live preview and USB ESC/POS printing (prebuilt binary)
3 pkgver = 0.5.7
3 pkgver = 0.5.7
4 pkgrel = 1
4 pkgrel = 1
5 url = https://gitlab.com/Timfa/posprint
5 url = https://gitlab.com/Timfa/posprint
6 arch = x86_64
6 arch = x86_64
7 license = MIT
7 license = MIT
8 provides = posprint=0.5.7
8 provides = posprint=0.5.7
9 conflicts = posprint
9 conflicts = posprint
10 depends = gcc-libs
10 depends = gcc-libs
11 depends = libxkbcommon
11 depends = libxkbcommon
12 depends = libxcb
12 depends = libxcb
13 depends = openssl
13 depends = openssl
14 depends = dbus
14 depends = dbus
15 depends = wayland
15 depends = wayland
16 depends = libx11
16 depends = libx11
17 depends = fontconfig
17 depends = fontconfig
18 depends = freetype2
18 depends = freetype2
19 depends = libglvnd
19 depends = libglvnd
20 options = !strip
20 options = !strip
21 options = !debug
21 options = !debug
22 source = posprint-0.5.7-x86_64.tar.gz::https://gitlab.com/Timfa/posprint/-/jobs/artifacts/0.5.7/raw/dist/posprint-0.5.7-x86_64.tar.gz?job=build:linux-arch
22 source = posprint-0.5.7-x86_64.tar.gz::https://gitlab.com/api/v4/projects/Timfa%2Fposprint/packages/generic/posprint/0.5.7/posprint-0.5.7-x86_64.tar.gz
23 sha256sums = 0000000000000000000000000000000000000000000000000000000000000000
23 sha256sums = 0000000000000000000000000000000000000000000000000000000000000000
24
24
25pkgname = posprint-bin
25pkgname = posprint-bin
packaging/aur-bin/PKGBUILD +1 −1
@@ -21,7 +21,7 @@ depends=(
21 21 provides=("posprint=${pkgver}")
22 22 conflicts=('posprint')
23 23 options=('!strip' '!debug')
24 source=("posprint-${pkgver}-x86_64.tar.gz::https://gitlab.com/Timfa/posprint/-/jobs/artifacts/${pkgver}/raw/dist/posprint-${pkgver}-x86_64.tar.gz?job=build:linux-arch")
24 source=("posprint-${pkgver}-x86_64.tar.gz::https://gitlab.com/api/v4/projects/Timfa%2Fposprint/packages/generic/posprint/${pkgver}/posprint-${pkgver}-x86_64.tar.gz")
25 25 sha256sums=('0000000000000000000000000000000000000000000000000000000000000000')
26 26
27 27 package() {
@@ -21,7 +21,7 @@ depends=(
21provides=("posprint=${pkgver}")
21provides=("posprint=${pkgver}")
22conflicts=('posprint')
22conflicts=('posprint')
23options=('!strip' '!debug')
23options=('!strip' '!debug')
24source=("posprint-${pkgver}-x86_64.tar.gz::https://gitlab.com/Timfa/posprint/-/jobs/artifacts/${pkgver}/raw/dist/posprint-${pkgver}-x86_64.tar.gz?job=build:linux-arch")
24source=("posprint-${pkgver}-x86_64.tar.gz::https://gitlab.com/api/v4/projects/Timfa%2Fposprint/packages/generic/posprint/${pkgver}/posprint-${pkgver}-x86_64.tar.gz")
25sha256sums=('0000000000000000000000000000000000000000000000000000000000000000')
25sha256sums=('0000000000000000000000000000000000000000000000000000000000000000')
26
26
27package() {
27package() {
scripts/make-linux-bin-tarball.sh +83 −10
@@ -1,21 +1,85 @@
1 1 #!/usr/bin/env bash
2 2 # Pack usr/ from an Arch .pkg.tar.zst into posprint-<ver>-x86_64.tar.gz for AUR posprint-bin.
3 #
4 # Usage:
5 # make-linux-bin-tarball.sh [posprint-*.pkg.tar.zst ...] [out.tar.gz] [version]
6 #
7 # Extra .pkg.tar.zst arguments (e.g. a shell glob that also matches the debug
8 # split package) are ignored; only the non-debug package is used. The tarball is
9 # never written over a package path.
3 10 set -euo pipefail
4 11
5 12 ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6 PKG_ZST="${1:-}"
7 OUT="${2:-}"
8 VERSION="${3:-}"
9 13
10 if [[ -z "$PKG_ZST" ]]; then
14 is_debug_pkg() {
15 local base
16 base="$(basename -- "$1")"
17 # Arch debug split packages: posprint-debug-<ver>-<rel>-<arch>.pkg.tar.zst
18 [[ "$base" == posprint-debug-* || "$base" == *-debug-*.pkg.tar.zst ]]
19 }
20
21 is_pkg() {
22 [[ "$1" == *.pkg.tar.zst || "$1" == *.pkg.tar ]]
23 }
24
25 is_tarball_out() {
26 [[ "$1" == *.tar.gz ]]
27 }
28
29 looks_like_version() {
30 [[ "$1" =~ ^v?[0-9]+\.[0-9]+ ]]
31 }
32
33 PKG_CANDIDATES=()
34 OUT=""
35 VERSION=""
36 UNKNOWN=()
37
38 for arg in "$@"; do
39 if is_pkg "$arg"; then
40 PKG_CANDIDATES+=("$arg")
41 elif is_tarball_out "$arg"; then
42 if [[ -n "$OUT" ]]; then
43 echo "Multiple output paths: $OUT and $arg" >&2
44 exit 1
45 fi
46 OUT="$arg"
47 elif looks_like_version "$arg"; then
48 VERSION="$arg"
49 else
50 UNKNOWN+=("$arg")
51 fi
52 done
53
54 if [[ ${#UNKNOWN[@]} -gt 0 ]]; then
55 echo "Unexpected arguments: ${UNKNOWN[*]}" >&2
56 echo "Usage: $0 [posprint-*.pkg.tar.zst ...] [out.tar.gz] [version]" >&2
57 exit 1
58 fi
59
60 if [[ ${#PKG_CANDIDATES[@]} -eq 0 ]]; then
11 61 shopt -s nullglob
12 candidates=("$ROOT"/packaging/arch/*.pkg.tar.zst "$ROOT"/dist/*.pkg.tar.zst)
62 PKG_CANDIDATES=("$ROOT"/packaging/arch/posprint-*.pkg.tar.zst "$ROOT"/dist/posprint-*.pkg.tar.zst)
13 63 shopt -u nullglob
14 if [[ ${#candidates[@]} -eq 0 ]]; then
15 echo "Usage: $0 <posprint-*.pkg.tar.zst> [out.tar.gz] [version]" >&2
16 exit 1
64 fi
65
66 PKG_ZST=""
67 for candidate in "${PKG_CANDIDATES[@]+"${PKG_CANDIDATES[@]}"}"; do
68 if ! is_debug_pkg "$candidate"; then
69 PKG_ZST="$candidate"
70 break
17 71 fi
18 PKG_ZST="${candidates[0]}"
72 done
73
74 if [[ -z "$PKG_ZST" ]]; then
75 echo "Usage: $0 <posprint-*.pkg.tar.zst> [out.tar.gz] [version]" >&2
76 echo "No non-debug Arch package found." >&2
77 exit 1
78 fi
79
80 if [[ ! -f "$PKG_ZST" ]]; then
81 echo "Package not found: $PKG_ZST" >&2
82 exit 1
19 83 fi
20 84
21 85 if [[ -z "$VERSION" ]]; then
@@ -28,6 +92,11 @@ if [[ -z "$OUT" ]]; then
28 92 OUT="$ROOT/dist/posprint-${VERSION}-x86_64.tar.gz"
29 93 fi
30 94
95 if is_pkg "$OUT"; then
96 echo "Refusing to write tarball over package path: $OUT" >&2
97 exit 1
98 fi
99
31 100 EXTRACT="$(mktemp -d)"
32 101 cleanup() { rm -rf "$EXTRACT"; }
33 102 trap cleanup EXIT
@@ -45,4 +114,8 @@ fi
45 114
46 115 mkdir -p "$(dirname "$OUT")"
47 116 tar -C "$EXTRACT" -czf "$OUT" usr
48 echo "Wrote $OUT"
117 if [[ ! -s "$OUT" ]]; then
118 echo "Failed to write tarball: $OUT" >&2
119 exit 1
120 fi
121 echo "Wrote $OUT from $PKG_ZST"
@@ -1,21 +1,85 @@
1#!/usr/bin/env bash
1#!/usr/bin/env bash
2# Pack usr/ from an Arch .pkg.tar.zst into posprint-<ver>-x86_64.tar.gz for AUR posprint-bin.
2# Pack usr/ from an Arch .pkg.tar.zst into posprint-<ver>-x86_64.tar.gz for AUR posprint-bin.
3#
4# Usage:
5# make-linux-bin-tarball.sh [posprint-*.pkg.tar.zst ...] [out.tar.gz] [version]
6#
7# Extra .pkg.tar.zst arguments (e.g. a shell glob that also matches the debug
8# split package) are ignored; only the non-debug package is used. The tarball is
9# never written over a package path.
3set -euo pipefail
10set -euo pipefail
4
11
5ROOT="$(cd "$(dirname "$0")/.." && pwd)"
12ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6PKG_ZST="${1:-}"
7OUT="${2:-}"
8VERSION="${3:-}"
9
13
10if [[ -z "$PKG_ZST" ]]; then
14is_debug_pkg() {
15 local base
16 base="$(basename -- "$1")"
17 # Arch debug split packages: posprint-debug-<ver>-<rel>-<arch>.pkg.tar.zst
18 [[ "$base" == posprint-debug-* || "$base" == *-debug-*.pkg.tar.zst ]]
19}
20
21is_pkg() {
22 [[ "$1" == *.pkg.tar.zst || "$1" == *.pkg.tar ]]
23}
24
25is_tarball_out() {
26 [[ "$1" == *.tar.gz ]]
27}
28
29looks_like_version() {
30 [[ "$1" =~ ^v?[0-9]+\.[0-9]+ ]]
31}
32
33PKG_CANDIDATES=()
34OUT=""
35VERSION=""
36UNKNOWN=()
37
38for arg in "$@"; do
39 if is_pkg "$arg"; then
40 PKG_CANDIDATES+=("$arg")
41 elif is_tarball_out "$arg"; then
42 if [[ -n "$OUT" ]]; then
43 echo "Multiple output paths: $OUT and $arg" >&2
44 exit 1
45 fi
46 OUT="$arg"
47 elif looks_like_version "$arg"; then
48 VERSION="$arg"
49 else
50 UNKNOWN+=("$arg")
51 fi
52done
53
54if [[ ${#UNKNOWN[@]} -gt 0 ]]; then
55 echo "Unexpected arguments: ${UNKNOWN[*]}" >&2
56 echo "Usage: $0 [posprint-*.pkg.tar.zst ...] [out.tar.gz] [version]" >&2
57 exit 1
58fi
59
60if [[ ${#PKG_CANDIDATES[@]} -eq 0 ]]; then
11 shopt -s nullglob
61 shopt -s nullglob
12 candidates=("$ROOT"/packaging/arch/*.pkg.tar.zst "$ROOT"/dist/*.pkg.tar.zst)
62 PKG_CANDIDATES=("$ROOT"/packaging/arch/posprint-*.pkg.tar.zst "$ROOT"/dist/posprint-*.pkg.tar.zst)
13 shopt -u nullglob
63 shopt -u nullglob
14 if [[ ${#candidates[@]} -eq 0 ]]; then
64fi
15 echo "Usage: $0 <posprint-*.pkg.tar.zst> [out.tar.gz] [version]" >&2
65
16 exit 1
66PKG_ZST=""
67for candidate in "${PKG_CANDIDATES[@]+"${PKG_CANDIDATES[@]}"}"; do
68 if ! is_debug_pkg "$candidate"; then
69 PKG_ZST="$candidate"
70 break
17 fi
71 fi
18 PKG_ZST="${candidates[0]}"
72done
73
74if [[ -z "$PKG_ZST" ]]; then
75 echo "Usage: $0 <posprint-*.pkg.tar.zst> [out.tar.gz] [version]" >&2
76 echo "No non-debug Arch package found." >&2
77 exit 1
78fi
79
80if [[ ! -f "$PKG_ZST" ]]; then
81 echo "Package not found: $PKG_ZST" >&2
82 exit 1
19fi
83fi
20
84
21if [[ -z "$VERSION" ]]; then
85if [[ -z "$VERSION" ]]; then
@@ -28,6 +92,11 @@ if [[ -z "$OUT" ]]; then
28 OUT="$ROOT/dist/posprint-${VERSION}-x86_64.tar.gz"
92 OUT="$ROOT/dist/posprint-${VERSION}-x86_64.tar.gz"
29fi
93fi
30
94
95if is_pkg "$OUT"; then
96 echo "Refusing to write tarball over package path: $OUT" >&2
97 exit 1
98fi
99
31EXTRACT="$(mktemp -d)"
100EXTRACT="$(mktemp -d)"
32cleanup() { rm -rf "$EXTRACT"; }
101cleanup() { rm -rf "$EXTRACT"; }
33trap cleanup EXIT
102trap cleanup EXIT
@@ -45,4 +114,8 @@ fi
45
114
46mkdir -p "$(dirname "$OUT")"
115mkdir -p "$(dirname "$OUT")"
47tar -C "$EXTRACT" -czf "$OUT" usr
116tar -C "$EXTRACT" -czf "$OUT" usr
48echo "Wrote $OUT"
117if [[ ! -s "$OUT" ]]; then
118 echo "Failed to write tarball: $OUT" >&2
119 exit 1
120fi
121echo "Wrote $OUT from $PKG_ZST"
scripts/publish-aur.sh +12 −4
@@ -26,7 +26,9 @@ fi
26 26
27 27 SOURCE_ARCHIVE_URL="https://gitlab.com/Timfa/posprint/-/archive/${VERSION}/posprint-${VERSION}.tar.gz"
28 28 BIN_TARBALL_NAME="posprint-${VERSION}-x86_64.tar.gz"
29 BIN_ARTIFACT_URL="https://gitlab.com/Timfa/posprint/-/jobs/artifacts/${VERSION}/raw/dist/${BIN_TARBALL_NAME}?job=build:linux-arch"
29 # Durable Generic Package Registry URL (not jobs/artifacts/TAG permalinks — those
30 # 404 while the tag pipeline is still running or if a later job failed).
31 BIN_PACKAGE_URL="${POSPRINT_GENERIC_PACKAGE_URL:-https://gitlab.com/api/v4/projects/Timfa%2Fposprint/packages/generic/posprint/${VERSION}/${BIN_TARBALL_NAME}}"
30 32
31 33 generate_srcinfo() {
32 34 # makepkg refuses root. mktemp parents are 0700 — aurbuild must be able to traverse
@@ -115,10 +117,16 @@ SOURCE_SHA="$(sha256sum "$TMP_SOURCE" | awk '{print $1}')"
115 117 publish_package "posprint" "packaging/aur" "$SOURCE_SHA"
116 118
117 119 BIN_TARBALL="$ROOT/dist/${BIN_TARBALL_NAME}"
118 if [[ ! -f "$BIN_TARBALL" ]]; then
119 echo "Binary tarball not in dist/; downloading $BIN_ARTIFACT_URL"
120 if [[ -f "$BIN_TARBALL" ]]; then
121 echo "Using local binary tarball: $BIN_TARBALL"
122 else
123 echo "Binary tarball not in dist/; downloading $BIN_PACKAGE_URL"
120 124 mkdir -p "$ROOT/dist"
121 curl -fsSL "$BIN_ARTIFACT_URL" -o "$BIN_TARBALL"
125 curl -fsSL "$BIN_PACKAGE_URL" -o "$BIN_TARBALL"
126 fi
127 if [[ ! -s "$BIN_TARBALL" ]]; then
128 echo "Missing binary tarball $BIN_TARBALL (build:linux-arch must produce dist/${BIN_TARBALL_NAME})" >&2
129 exit 1
122 130 fi
123 131 BIN_SHA="$(sha256sum "$BIN_TARBALL" | awk '{print $1}')"
124 132 publish_package "posprint-bin" "packaging/aur-bin" "$BIN_SHA"
@@ -26,7 +26,9 @@ fi
26
26
27SOURCE_ARCHIVE_URL="https://gitlab.com/Timfa/posprint/-/archive/${VERSION}/posprint-${VERSION}.tar.gz"
27SOURCE_ARCHIVE_URL="https://gitlab.com/Timfa/posprint/-/archive/${VERSION}/posprint-${VERSION}.tar.gz"
28BIN_TARBALL_NAME="posprint-${VERSION}-x86_64.tar.gz"
28BIN_TARBALL_NAME="posprint-${VERSION}-x86_64.tar.gz"
29BIN_ARTIFACT_URL="https://gitlab.com/Timfa/posprint/-/jobs/artifacts/${VERSION}/raw/dist/${BIN_TARBALL_NAME}?job=build:linux-arch"
29# Durable Generic Package Registry URL (not jobs/artifacts/TAG permalinks — those
30# 404 while the tag pipeline is still running or if a later job failed).
31BIN_PACKAGE_URL="${POSPRINT_GENERIC_PACKAGE_URL:-https://gitlab.com/api/v4/projects/Timfa%2Fposprint/packages/generic/posprint/${VERSION}/${BIN_TARBALL_NAME}}"
30
32
31generate_srcinfo() {
33generate_srcinfo() {
32 # makepkg refuses root. mktemp parents are 0700 — aurbuild must be able to traverse
34 # makepkg refuses root. mktemp parents are 0700 — aurbuild must be able to traverse
@@ -115,10 +117,16 @@ SOURCE_SHA="$(sha256sum "$TMP_SOURCE" | awk '{print $1}')"
115publish_package "posprint" "packaging/aur" "$SOURCE_SHA"
117publish_package "posprint" "packaging/aur" "$SOURCE_SHA"
116
118
117BIN_TARBALL="$ROOT/dist/${BIN_TARBALL_NAME}"
119BIN_TARBALL="$ROOT/dist/${BIN_TARBALL_NAME}"
118if [[ ! -f "$BIN_TARBALL" ]]; then
120if [[ -f "$BIN_TARBALL" ]]; then
119 echo "Binary tarball not in dist/; downloading $BIN_ARTIFACT_URL"
121 echo "Using local binary tarball: $BIN_TARBALL"
122else
123 echo "Binary tarball not in dist/; downloading $BIN_PACKAGE_URL"
120 mkdir -p "$ROOT/dist"
124 mkdir -p "$ROOT/dist"
121 curl -fsSL "$BIN_ARTIFACT_URL" -o "$BIN_TARBALL"
125 curl -fsSL "$BIN_PACKAGE_URL" -o "$BIN_TARBALL"
126fi
127if [[ ! -s "$BIN_TARBALL" ]]; then
128 echo "Missing binary tarball $BIN_TARBALL (build:linux-arch must produce dist/${BIN_TARBALL_NAME})" >&2
129 exit 1
122fi
130fi
123BIN_SHA="$(sha256sum "$BIN_TARBALL" | awk '{print $1}')"
131BIN_SHA="$(sha256sum "$BIN_TARBALL" | awk '{print $1}')"
124publish_package "posprint-bin" "packaging/aur-bin" "$BIN_SHA"
132publish_package "posprint-bin" "packaging/aur-bin" "$BIN_SHA"
scripts/publish-gitlab-release.sh added +264 −0
@@ -0,0 +1,264 @@
1 #!/usr/bin/env bash
2 # Upload dist/ release files to the GitLab Generic Package Registry and attach
3 # them to the GitLab Release so downloads do not depend on job-artifact
4 # permalinks (those 404 when the latest tag pipeline is failed or still running).
5 #
6 # Usage:
7 # publish-gitlab-release.sh [--dry-run] [--dist DIR] [tag]
8 #
9 # In CI, tag defaults to $CI_COMMIT_TAG. Dry-run prints the upload/link plan
10 # and does not call the GitLab API.
11 set -euo pipefail
12
13 ROOT="$(cd "$(dirname "$0")/.." && pwd)"
14 DIST="$ROOT/dist"
15 DRY_RUN=0
16 TAG="${CI_COMMIT_TAG:-}"
17
18 usage() {
19 echo "Usage: $0 [--dry-run] [--dist DIR] [tag]" >&2
20 exit 2
21 }
22
23 while [[ $# -gt 0 ]]; do
24 case "$1" in
25 --dry-run) DRY_RUN=1; shift ;;
26 --dist)
27 [[ $# -ge 2 ]] || usage
28 DIST="$2"
29 shift 2
30 ;;
31 -h|--help) usage ;;
32 *)
33 if [[ -n "$TAG" && "$TAG" != "$1" ]]; then
34 echo "Unexpected argument: $1" >&2
35 usage
36 fi
37 TAG="$1"
38 shift
39 ;;
40 esac
41 done
42
43 if [[ -z "$TAG" ]]; then
44 TAG="$(grep '^version = ' "$ROOT/Cargo.toml" | sed -E 's/.*"([^"]+)"/\1/')"
45 fi
46 VERSION="${TAG#v}"
47
48 is_debug_pkg() {
49 local base
50 base="$(basename -- "$1")"
51 [[ "$base" == posprint-debug-* || "$base" == *-debug-*.pkg.tar.zst ]]
52 }
53
54 # Prints: label<TAB>absolute-path
55 collect_assets() {
56 local f
57 shopt -s nullglob
58 local debs=("$DIST"/*.deb)
59 local pkgs=("$DIST"/posprint-*-x86_64.pkg.tar.zst)
60 local tgzs=("$DIST"/posprint-*-x86_64.tar.gz)
61 shopt -u nullglob
62
63 if [[ ${#debs[@]} -ne 1 ]]; then
64 echo "Expected exactly one .deb in $DIST, found ${#debs[@]}" >&2
65 ls -la "$DIST" >&2 || true
66 return 1
67 fi
68 printf '%s\t%s\n' "Linux .deb (amd64)" "${debs[0]}"
69
70 local main_pkg=""
71 for f in "${pkgs[@]+"${pkgs[@]}"}"; do
72 if ! is_debug_pkg "$f"; then
73 if [[ -n "$main_pkg" ]]; then
74 echo "Multiple non-debug Arch packages in $DIST" >&2
75 return 1
76 fi
77 main_pkg="$f"
78 fi
79 done
80 if [[ -z "$main_pkg" ]]; then
81 echo "No non-debug Arch .pkg.tar.zst in $DIST" >&2
82 ls -la "$DIST" >&2 || true
83 return 1
84 fi
85 printf '%s\t%s\n' "Arch Linux .pkg.tar.zst (x86_64)" "$main_pkg"
86
87 if [[ ${#tgzs[@]} -ne 1 ]]; then
88 echo "Expected exactly one posprint-*-x86_64.tar.gz in $DIST, found ${#tgzs[@]}" >&2
89 ls -la "$DIST" >&2 || true
90 return 1
91 fi
92 printf '%s\t%s\n' "Linux binary tarball (x86_64, AUR posprint-bin)" "${tgzs[0]}"
93
94 if [[ ! -f "$DIST/posprint.exe" ]]; then
95 echo "Missing $DIST/posprint.exe" >&2
96 ls -la "$DIST" >&2 || true
97 return 1
98 fi
99 printf '%s\t%s\n' "Windows .exe" "$DIST/posprint.exe"
100 }
101
102 json_escape() {
103 printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
104 }
105
106 generic_file_url() {
107 local name="$1"
108 printf '%s/projects/%s/packages/generic/posprint/%s/%s' \
109 "${CI_API_V4_URL}" "${CI_PROJECT_ID}" "${VERSION}" "${name}"
110 }
111
112 ASSETS="$(collect_assets)"
113
114 if [[ "$DRY_RUN" -eq 1 ]]; then
115 echo "tag=${TAG}"
116 echo "version=${VERSION}"
117 echo "dist=${DIST}"
118 while IFS=$'\t' read -r label path; do
119 name="$(basename -- "$path")"
120 printf 'UPLOAD\t%s\t%s\t%s\n' "$label" "$path" "$name"
121 printf 'LINK\t%s\t/%s\n' "$label" "$name"
122 done <<<"$ASSETS"
123 exit 0
124 fi
125
126 : "${CI_JOB_TOKEN:?CI_JOB_TOKEN is required to publish a GitLab release}"
127 : "${CI_API_V4_URL:?CI_API_V4_URL is required to publish a GitLab release}"
128 : "${CI_PROJECT_ID:?CI_PROJECT_ID is required to publish a GitLab release}"
129
130 api() {
131 local method="$1"
132 local path="$2"
133 local body_file="${3:-}"
134 local out_file="$4"
135 local extra=()
136 if [[ -n "$body_file" ]]; then
137 extra+=(--header "Content-Type: application/json" --data @"$body_file")
138 fi
139 curl -sS -X "$method" \
140 --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
141 "${extra[@]}" \
142 -o "$out_file" -w "%{http_code}" \
143 "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}${path}"
144 }
145
146 upload_generic() {
147 local file="$1"
148 local name
149 name="$(basename -- "$file")"
150 local url
151 url="$(generic_file_url "$name")"
152 local tmp code
153 tmp="$(mktemp)"
154 code="$(curl -sS -o "$tmp" -w "%{http_code}" \
155 --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
156 --upload-file "$file" \
157 "$url")"
158 if [[ "$code" == "201" || "$code" == "200" ]]; then
159 echo "Uploaded $name ($code)"
160 rm -f "$tmp"
161 return 0
162 fi
163 if [[ "$code" == "400" || "$code" == "409" ]] && grep -qiE 'already|exist|duplicate|taken|cannot be reused' "$tmp"; then
164 echo "Already uploaded $name (ok)"
165 rm -f "$tmp"
166 return 0
167 fi
168 echo "Upload failed for $name ($code): $(cat "$tmp")" >&2
169 rm -f "$tmp"
170 return 1
171 }
172
173 echo "Publishing GitLab release ${TAG} from ${DIST}"
174
175 while IFS=$'\t' read -r _label path; do
176 upload_generic "$path"
177 done <<<"$ASSETS"
178
179 LINKS_JSON=""
180 first=1
181 while IFS=$'\t' read -r label path; do
182 name="$(basename -- "$path")"
183 url="$(generic_file_url "$name")"
184 item="$(printf '{"name":"%s","url":"%s","link_type":"package","direct_asset_path":"/%s"}' \
185 "$(json_escape "$label")" \
186 "$(json_escape "$url")" \
187 "$(json_escape "$name")")"
188 if [[ "$first" -eq 1 ]]; then
189 LINKS_JSON="$item"
190 first=0
191 else
192 LINKS_JSON="${LINKS_JSON},${item}"
193 fi
194 done <<<"$ASSETS"
195
196 DESC="Cross-platform POS print designer release ${TAG}"
197 CREATE_BODY="$(mktemp)"
198 RESP="$(mktemp)"
199 trap 'rm -f "$CREATE_BODY" "$RESP"' EXIT
200
201 cat >"$CREATE_BODY" <<EOF
202 {"name":"posprint ${TAG}","tag_name":"${TAG}","description":"$(json_escape "$DESC")","assets":{"links":[${LINKS_JSON}]}}
203 EOF
204
205 code="$(api GET "/releases/${TAG}" "" "$RESP")"
206 if [[ "$code" == "404" ]]; then
207 code="$(api POST "/releases" "$CREATE_BODY" "$RESP")"
208 if [[ "$code" != "201" && "$code" != "200" ]]; then
209 echo "Failed to create release ($code): $(cat "$RESP")" >&2
210 exit 1
211 fi
212 echo "Created GitLab release ${TAG}"
213 exit 0
214 fi
215
216 if [[ "$code" != "200" ]]; then
217 echo "Failed to query release ${TAG} ($code): $(cat "$RESP")" >&2
218 exit 1
219 fi
220
221 UPDATE_BODY="$(mktemp)"
222 cat >"$UPDATE_BODY" <<EOF
223 {"name":"posprint ${TAG}","description":"$(json_escape "$DESC")"}
224 EOF
225 code="$(api PUT "/releases/${TAG}" "$UPDATE_BODY" "$RESP")"
226 rm -f "$UPDATE_BODY"
227 if [[ "$code" != "200" ]]; then
228 echo "Failed to update release ${TAG} ($code): $(cat "$RESP")" >&2
229 exit 1
230 fi
231
232 # Replace existing asset links so retries pick up new filenames/URLs.
233 code="$(api GET "/releases/${TAG}/assets/links" "" "$RESP")"
234 if [[ "$code" == "200" ]]; then
235 if command -v jq >/dev/null; then
236 mapfile -t LINK_IDS < <(jq -r '.[].id // empty' "$RESP" || true)
237 else
238 mapfile -t LINK_IDS < <(grep -oE '"id":[0-9]+' "$RESP" | sed 's/"id"://' || true)
239 fi
240 for link_id in "${LINK_IDS[@]+"${LINK_IDS[@]}"}"; do
241 [[ -n "$link_id" ]] || continue
242 del_code="$(api DELETE "/releases/${TAG}/assets/links/${link_id}" "" "$RESP")"
243 if [[ "$del_code" != "204" && "$del_code" != "200" ]]; then
244 echo "Warning: could not delete release link ${link_id} ($del_code): $(cat "$RESP")" >&2
245 fi
246 done
247 fi
248
249 while IFS=$'\t' read -r label path; do
250 name="$(basename -- "$path")"
251 url="$(generic_file_url "$name")"
252 link_body="$(mktemp)"
253 cat >"$link_body" <<EOF
254 {"name":"$(json_escape "$label")","url":"$(json_escape "$url")","link_type":"package","direct_asset_path":"/$(json_escape "$name")"}
255 EOF
256 code="$(api POST "/releases/${TAG}/assets/links" "$link_body" "$RESP")"
257 rm -f "$link_body"
258 if [[ "$code" != "201" && "$code" != "200" ]]; then
259 echo "Failed to add release link ${name} ($code): $(cat "$RESP")" >&2
260 exit 1
261 fi
262 done <<<"$ASSETS"
263
264 echo "Updated GitLab release ${TAG} with Generic Package Registry assets"
@@ -0,0 +1,264 @@
1#!/usr/bin/env bash
2# Upload dist/ release files to the GitLab Generic Package Registry and attach
3# them to the GitLab Release so downloads do not depend on job-artifact
4# permalinks (those 404 when the latest tag pipeline is failed or still running).
5#
6# Usage:
7# publish-gitlab-release.sh [--dry-run] [--dist DIR] [tag]
8#
9# In CI, tag defaults to $CI_COMMIT_TAG. Dry-run prints the upload/link plan
10# and does not call the GitLab API.
11set -euo pipefail
12
13ROOT="$(cd "$(dirname "$0")/.." && pwd)"
14DIST="$ROOT/dist"
15DRY_RUN=0
16TAG="${CI_COMMIT_TAG:-}"
17
18usage() {
19 echo "Usage: $0 [--dry-run] [--dist DIR] [tag]" >&2
20 exit 2
21}
22
23while [[ $# -gt 0 ]]; do
24 case "$1" in
25 --dry-run) DRY_RUN=1; shift ;;
26 --dist)
27 [[ $# -ge 2 ]] || usage
28 DIST="$2"
29 shift 2
30 ;;
31 -h|--help) usage ;;
32 *)
33 if [[ -n "$TAG" && "$TAG" != "$1" ]]; then
34 echo "Unexpected argument: $1" >&2
35 usage
36 fi
37 TAG="$1"
38 shift
39 ;;
40 esac
41done
42
43if [[ -z "$TAG" ]]; then
44 TAG="$(grep '^version = ' "$ROOT/Cargo.toml" | sed -E 's/.*"([^"]+)"/\1/')"
45fi
46VERSION="${TAG#v}"
47
48is_debug_pkg() {
49 local base
50 base="$(basename -- "$1")"
51 [[ "$base" == posprint-debug-* || "$base" == *-debug-*.pkg.tar.zst ]]
52}
53
54# Prints: label<TAB>absolute-path
55collect_assets() {
56 local f
57 shopt -s nullglob
58 local debs=("$DIST"/*.deb)
59 local pkgs=("$DIST"/posprint-*-x86_64.pkg.tar.zst)
60 local tgzs=("$DIST"/posprint-*-x86_64.tar.gz)
61 shopt -u nullglob
62
63 if [[ ${#debs[@]} -ne 1 ]]; then
64 echo "Expected exactly one .deb in $DIST, found ${#debs[@]}" >&2
65 ls -la "$DIST" >&2 || true
66 return 1
67 fi
68 printf '%s\t%s\n' "Linux .deb (amd64)" "${debs[0]}"
69
70 local main_pkg=""
71 for f in "${pkgs[@]+"${pkgs[@]}"}"; do
72 if ! is_debug_pkg "$f"; then
73 if [[ -n "$main_pkg" ]]; then
74 echo "Multiple non-debug Arch packages in $DIST" >&2
75 return 1
76 fi
77 main_pkg="$f"
78 fi
79 done
80 if [[ -z "$main_pkg" ]]; then
81 echo "No non-debug Arch .pkg.tar.zst in $DIST" >&2
82 ls -la "$DIST" >&2 || true
83 return 1
84 fi
85 printf '%s\t%s\n' "Arch Linux .pkg.tar.zst (x86_64)" "$main_pkg"
86
87 if [[ ${#tgzs[@]} -ne 1 ]]; then
88 echo "Expected exactly one posprint-*-x86_64.tar.gz in $DIST, found ${#tgzs[@]}" >&2
89 ls -la "$DIST" >&2 || true
90 return 1
91 fi
92 printf '%s\t%s\n' "Linux binary tarball (x86_64, AUR posprint-bin)" "${tgzs[0]}"
93
94 if [[ ! -f "$DIST/posprint.exe" ]]; then
95 echo "Missing $DIST/posprint.exe" >&2
96 ls -la "$DIST" >&2 || true
97 return 1
98 fi
99 printf '%s\t%s\n' "Windows .exe" "$DIST/posprint.exe"
100}
101
102json_escape() {
103 printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g'
104}
105
106generic_file_url() {
107 local name="$1"
108 printf '%s/projects/%s/packages/generic/posprint/%s/%s' \
109 "${CI_API_V4_URL}" "${CI_PROJECT_ID}" "${VERSION}" "${name}"
110}
111
112ASSETS="$(collect_assets)"
113
114if [[ "$DRY_RUN" -eq 1 ]]; then
115 echo "tag=${TAG}"
116 echo "version=${VERSION}"
117 echo "dist=${DIST}"
118 while IFS=$'\t' read -r label path; do
119 name="$(basename -- "$path")"
120 printf 'UPLOAD\t%s\t%s\t%s\n' "$label" "$path" "$name"
121 printf 'LINK\t%s\t/%s\n' "$label" "$name"
122 done <<<"$ASSETS"
123 exit 0
124fi
125
126: "${CI_JOB_TOKEN:?CI_JOB_TOKEN is required to publish a GitLab release}"
127: "${CI_API_V4_URL:?CI_API_V4_URL is required to publish a GitLab release}"
128: "${CI_PROJECT_ID:?CI_PROJECT_ID is required to publish a GitLab release}"
129
130api() {
131 local method="$1"
132 local path="$2"
133 local body_file="${3:-}"
134 local out_file="$4"
135 local extra=()
136 if [[ -n "$body_file" ]]; then
137 extra+=(--header "Content-Type: application/json" --data @"$body_file")
138 fi
139 curl -sS -X "$method" \
140 --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
141 "${extra[@]}" \
142 -o "$out_file" -w "%{http_code}" \
143 "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}${path}"
144}
145
146upload_generic() {
147 local file="$1"
148 local name
149 name="$(basename -- "$file")"
150 local url
151 url="$(generic_file_url "$name")"
152 local tmp code
153 tmp="$(mktemp)"
154 code="$(curl -sS -o "$tmp" -w "%{http_code}" \
155 --header "JOB-TOKEN: ${CI_JOB_TOKEN}" \
156 --upload-file "$file" \
157 "$url")"
158 if [[ "$code" == "201" || "$code" == "200" ]]; then
159 echo "Uploaded $name ($code)"
160 rm -f "$tmp"
161 return 0
162 fi
163 if [[ "$code" == "400" || "$code" == "409" ]] && grep -qiE 'already|exist|duplicate|taken|cannot be reused' "$tmp"; then
164 echo "Already uploaded $name (ok)"
165 rm -f "$tmp"
166 return 0
167 fi
168 echo "Upload failed for $name ($code): $(cat "$tmp")" >&2
169 rm -f "$tmp"
170 return 1
171}
172
173echo "Publishing GitLab release ${TAG} from ${DIST}"
174
175while IFS=$'\t' read -r _label path; do
176 upload_generic "$path"
177done <<<"$ASSETS"
178
179LINKS_JSON=""
180first=1
181while IFS=$'\t' read -r label path; do
182 name="$(basename -- "$path")"
183 url="$(generic_file_url "$name")"
184 item="$(printf '{"name":"%s","url":"%s","link_type":"package","direct_asset_path":"/%s"}' \
185 "$(json_escape "$label")" \
186 "$(json_escape "$url")" \
187 "$(json_escape "$name")")"
188 if [[ "$first" -eq 1 ]]; then
189 LINKS_JSON="$item"
190 first=0
191 else
192 LINKS_JSON="${LINKS_JSON},${item}"
193 fi
194done <<<"$ASSETS"
195
196DESC="Cross-platform POS print designer release ${TAG}"
197CREATE_BODY="$(mktemp)"
198RESP="$(mktemp)"
199trap 'rm -f "$CREATE_BODY" "$RESP"' EXIT
200
201cat >"$CREATE_BODY" <<EOF
202{"name":"posprint ${TAG}","tag_name":"${TAG}","description":"$(json_escape "$DESC")","assets":{"links":[${LINKS_JSON}]}}
203EOF
204
205code="$(api GET "/releases/${TAG}" "" "$RESP")"
206if [[ "$code" == "404" ]]; then
207 code="$(api POST "/releases" "$CREATE_BODY" "$RESP")"
208 if [[ "$code" != "201" && "$code" != "200" ]]; then
209 echo "Failed to create release ($code): $(cat "$RESP")" >&2
210 exit 1
211 fi
212 echo "Created GitLab release ${TAG}"
213 exit 0
214fi
215
216if [[ "$code" != "200" ]]; then
217 echo "Failed to query release ${TAG} ($code): $(cat "$RESP")" >&2
218 exit 1
219fi
220
221UPDATE_BODY="$(mktemp)"
222cat >"$UPDATE_BODY" <<EOF
223{"name":"posprint ${TAG}","description":"$(json_escape "$DESC")"}
224EOF
225code="$(api PUT "/releases/${TAG}" "$UPDATE_BODY" "$RESP")"
226rm -f "$UPDATE_BODY"
227if [[ "$code" != "200" ]]; then
228 echo "Failed to update release ${TAG} ($code): $(cat "$RESP")" >&2
229 exit 1
230fi
231
232# Replace existing asset links so retries pick up new filenames/URLs.
233code="$(api GET "/releases/${TAG}/assets/links" "" "$RESP")"
234if [[ "$code" == "200" ]]; then
235 if command -v jq >/dev/null; then
236 mapfile -t LINK_IDS < <(jq -r '.[].id // empty' "$RESP" || true)
237 else
238 mapfile -t LINK_IDS < <(grep -oE '"id":[0-9]+' "$RESP" | sed 's/"id"://' || true)
239 fi
240 for link_id in "${LINK_IDS[@]+"${LINK_IDS[@]}"}"; do
241 [[ -n "$link_id" ]] || continue
242 del_code="$(api DELETE "/releases/${TAG}/assets/links/${link_id}" "" "$RESP")"
243 if [[ "$del_code" != "204" && "$del_code" != "200" ]]; then
244 echo "Warning: could not delete release link ${link_id} ($del_code): $(cat "$RESP")" >&2
245 fi
246 done
247fi
248
249while IFS=$'\t' read -r label path; do
250 name="$(basename -- "$path")"
251 url="$(generic_file_url "$name")"
252 link_body="$(mktemp)"
253 cat >"$link_body" <<EOF
254{"name":"$(json_escape "$label")","url":"$(json_escape "$url")","link_type":"package","direct_asset_path":"/$(json_escape "$name")"}
255EOF
256 code="$(api POST "/releases/${TAG}/assets/links" "$link_body" "$RESP")"
257 rm -f "$link_body"
258 if [[ "$code" != "201" && "$code" != "200" ]]; then
259 echo "Failed to add release link ${name} ($code): $(cat "$RESP")" >&2
260 exit 1
261 fi
262done <<<"$ASSETS"
263
264echo "Updated GitLab release ${TAG} with Generic Package Registry assets"
tests/release_scripts.rs added +258 −0
@@ -0,0 +1,258 @@
1 //! Regression tests for tag-release packaging scripts and CI asset names.
2
3 use std::fs;
4 use std::path::Path;
5 use std::process::Command;
6
7 fn repo_root() -> std::path::PathBuf {
8 Path::new(env!("CARGO_MANIFEST_DIR")).to_path_buf()
9 }
10
11 fn write_fake_usr_tree(dir: &Path, marker: &str) {
12 let bin = dir.join("usr/bin");
13 fs::create_dir_all(&bin).unwrap();
14 fs::write(bin.join("posprint"), marker).unwrap();
15 }
16
17 fn tar_usr(src_root: &Path, dest_pkg: &Path) {
18 let status = Command::new("tar")
19 .args(["-C", src_root.to_str().unwrap(), "-cf"])
20 .arg(dest_pkg)
21 .arg("usr")
22 .status()
23 .expect("spawn tar");
24 assert!(status.success(), "tar failed creating {}", dest_pkg.display());
25 }
26
27 fn run_tarball_script(args: &[&str]) -> std::process::Output {
28 let script = repo_root().join("scripts/make-linux-bin-tarball.sh");
29 Command::new("bash")
30 .arg(&script)
31 .args(args)
32 .output()
33 .unwrap_or_else(|e| panic!("run make-linux-bin-tarball.sh: {e}"))
34 }
35
36 fn run_publish_release(args: &[&str]) -> std::process::Output {
37 let script = repo_root().join("scripts/publish-gitlab-release.sh");
38 Command::new("bash")
39 .arg(&script)
40 .args(args)
41 .output()
42 .unwrap_or_else(|e| panic!("run publish-gitlab-release.sh: {e}"))
43 }
44
45 #[test]
46 fn tarball_script_ignores_debug_package_when_glob_expands_to_two() {
47 let tmp = tempfile::tempdir().unwrap();
48 let main_root = tmp.path().join("main");
49 let debug_root = tmp.path().join("debug");
50 write_fake_usr_tree(&main_root, "main-bin");
51 write_fake_usr_tree(&debug_root, "debug-bin");
52
53 let main_pkg = tmp.path().join("posprint-0.5.7-1-x86_64.pkg.tar");
54 let debug_pkg = tmp.path().join("posprint-debug-0.5.7-1-x86_64.pkg.tar");
55 tar_usr(&main_root, &main_pkg);
56 tar_usr(&debug_root, &debug_pkg);
57 let debug_before = fs::read(&debug_pkg).unwrap();
58
59 let out = tmp.path().join("posprint-0.5.7-x86_64.tar.gz");
60 let output = run_tarball_script(&[
61 main_pkg.to_str().unwrap(),
62 debug_pkg.to_str().unwrap(),
63 out.to_str().unwrap(),
64 "0.5.7",
65 ]);
66 assert!(
67 output.status.success(),
68 "stdout:\n{}\nstderr:\n{}",
69 String::from_utf8_lossy(&output.stdout),
70 String::from_utf8_lossy(&output.stderr)
71 );
72 assert!(out.is_file(), "tarball was not written to the intended out path");
73 assert_ne!(out.metadata().unwrap().len(), 0);
74 assert_eq!(
75 fs::read(&debug_pkg).unwrap(),
76 debug_before,
77 "debug package must not be overwritten when it is $2"
78 );
79
80 let extract = tmp.path().join("extract");
81 fs::create_dir_all(&extract).unwrap();
82 let status = Command::new("tar")
83 .args(["-C", extract.to_str().unwrap(), "-xzf"])
84 .arg(&out)
85 .status()
86 .unwrap();
87 assert!(status.success());
88 let packed = fs::read_to_string(extract.join("usr/bin/posprint")).unwrap();
89 assert_eq!(packed, "main-bin");
90 }
91
92 #[test]
93 fn tarball_script_rejects_only_debug_packages() {
94 let tmp = tempfile::tempdir().unwrap();
95 let debug_root = tmp.path().join("debug");
96 write_fake_usr_tree(&debug_root, "debug-bin");
97 let debug_pkg = tmp.path().join("posprint-debug-0.5.7-1-x86_64.pkg.tar");
98 tar_usr(&debug_root, &debug_pkg);
99 let out = tmp.path().join("posprint-0.5.7-x86_64.tar.gz");
100
101 let output = run_tarball_script(&[
102 debug_pkg.to_str().unwrap(),
103 out.to_str().unwrap(),
104 "0.5.7",
105 ]);
106 assert!(!output.status.success());
107 let stderr = String::from_utf8_lossy(&output.stderr);
108 assert!(
109 stderr.contains("No non-debug"),
110 "unexpected stderr: {stderr}"
111 );
112 assert!(!out.exists());
113 }
114
115 #[test]
116 fn tarball_script_classic_three_args_still_works() {
117 let tmp = tempfile::tempdir().unwrap();
118 let main_root = tmp.path().join("main");
119 write_fake_usr_tree(&main_root, "only-main");
120 let main_pkg = tmp.path().join("posprint-0.5.7-1-x86_64.pkg.tar");
121 tar_usr(&main_root, &main_pkg);
122 let out = tmp.path().join("out.tar.gz");
123
124 let output = run_tarball_script(&[main_pkg.to_str().unwrap(), out.to_str().unwrap(), "0.5.7"]);
125 assert!(
126 output.status.success(),
127 "stderr: {}",
128 String::from_utf8_lossy(&output.stderr)
129 );
130 assert!(out.is_file());
131 }
132
133 #[test]
134 fn publish_release_dry_run_uses_real_filenames() {
135 let tmp = tempfile::tempdir().unwrap();
136 let dist = tmp.path();
137 fs::write(dist.join("posprint_0.5.7-1_amd64.deb"), b"deb").unwrap();
138 fs::write(
139 dist.join("posprint-0.5.7-1-x86_64.pkg.tar.zst"),
140 b"pkg",
141 )
142 .unwrap();
143 fs::write(dist.join("posprint-debug-0.5.7-1-x86_64.pkg.tar.zst"), b"dbg").unwrap();
144 fs::write(dist.join("posprint-0.5.7-x86_64.tar.gz"), b"tgz").unwrap();
145 fs::write(dist.join("posprint.exe"), b"exe").unwrap();
146
147 let output = run_publish_release(&[
148 "--dry-run",
149 "--dist",
150 dist.to_str().unwrap(),
151 "0.5.7",
152 ]);
153 assert!(
154 output.status.success(),
155 "stdout:\n{}\nstderr:\n{}",
156 String::from_utf8_lossy(&output.stdout),
157 String::from_utf8_lossy(&output.stderr)
158 );
159 let stdout = String::from_utf8_lossy(&output.stdout);
160 assert!(stdout.contains("posprint_0.5.7-1_amd64.deb"));
161 assert!(stdout.contains("posprint-0.5.7-1-x86_64.pkg.tar.zst"));
162 assert!(
163 !stdout.contains("posprint-debug-"),
164 "debug package must not be a release asset:\n{stdout}"
165 );
166 assert!(
167 !stdout.contains("posprint_0.5.7-1-x86_64"),
168 "Arch package must use hyphens, not posprint_ver:\n{stdout}"
169 );
170 assert!(stdout.contains("posprint-0.5.7-x86_64.tar.gz"));
171 assert!(stdout.contains("posprint.exe"));
172 }
173
174 #[test]
175 fn publish_release_dry_run_rejects_missing_tarball() {
176 let tmp = tempfile::tempdir().unwrap();
177 let dist = tmp.path();
178 fs::write(dist.join("posprint_0.5.7-1_amd64.deb"), b"deb").unwrap();
179 fs::write(
180 dist.join("posprint-0.5.7-1-x86_64.pkg.tar.zst"),
181 b"pkg",
182 )
183 .unwrap();
184 fs::write(dist.join("posprint.exe"), b"exe").unwrap();
185
186 let output = run_publish_release(&[
187 "--dry-run",
188 "--dist",
189 dist.to_str().unwrap(),
190 "0.5.7",
191 ]);
192 assert!(!output.status.success());
193 let stderr = String::from_utf8_lossy(&output.stderr);
194 assert!(
195 stderr.contains("tar.gz"),
196 "expected missing-tarball error, got: {stderr}"
197 );
198 }
199
200 #[test]
201 fn gitlab_ci_does_not_use_tag_artifact_permalinks() {
202 let yml = include_str!("../.gitlab-ci.yml");
203 assert!(
204 !yml.contains("jobs/artifacts/"),
205 "release links must not use jobs/artifacts/TAG permalinks"
206 );
207 assert!(
208 !yml.contains("posprint_${CI_COMMIT_TAG#v}_amd64.deb"),
209 "deb link must not drop cargo-deb revision -1"
210 );
211 assert!(
212 !yml.contains("posprint_${CI_COMMIT_TAG#v}-1-x86_64.pkg.tar.zst"),
213 "pkg link must not use underscore after posprint"
214 );
215 assert!(yml.contains("publish-gitlab-release.sh"));
216 assert!(yml.contains("make-linux-bin-tarball.sh"));
217 assert!(
218 yml.contains("build:linux-arch"),
219 "publish:aur must still need the Arch job"
220 );
221 assert!(yml.contains("allow_failure: true"));
222 }
223
224 #[test]
225 fn aur_bin_uses_generic_package_registry() {
226 let pkgbuild = include_str!("../packaging/aur-bin/PKGBUILD");
227 let srcinfo = include_str!("../packaging/aur-bin/.SRCINFO");
228 let publish = include_str!("../scripts/publish-aur.sh");
229 for text in [pkgbuild, srcinfo, publish] {
230 assert!(
231 !text.contains("jobs/artifacts"),
232 "AUR bin must not download via jobs/artifacts permalinks"
233 );
234 assert!(
235 text.contains("packages/generic/posprint"),
236 "AUR bin must use the Generic Package Registry URL"
237 );
238 }
239 }
240
241 #[test]
242 fn expected_release_filenames_match_packaging_tools() {
243 // cargo-deb: <name>_<version>-<revision>_<arch>.deb (revision defaults to 1)
244 // makepkg: <pkgname>-<pkgver>-<pkgrel>-<arch>.pkg.tar.zst
245 let version = "0.5.7";
246 assert_eq!(
247 format!("posprint_{version}-1_amd64.deb"),
248 "posprint_0.5.7-1_amd64.deb"
249 );
250 assert_eq!(
251 format!("posprint-{version}-1-x86_64.pkg.tar.zst"),
252 "posprint-0.5.7-1-x86_64.pkg.tar.zst"
253 );
254 assert_eq!(
255 format!("posprint-{version}-x86_64.tar.gz"),
256 "posprint-0.5.7-x86_64.tar.gz"
257 );
258 }
@@ -0,0 +1,258 @@
1//! Regression tests for tag-release packaging scripts and CI asset names.
2
3use std::fs;
4use std::path::Path;
5use std::process::Command;
6
7fn repo_root() -> std::path::PathBuf {
8 Path::new(env!("CARGO_MANIFEST_DIR")).to_path_buf()
9}
10
11fn write_fake_usr_tree(dir: &Path, marker: &str) {
12 let bin = dir.join("usr/bin");
13 fs::create_dir_all(&bin).unwrap();
14 fs::write(bin.join("posprint"), marker).unwrap();
15}
16
17fn tar_usr(src_root: &Path, dest_pkg: &Path) {
18 let status = Command::new("tar")
19 .args(["-C", src_root.to_str().unwrap(), "-cf"])
20 .arg(dest_pkg)
21 .arg("usr")
22 .status()
23 .expect("spawn tar");
24 assert!(status.success(), "tar failed creating {}", dest_pkg.display());
25}
26
27fn run_tarball_script(args: &[&str]) -> std::process::Output {
28 let script = repo_root().join("scripts/make-linux-bin-tarball.sh");
29 Command::new("bash")
30 .arg(&script)
31 .args(args)
32 .output()
33 .unwrap_or_else(|e| panic!("run make-linux-bin-tarball.sh: {e}"))
34}
35
36fn run_publish_release(args: &[&str]) -> std::process::Output {
37 let script = repo_root().join("scripts/publish-gitlab-release.sh");
38 Command::new("bash")
39 .arg(&script)
40 .args(args)
41 .output()
42 .unwrap_or_else(|e| panic!("run publish-gitlab-release.sh: {e}"))
43}
44
45#[test]
46fn tarball_script_ignores_debug_package_when_glob_expands_to_two() {
47 let tmp = tempfile::tempdir().unwrap();
48 let main_root = tmp.path().join("main");
49 let debug_root = tmp.path().join("debug");
50 write_fake_usr_tree(&main_root, "main-bin");
51 write_fake_usr_tree(&debug_root, "debug-bin");
52
53 let main_pkg = tmp.path().join("posprint-0.5.7-1-x86_64.pkg.tar");
54 let debug_pkg = tmp.path().join("posprint-debug-0.5.7-1-x86_64.pkg.tar");
55 tar_usr(&main_root, &main_pkg);
56 tar_usr(&debug_root, &debug_pkg);
57 let debug_before = fs::read(&debug_pkg).unwrap();
58
59 let out = tmp.path().join("posprint-0.5.7-x86_64.tar.gz");
60 let output = run_tarball_script(&[
61 main_pkg.to_str().unwrap(),
62 debug_pkg.to_str().unwrap(),
63 out.to_str().unwrap(),
64 "0.5.7",
65 ]);
66 assert!(
67 output.status.success(),
68 "stdout:\n{}\nstderr:\n{}",
69 String::from_utf8_lossy(&output.stdout),
70 String::from_utf8_lossy(&output.stderr)
71 );
72 assert!(out.is_file(), "tarball was not written to the intended out path");
73 assert_ne!(out.metadata().unwrap().len(), 0);
74 assert_eq!(
75 fs::read(&debug_pkg).unwrap(),
76 debug_before,
77 "debug package must not be overwritten when it is $2"
78 );
79
80 let extract = tmp.path().join("extract");
81 fs::create_dir_all(&extract).unwrap();
82 let status = Command::new("tar")
83 .args(["-C", extract.to_str().unwrap(), "-xzf"])
84 .arg(&out)
85 .status()
86 .unwrap();
87 assert!(status.success());
88 let packed = fs::read_to_string(extract.join("usr/bin/posprint")).unwrap();
89 assert_eq!(packed, "main-bin");
90}
91
92#[test]
93fn tarball_script_rejects_only_debug_packages() {
94 let tmp = tempfile::tempdir().unwrap();
95 let debug_root = tmp.path().join("debug");
96 write_fake_usr_tree(&debug_root, "debug-bin");
97 let debug_pkg = tmp.path().join("posprint-debug-0.5.7-1-x86_64.pkg.tar");
98 tar_usr(&debug_root, &debug_pkg);
99 let out = tmp.path().join("posprint-0.5.7-x86_64.tar.gz");
100
101 let output = run_tarball_script(&[
102 debug_pkg.to_str().unwrap(),
103 out.to_str().unwrap(),
104 "0.5.7",
105 ]);
106 assert!(!output.status.success());
107 let stderr = String::from_utf8_lossy(&output.stderr);
108 assert!(
109 stderr.contains("No non-debug"),
110 "unexpected stderr: {stderr}"
111 );
112 assert!(!out.exists());
113}
114
115#[test]
116fn tarball_script_classic_three_args_still_works() {
117 let tmp = tempfile::tempdir().unwrap();
118 let main_root = tmp.path().join("main");
119 write_fake_usr_tree(&main_root, "only-main");
120 let main_pkg = tmp.path().join("posprint-0.5.7-1-x86_64.pkg.tar");
121 tar_usr(&main_root, &main_pkg);
122 let out = tmp.path().join("out.tar.gz");
123
124 let output = run_tarball_script(&[main_pkg.to_str().unwrap(), out.to_str().unwrap(), "0.5.7"]);
125 assert!(
126 output.status.success(),
127 "stderr: {}",
128 String::from_utf8_lossy(&output.stderr)
129 );
130 assert!(out.is_file());
131}
132
133#[test]
134fn publish_release_dry_run_uses_real_filenames() {
135 let tmp = tempfile::tempdir().unwrap();
136 let dist = tmp.path();
137 fs::write(dist.join("posprint_0.5.7-1_amd64.deb"), b"deb").unwrap();
138 fs::write(
139 dist.join("posprint-0.5.7-1-x86_64.pkg.tar.zst"),
140 b"pkg",
141 )
142 .unwrap();
143 fs::write(dist.join("posprint-debug-0.5.7-1-x86_64.pkg.tar.zst"), b"dbg").unwrap();
144 fs::write(dist.join("posprint-0.5.7-x86_64.tar.gz"), b"tgz").unwrap();
145 fs::write(dist.join("posprint.exe"), b"exe").unwrap();
146
147 let output = run_publish_release(&[
148 "--dry-run",
149 "--dist",
150 dist.to_str().unwrap(),
151 "0.5.7",
152 ]);
153 assert!(
154 output.status.success(),
155 "stdout:\n{}\nstderr:\n{}",
156 String::from_utf8_lossy(&output.stdout),
157 String::from_utf8_lossy(&output.stderr)
158 );
159 let stdout = String::from_utf8_lossy(&output.stdout);
160 assert!(stdout.contains("posprint_0.5.7-1_amd64.deb"));
161 assert!(stdout.contains("posprint-0.5.7-1-x86_64.pkg.tar.zst"));
162 assert!(
163 !stdout.contains("posprint-debug-"),
164 "debug package must not be a release asset:\n{stdout}"
165 );
166 assert!(
167 !stdout.contains("posprint_0.5.7-1-x86_64"),
168 "Arch package must use hyphens, not posprint_ver:\n{stdout}"
169 );
170 assert!(stdout.contains("posprint-0.5.7-x86_64.tar.gz"));
171 assert!(stdout.contains("posprint.exe"));
172}
173
174#[test]
175fn publish_release_dry_run_rejects_missing_tarball() {
176 let tmp = tempfile::tempdir().unwrap();
177 let dist = tmp.path();
178 fs::write(dist.join("posprint_0.5.7-1_amd64.deb"), b"deb").unwrap();
179 fs::write(
180 dist.join("posprint-0.5.7-1-x86_64.pkg.tar.zst"),
181 b"pkg",
182 )
183 .unwrap();
184 fs::write(dist.join("posprint.exe"), b"exe").unwrap();
185
186 let output = run_publish_release(&[
187 "--dry-run",
188 "--dist",
189 dist.to_str().unwrap(),
190 "0.5.7",
191 ]);
192 assert!(!output.status.success());
193 let stderr = String::from_utf8_lossy(&output.stderr);
194 assert!(
195 stderr.contains("tar.gz"),
196 "expected missing-tarball error, got: {stderr}"
197 );
198}
199
200#[test]
201fn gitlab_ci_does_not_use_tag_artifact_permalinks() {
202 let yml = include_str!("../.gitlab-ci.yml");
203 assert!(
204 !yml.contains("jobs/artifacts/"),
205 "release links must not use jobs/artifacts/TAG permalinks"
206 );
207 assert!(
208 !yml.contains("posprint_${CI_COMMIT_TAG#v}_amd64.deb"),
209 "deb link must not drop cargo-deb revision -1"
210 );
211 assert!(
212 !yml.contains("posprint_${CI_COMMIT_TAG#v}-1-x86_64.pkg.tar.zst"),
213 "pkg link must not use underscore after posprint"
214 );
215 assert!(yml.contains("publish-gitlab-release.sh"));
216 assert!(yml.contains("make-linux-bin-tarball.sh"));
217 assert!(
218 yml.contains("build:linux-arch"),
219 "publish:aur must still need the Arch job"
220 );
221 assert!(yml.contains("allow_failure: true"));
222}
223
224#[test]
225fn aur_bin_uses_generic_package_registry() {
226 let pkgbuild = include_str!("../packaging/aur-bin/PKGBUILD");
227 let srcinfo = include_str!("../packaging/aur-bin/.SRCINFO");
228 let publish = include_str!("../scripts/publish-aur.sh");
229 for text in [pkgbuild, srcinfo, publish] {
230 assert!(
231 !text.contains("jobs/artifacts"),
232 "AUR bin must not download via jobs/artifacts permalinks"
233 );
234 assert!(
235 text.contains("packages/generic/posprint"),
236 "AUR bin must use the Generic Package Registry URL"
237 );
238 }
239}
240
241#[test]
242fn expected_release_filenames_match_packaging_tools() {
243 // cargo-deb: <name>_<version>-<revision>_<arch>.deb (revision defaults to 1)
244 // makepkg: <pkgname>-<pkgver>-<pkgrel>-<arch>.pkg.tar.zst
245 let version = "0.5.7";
246 assert_eq!(
247 format!("posprint_{version}-1_amd64.deb"),
248 "posprint_0.5.7-1_amd64.deb"
249 );
250 assert_eq!(
251 format!("posprint-{version}-1-x86_64.pkg.tar.zst"),
252 "posprint-0.5.7-1-x86_64.pkg.tar.zst"
253 );
254 assert_eq!(
255 format!("posprint-{version}-x86_64.tar.gz"),
256 "posprint-0.5.7-x86_64.tar.gz"
257 );
258}