Merge branch 'cursor/fix-release-artifacts-3563' into 'master'
fix: restore 0.5.7 release downloads and AUR bin publish See merge request Timfa/posprint!2
@@ -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=lf1
*.sh text eol=lf2
*.ps1 text eol=crlf2
*.ps1 text eol=crlf3
.gitlab-ci.yml text eol=lf3
PKGBUILD text eol=lf4
PKGBUILD text eol=lf4
*.desktop text eol=lf5
*.desktop text eol=lf5
*.xml text eol=lf6
*.xml text eol=lf@@ -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).5
workflow:
5
workflow: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_TAG9
9
10
stages:
10
stages:11
- test
11
- test12
- build
12
- build13
- release
13
- release14
14
15
variables:
15
variables:16
CARGO_TERM_COLOR: always
16
CARGO_TERM_COLOR: always17
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-bookworm22
before_script:
22
before_script:23
- rustc --version
23
- rustc --version24
- cargo --version
24
- cargo --version25
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-amd6430
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.exe35
.\rustup-init.exe -y --default-toolchain stable --profile minimal
35
.\rustup-init.exe -y --default-toolchain stable --profile minimal36
Remove-Item rustup-init.exe
36
Remove-Item rustup-init.exe37
}
37
}38
$env:Path = "$env:USERPROFILE\.cargo\bin;$env:Path"
38
$env:Path = "$env:USERPROFILE\.cargo\bin;$env:Path"39
rustc --version
39
rustc --version40
cargo --version
40
cargo --version41
41
42
test:linux:
42
test:linux:43
extends: .default_rust
43
extends: .default_rust44
stage: test
44
stage: test45
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 -qq49
- 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-dev50
libxkbcommon-dev libssl-dev libudev-dev pkg-config
50
libxkbcommon-dev libssl-dev libudev-dev pkg-config51
- cargo test --verbose
51
- cargo test --verbose52
52
53
test:windows:
53
test:windows:54
extends: .windows_saas
54
extends: .windows_saas55
stage: test
55
stage: test56
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 --verbose60
60
61
build:linux-deb:
61
build:linux-deb:62
extends: .default_rust
62
extends: .default_rust63
stage: build
63
stage: build64
rules:
64
rules:65
- if: $CI_COMMIT_TAG
65
- if: $CI_COMMIT_TAG66
before_script:
66
before_script:67
- apt-get update -qq
67
- apt-get update -qq68
- 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-dev69
libxkbcommon-dev libssl-dev libudev-dev pkg-config dpkg-dev
69
libxkbcommon-dev libssl-dev libudev-dev pkg-config dpkg-dev70
- cargo install cargo-deb --locked
70
- cargo install cargo-deb --locked71
script:
71
script:72
- cargo deb
72
- cargo deb73
- mkdir -p dist
73
- mkdir -p dist74
- 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/*.deb79
expire_in: 1 year
79
expire_in: 1 year80
80
81
build:linux-arch:
81
build:linux-arch:82
stage: build
82
stage: build83
image: archlinux/archlinux:base-devel
83
image: archlinux/archlinux:base-devel84
rules:
84
rules:85
- if: $CI_COMMIT_TAG
85
- if: $CI_COMMIT_TAG86
script:
86
script:87
- pacman -Syu --noconfirm
87
- pacman -Syu --noconfirm88
- pacman -S --noconfirm --needed rust pkgconf openssl libxkbcommon libxcb dbus
88
- pacman -S --noconfirm --needed rust pkgconf openssl libxkbcommon libxcb dbus89
wayland libx11 fontconfig freetype2 libglvnd git rsync
89
wayland libx11 fontconfig freetype2 libglvnd git rsync90
- rustc --version
90
- rustc --version91
- 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/PKGBUILD93
- useradd -m builduser
93
- useradd -m builduser94
- 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 matches99
# 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 tarball100
- |
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 pipefail103
name: "posprint-arch-$CI_COMMIT_TAG"
103
shopt -s nullglob104
paths:
104
mains=("$CI_PROJECT_DIR"/packaging/arch/posprint-${PKGVER}-*-x86_64.pkg.tar.zst)105
- dist/*.pkg.tar.zst
105
shopt -u nullglob106
- dist/posprint-*-x86_64.tar.gz
106
if [[ ${#mains[@]} -ne 1 ]]; then107
expire_in: 1 year
107
echo "Expected one non-debug Arch package, found ${#mains[@]}" >&2108
108
ls -la "$CI_PROJECT_DIR/packaging/arch" >&2 || true109
build:windows:
109
exit 1110
extends: .windows_saas
110
fi111
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.zst119
name: "posprint-windows-$CI_COMMIT_TAG"
119
- dist/posprint-*-x86_64.tar.gz120
paths:
120
expire_in: 1 year121
- dist/posprint.exe
121
122
expire_in: 1 year
122
build:windows:123
123
extends: .windows_saas124
release:gitlab:
124
stage: build125
stage: release
125
rules:126
image: registry.gitlab.com/gitlab-org/release-cli:latest
126
- if: $CI_COMMIT_TAG127
rules:
127
script:128
- if: $CI_COMMIT_TAG
128
- cargo build --release129
needs:
129
- New-Item -ItemType Directory -Force -Path dist | Out-Null130
- 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.exe135
release-cli create \
135
expire_in: 1 year136
--name "posprint $CI_COMMIT_TAG" \
136
137
--tag-name "$CI_COMMIT_TAG" \
137
release:gitlab:138
--description "Cross-platform POS print designer release $CI_COMMIT_TAG" \
138
stage: release139
--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.21140
--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_TAG142
--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-deb144
publish:aur:
144
artifacts: true145
stage: release
145
- job: build:linux-arch146
image: archlinux/archlinux:base-devel
146
artifacts: true147
rules:
147
- job: build:windows148
- if: $CI_COMMIT_TAG
148
artifacts: true149
needs:
149
before_script:150
- release:gitlab
150
- apk add --no-cache bash curl jq151
- job: build:linux-arch
151
- chmod +x scripts/publish-gitlab-release.sh152
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 the155
# 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.sh157
- pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux
157
158
- chmod +x scripts/aur-ssh-setup.sh
158
publish:aur:159
- ./scripts/aur-ssh-setup.sh
159
stage: release160
script:
160
image: archlinux/archlinux:base-devel161
- chmod +x scripts/publish-aur.sh
161
rules:162
- ./scripts/publish-aur.sh "$CI_COMMIT_TAG"
162
- if: $CI_COMMIT_TAG163
# AUR outage must not fail the whole tag pipeline (job-artifact permalinks164
# 404 when the latest pipeline for the tag is failed). Prefer success; this165
# is only a safety net.166
allow_failure: true167
needs:168
- release:gitlab169
- job: build:linux-arch170
artifacts: true171
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 --noconfirm175
- pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux176
- chmod +x scripts/aur-ssh-setup.sh177
- ./scripts/aur-ssh-setup.sh178
script:179
- chmod +x scripts/publish-aur.sh180
- ./scripts/publish-aur.sh "$CI_COMMIT_TAG"@@ -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 fails46
| 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
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
## Features54
## Features55
55
@@ -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 o174
## Build and release174
## Build and release175
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 migrations179
- **Versioning:** Semver in `Cargo.toml`; `.pos` `version` for file-format migrations180
180
@@ -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:16
https://gitlab.com/Timfa/posprint/-/archive/<version>/posprint-<version>.tar.gz16
https://gitlab.com/Timfa/posprint/-/archive/<version>/posprint-<version>.tar.gz17
```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
```text21
```text22
https://gitlab.com/Timfa/posprint/-/jobs/artifacts/<version>/raw/dist/posprint-<version>-x86_64.tar.gz?job=build:linux-arch22
https://gitlab.com/api/v4/projects/Timfa%2Fposprint/packages/generic/posprint/<version>/posprint-<version>-x86_64.tar.gz23
```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
## Files in this repo29
## Files in this repo28
30
@@ -32,7 +34,8 @@ That tarball is packed from the Arch CI package (`usr/` only). `posprint` and `p32
| `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 `p42
45
43
When a Git tag is pushed:46
When a Git tag is pushed:44
47
45
1. GitLab builds the normal release artifacts, including `posprint-<version>-x86_64.tar.gz`.48
1. GitLab builds the normal release artifacts, including `posprint-<version>-x86_64.tar.gz` from the **non-debug** Arch package.46
2. GitLab creates the upstream release (with a link to that tarball).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).47
3. GitLab runs `scripts/publish-aur.sh "$CI_COMMIT_TAG"`.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
4. The script:51
4. The script:49
- downloads the tagged **source** tarball and hashes it52
- downloads the tagged **source** tarball and hashes it50
- uses the CI **binary** tarball from `dist/` (or downloads the job artifact) and hashes it53
- uses the CI **binary** tarball from `dist/` (or, if missing, the Generic Package Registry) and hashes it51
- clones each AUR repo (`posprint`, `posprint-bin`), or creates it on first push54
- clones each AUR repo (`posprint`, `posprint-bin`), or creates it on first push52
- 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 URLs57
- strips a leading `v` from the tag when resolving GitLab URLs55
- 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
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
```bash72
git checkout master73
git pull origin master74
git tag -d 0.5.775
git push origin :refs/tags/0.5.776
git tag 0.5.777
git push origin 0.5.778
```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
## GitLab CI secrets86
## GitLab CI secrets58
87
59
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**.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**.@@ -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 support72
### Linux targets we support72
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 tags113
- `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 Release114
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
### File association (`.pos` → posprint)123
### File association (`.pos` → posprint)120
124
@@ -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
)22
makedepends=('rust' 'cargo' 'pkgconf' 'git')22
makedepends=('rust' 'cargo' 'pkgconf' 'git')23
options=('!lto')23
# !debug: recent makepkg.conf enables debug split packages; those scramble24
# CI globs (posprint-*.pkg.tar.zst) and are not shipped as release assets.25
options=('!lto' '!debug')24
source=()26
source=()25
sha256sums=()27
sha256sums=()26
28
@@ -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 @@1
pkgbase = posprint-bin
1
pkgbase = posprint-bin2
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.74
pkgrel = 1
4
pkgrel = 15
url = https://gitlab.com/Timfa/posprint
5
url = https://gitlab.com/Timfa/posprint6
arch = x86_64
6
arch = x86_647
license = MIT
7
license = MIT8
provides = posprint=0.5.7
8
provides = posprint=0.5.79
conflicts = posprint
9
conflicts = posprint10
depends = gcc-libs
10
depends = gcc-libs11
depends = libxkbcommon
11
depends = libxkbcommon12
depends = libxcb
12
depends = libxcb13
depends = openssl
13
depends = openssl14
depends = dbus
14
depends = dbus15
depends = wayland
15
depends = wayland16
depends = libx11
16
depends = libx1117
depends = fontconfig
17
depends = fontconfig18
depends = freetype2
18
depends = freetype219
depends = libglvnd
19
depends = libglvnd20
options = !strip
20
options = !strip21
options = !debug
21
options = !debug22
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.gz23
sha256sums = 0000000000000000000000000000000000000000000000000000000000000000
23
sha256sums = 000000000000000000000000000000000000000000000000000000000000000024
24
25
pkgname = posprint-bin
25
pkgname = posprint-bin@@ -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=(21
provides=("posprint=${pkgver}")21
provides=("posprint=${pkgver}")22
conflicts=('posprint')22
conflicts=('posprint')23
options=('!strip' '!debug')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
sha256sums=('0000000000000000000000000000000000000000000000000000000000000000')25
sha256sums=('0000000000000000000000000000000000000000000000000000000000000000')26
26
27
package() {27
package() {@@ -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 bash1
#!/usr/bin/env bash2
# 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 debug8
# split package) are ignored; only the non-debug package is used. The tarball is9
# never written over a package path.3
set -euo pipefail10
set -euo pipefail4
11
5
ROOT="$(cd "$(dirname "$0")/.." && pwd)"12
ROOT="$(cd "$(dirname "$0")/.." && pwd)"6
PKG_ZST="${1:-}"7
OUT="${2:-}"8
VERSION="${3:-}"9
13
10
if [[ -z "$PKG_ZST" ]]; then14
is_debug_pkg() {15
local base16
base="$(basename -- "$1")"17
# Arch debug split packages: posprint-debug-<ver>-<rel>-<arch>.pkg.tar.zst18
[[ "$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 "$@"; do39
if is_pkg "$arg"; then40
PKG_CANDIDATES+=("$arg")41
elif is_tarball_out "$arg"; then42
if [[ -n "$OUT" ]]; then43
echo "Multiple output paths: $OUT and $arg" >&244
exit 145
fi46
OUT="$arg"47
elif looks_like_version "$arg"; then48
VERSION="$arg"49
else50
UNKNOWN+=("$arg")51
fi52
done53
54
if [[ ${#UNKNOWN[@]} -gt 0 ]]; then55
echo "Unexpected arguments: ${UNKNOWN[*]}" >&256
echo "Usage: $0 [posprint-*.pkg.tar.zst ...] [out.tar.gz] [version]" >&257
exit 158
fi59
60
if [[ ${#PKG_CANDIDATES[@]} -eq 0 ]]; then11
shopt -s nullglob61
shopt -s nullglob12
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 nullglob63
shopt -u nullglob14
if [[ ${#candidates[@]} -eq 0 ]]; then64
fi15
echo "Usage: $0 <posprint-*.pkg.tar.zst> [out.tar.gz] [version]" >&265
16
exit 166
PKG_ZST=""67
for candidate in "${PKG_CANDIDATES[@]+"${PKG_CANDIDATES[@]}"}"; do68
if ! is_debug_pkg "$candidate"; then69
PKG_ZST="$candidate"70
break17
fi71
fi18
PKG_ZST="${candidates[0]}"72
done73
74
if [[ -z "$PKG_ZST" ]]; then75
echo "Usage: $0 <posprint-*.pkg.tar.zst> [out.tar.gz] [version]" >&276
echo "No non-debug Arch package found." >&277
exit 178
fi79
80
if [[ ! -f "$PKG_ZST" ]]; then81
echo "Package not found: $PKG_ZST" >&282
exit 119
fi83
fi20
84
21
if [[ -z "$VERSION" ]]; then85
if [[ -z "$VERSION" ]]; then@@ -28,6 +92,11 @@ if [[ -z "$OUT" ]]; then28
OUT="$ROOT/dist/posprint-${VERSION}-x86_64.tar.gz"92
OUT="$ROOT/dist/posprint-${VERSION}-x86_64.tar.gz"29
fi93
fi30
94
95
if is_pkg "$OUT"; then96
echo "Refusing to write tarball over package path: $OUT" >&297
exit 198
fi99
31
EXTRACT="$(mktemp -d)"100
EXTRACT="$(mktemp -d)"32
cleanup() { rm -rf "$EXTRACT"; }101
cleanup() { rm -rf "$EXTRACT"; }33
trap cleanup EXIT102
trap cleanup EXIT@@ -45,4 +114,8 @@ fi45
114
46
mkdir -p "$(dirname "$OUT")"115
mkdir -p "$(dirname "$OUT")"47
tar -C "$EXTRACT" -czf "$OUT" usr116
tar -C "$EXTRACT" -czf "$OUT" usr48
echo "Wrote $OUT"117
if [[ ! -s "$OUT" ]]; then118
echo "Failed to write tarball: $OUT" >&2119
exit 1120
fi121
echo "Wrote $OUT from $PKG_ZST"@@ -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 @@ fi26
26
27
SOURCE_ARCHIVE_URL="https://gitlab.com/Timfa/posprint/-/archive/${VERSION}/posprint-${VERSION}.tar.gz"27
SOURCE_ARCHIVE_URL="https://gitlab.com/Timfa/posprint/-/archive/${VERSION}/posprint-${VERSION}.tar.gz"28
BIN_TARBALL_NAME="posprint-${VERSION}-x86_64.tar.gz"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 — those30
# 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
generate_srcinfo() {33
generate_srcinfo() {32
# makepkg refuses root. mktemp parents are 0700 — aurbuild must be able to traverse34
# 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
publish_package "posprint" "packaging/aur" "$SOURCE_SHA"117
publish_package "posprint" "packaging/aur" "$SOURCE_SHA"116
118
117
BIN_TARBALL="$ROOT/dist/${BIN_TARBALL_NAME}"119
BIN_TARBALL="$ROOT/dist/${BIN_TARBALL_NAME}"118
if [[ ! -f "$BIN_TARBALL" ]]; then120
if [[ -f "$BIN_TARBALL" ]]; then119
echo "Binary tarball not in dist/; downloading $BIN_ARTIFACT_URL"121
echo "Using local binary tarball: $BIN_TARBALL"122
else123
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"126
fi127
if [[ ! -s "$BIN_TARBALL" ]]; then128
echo "Missing binary tarball $BIN_TARBALL (build:linux-arch must produce dist/${BIN_TARBALL_NAME})" >&2129
exit 1122
fi130
fi123
BIN_SHA="$(sha256sum "$BIN_TARBALL" | awk '{print $1}')"131
BIN_SHA="$(sha256sum "$BIN_TARBALL" | awk '{print $1}')"124
publish_package "posprint-bin" "packaging/aur-bin" "$BIN_SHA"132
publish_package "posprint-bin" "packaging/aur-bin" "$BIN_SHA"@@ -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 bash2
# Upload dist/ release files to the GitLab Generic Package Registry and attach3
# them to the GitLab Release so downloads do not depend on job-artifact4
# 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 plan10
# and does not call the GitLab API.11
set -euo pipefail12
13
ROOT="$(cd "$(dirname "$0")/.." && pwd)"14
DIST="$ROOT/dist"15
DRY_RUN=016
TAG="${CI_COMMIT_TAG:-}"17
18
usage() {19
echo "Usage: $0 [--dry-run] [--dist DIR] [tag]" >&220
exit 221
}22
23
while [[ $# -gt 0 ]]; do24
case "$1" in25
--dry-run) DRY_RUN=1; shift ;;26
--dist)27
[[ $# -ge 2 ]] || usage28
DIST="$2"29
shift 230
;;31
-h|--help) usage ;;32
*)33
if [[ -n "$TAG" && "$TAG" != "$1" ]]; then34
echo "Unexpected argument: $1" >&235
usage36
fi37
TAG="$1"38
shift39
;;40
esac41
done42
43
if [[ -z "$TAG" ]]; then44
TAG="$(grep '^version = ' "$ROOT/Cargo.toml" | sed -E 's/.*"([^"]+)"/\1/')"45
fi46
VERSION="${TAG#v}"47
48
is_debug_pkg() {49
local base50
base="$(basename -- "$1")"51
[[ "$base" == posprint-debug-* || "$base" == *-debug-*.pkg.tar.zst ]]52
}53
54
# Prints: label<TAB>absolute-path55
collect_assets() {56
local f57
shopt -s nullglob58
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 nullglob62
63
if [[ ${#debs[@]} -ne 1 ]]; then64
echo "Expected exactly one .deb in $DIST, found ${#debs[@]}" >&265
ls -la "$DIST" >&2 || true66
return 167
fi68
printf '%s\t%s\n' "Linux .deb (amd64)" "${debs[0]}"69
70
local main_pkg=""71
for f in "${pkgs[@]+"${pkgs[@]}"}"; do72
if ! is_debug_pkg "$f"; then73
if [[ -n "$main_pkg" ]]; then74
echo "Multiple non-debug Arch packages in $DIST" >&275
return 176
fi77
main_pkg="$f"78
fi79
done80
if [[ -z "$main_pkg" ]]; then81
echo "No non-debug Arch .pkg.tar.zst in $DIST" >&282
ls -la "$DIST" >&2 || true83
return 184
fi85
printf '%s\t%s\n' "Arch Linux .pkg.tar.zst (x86_64)" "$main_pkg"86
87
if [[ ${#tgzs[@]} -ne 1 ]]; then88
echo "Expected exactly one posprint-*-x86_64.tar.gz in $DIST, found ${#tgzs[@]}" >&289
ls -la "$DIST" >&2 || true90
return 191
fi92
printf '%s\t%s\n' "Linux binary tarball (x86_64, AUR posprint-bin)" "${tgzs[0]}"93
94
if [[ ! -f "$DIST/posprint.exe" ]]; then95
echo "Missing $DIST/posprint.exe" >&296
ls -la "$DIST" >&2 || true97
return 198
fi99
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 ]]; then115
echo "tag=${TAG}"116
echo "version=${VERSION}"117
echo "dist=${DIST}"118
while IFS=$'\t' read -r label path; do119
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 0124
fi125
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" ]]; then137
extra+=(--header "Content-Type: application/json" --data @"$body_file")138
fi139
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 name149
name="$(basename -- "$file")"150
local url151
url="$(generic_file_url "$name")"152
local tmp code153
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" ]]; then159
echo "Uploaded $name ($code)"160
rm -f "$tmp"161
return 0162
fi163
if [[ "$code" == "400" || "$code" == "409" ]] && grep -qiE 'already|exist|duplicate|taken|cannot be reused' "$tmp"; then164
echo "Already uploaded $name (ok)"165
rm -f "$tmp"166
return 0167
fi168
echo "Upload failed for $name ($code): $(cat "$tmp")" >&2169
rm -f "$tmp"170
return 1171
}172
173
echo "Publishing GitLab release ${TAG} from ${DIST}"174
175
while IFS=$'\t' read -r _label path; do176
upload_generic "$path"177
done <<<"$ASSETS"178
179
LINKS_JSON=""180
first=1181
while IFS=$'\t' read -r label path; do182
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 ]]; then189
LINKS_JSON="$item"190
first=0191
else192
LINKS_JSON="${LINKS_JSON},${item}"193
fi194
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"' EXIT200
201
cat >"$CREATE_BODY" <<EOF202
{"name":"posprint ${TAG}","tag_name":"${TAG}","description":"$(json_escape "$DESC")","assets":{"links":[${LINKS_JSON}]}}203
EOF204
205
code="$(api GET "/releases/${TAG}" "" "$RESP")"206
if [[ "$code" == "404" ]]; then207
code="$(api POST "/releases" "$CREATE_BODY" "$RESP")"208
if [[ "$code" != "201" && "$code" != "200" ]]; then209
echo "Failed to create release ($code): $(cat "$RESP")" >&2210
exit 1211
fi212
echo "Created GitLab release ${TAG}"213
exit 0214
fi215
216
if [[ "$code" != "200" ]]; then217
echo "Failed to query release ${TAG} ($code): $(cat "$RESP")" >&2218
exit 1219
fi220
221
UPDATE_BODY="$(mktemp)"222
cat >"$UPDATE_BODY" <<EOF223
{"name":"posprint ${TAG}","description":"$(json_escape "$DESC")"}224
EOF225
code="$(api PUT "/releases/${TAG}" "$UPDATE_BODY" "$RESP")"226
rm -f "$UPDATE_BODY"227
if [[ "$code" != "200" ]]; then228
echo "Failed to update release ${TAG} ($code): $(cat "$RESP")" >&2229
exit 1230
fi231
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" ]]; then235
if command -v jq >/dev/null; then236
mapfile -t LINK_IDS < <(jq -r '.[].id // empty' "$RESP" || true)237
else238
mapfile -t LINK_IDS < <(grep -oE '"id":[0-9]+' "$RESP" | sed 's/"id"://' || true)239
fi240
for link_id in "${LINK_IDS[@]+"${LINK_IDS[@]}"}"; do241
[[ -n "$link_id" ]] || continue242
del_code="$(api DELETE "/releases/${TAG}/assets/links/${link_id}" "" "$RESP")"243
if [[ "$del_code" != "204" && "$del_code" != "200" ]]; then244
echo "Warning: could not delete release link ${link_id} ($del_code): $(cat "$RESP")" >&2245
fi246
done247
fi248
249
while IFS=$'\t' read -r label path; do250
name="$(basename -- "$path")"251
url="$(generic_file_url "$name")"252
link_body="$(mktemp)"253
cat >"$link_body" <<EOF254
{"name":"$(json_escape "$label")","url":"$(json_escape "$url")","link_type":"package","direct_asset_path":"/$(json_escape "$name")"}255
EOF256
code="$(api POST "/releases/${TAG}/assets/links" "$link_body" "$RESP")"257
rm -f "$link_body"258
if [[ "$code" != "201" && "$code" != "200" ]]; then259
echo "Failed to add release link ${name} ($code): $(cat "$RESP")" >&2260
exit 1261
fi262
done <<<"$ASSETS"263
264
echo "Updated GitLab release ${TAG} with Generic Package Registry assets"@@ -0,0 +1,276 @@
1
//! Regression tests for tag-release packaging scripts and CI asset names.
2
//!
3
//! Shell-script integration tests run on Unix only. Windows SaaS runners do not
4
//! have bash; the Linux release path is unchanged and still covered by `test:linux`.
5
6
#[cfg(unix)]
7
mod unix_scripts {
8
use std::fs;
9
use std::path::Path;
10
use std::process::Command;
11
12
fn repo_root() -> std::path::PathBuf {
13
Path::new(env!("CARGO_MANIFEST_DIR")).to_path_buf()
14
}
15
16
fn write_fake_usr_tree(dir: &Path, marker: &str) {
17
let bin = dir.join("usr/bin");
18
fs::create_dir_all(&bin).unwrap();
19
fs::write(bin.join("posprint"), marker).unwrap();
20
}
21
22
fn tar_usr(src_root: &Path, dest_pkg: &Path) {
23
let status = Command::new("tar")
24
.args(["-C", src_root.to_str().unwrap(), "-cf"])
25
.arg(dest_pkg)
26
.arg("usr")
27
.status()
28
.expect("spawn tar");
29
assert!(status.success(), "tar failed creating {}", dest_pkg.display());
30
}
31
32
fn run_tarball_script(args: &[&str]) -> std::process::Output {
33
let script = repo_root().join("scripts/make-linux-bin-tarball.sh");
34
Command::new("bash")
35
.arg(&script)
36
.args(args)
37
.output()
38
.unwrap_or_else(|e| panic!("run make-linux-bin-tarball.sh: {e}"))
39
}
40
41
fn run_publish_release(args: &[&str]) -> std::process::Output {
42
let script = repo_root().join("scripts/publish-gitlab-release.sh");
43
Command::new("bash")
44
.arg(&script)
45
.args(args)
46
.output()
47
.unwrap_or_else(|e| panic!("run publish-gitlab-release.sh: {e}"))
48
}
49
50
#[test]
51
fn tarball_script_ignores_debug_package_when_glob_expands_to_two() {
52
let tmp = tempfile::tempdir().unwrap();
53
let main_root = tmp.path().join("main");
54
let debug_root = tmp.path().join("debug");
55
write_fake_usr_tree(&main_root, "main-bin");
56
write_fake_usr_tree(&debug_root, "debug-bin");
57
58
let main_pkg = tmp.path().join("posprint-0.5.7-1-x86_64.pkg.tar");
59
let debug_pkg = tmp.path().join("posprint-debug-0.5.7-1-x86_64.pkg.tar");
60
tar_usr(&main_root, &main_pkg);
61
tar_usr(&debug_root, &debug_pkg);
62
let debug_before = fs::read(&debug_pkg).unwrap();
63
64
let out = tmp.path().join("posprint-0.5.7-x86_64.tar.gz");
65
let output = run_tarball_script(&[
66
main_pkg.to_str().unwrap(),
67
debug_pkg.to_str().unwrap(),
68
out.to_str().unwrap(),
69
"0.5.7",
70
]);
71
assert!(
72
output.status.success(),
73
"stdout:\n{}\nstderr:\n{}",
74
String::from_utf8_lossy(&output.stdout),
75
String::from_utf8_lossy(&output.stderr)
76
);
77
assert!(out.is_file(), "tarball was not written to the intended out path");
78
assert_ne!(out.metadata().unwrap().len(), 0);
79
assert_eq!(
80
fs::read(&debug_pkg).unwrap(),
81
debug_before,
82
"debug package must not be overwritten when it is $2"
83
);
84
85
let extract = tmp.path().join("extract");
86
fs::create_dir_all(&extract).unwrap();
87
let status = Command::new("tar")
88
.args(["-C", extract.to_str().unwrap(), "-xzf"])
89
.arg(&out)
90
.status()
91
.unwrap();
92
assert!(status.success());
93
let packed = fs::read_to_string(extract.join("usr/bin/posprint")).unwrap();
94
assert_eq!(packed, "main-bin");
95
}
96
97
#[test]
98
fn tarball_script_rejects_only_debug_packages() {
99
let tmp = tempfile::tempdir().unwrap();
100
let debug_root = tmp.path().join("debug");
101
write_fake_usr_tree(&debug_root, "debug-bin");
102
let debug_pkg = tmp.path().join("posprint-debug-0.5.7-1-x86_64.pkg.tar");
103
tar_usr(&debug_root, &debug_pkg);
104
let out = tmp.path().join("posprint-0.5.7-x86_64.tar.gz");
105
106
let output = run_tarball_script(&[
107
debug_pkg.to_str().unwrap(),
108
out.to_str().unwrap(),
109
"0.5.7",
110
]);
111
assert!(!output.status.success());
112
let stderr = String::from_utf8_lossy(&output.stderr);
113
assert!(
114
stderr.contains("No non-debug"),
115
"unexpected stderr: {stderr}"
116
);
117
assert!(!out.exists());
118
}
119
120
#[test]
121
fn tarball_script_classic_three_args_still_works() {
122
let tmp = tempfile::tempdir().unwrap();
123
let main_root = tmp.path().join("main");
124
write_fake_usr_tree(&main_root, "only-main");
125
let main_pkg = tmp.path().join("posprint-0.5.7-1-x86_64.pkg.tar");
126
tar_usr(&main_root, &main_pkg);
127
let out = tmp.path().join("out.tar.gz");
128
129
let output = run_tarball_script(&[main_pkg.to_str().unwrap(), out.to_str().unwrap(), "0.5.7"]);
130
assert!(
131
output.status.success(),
132
"stderr: {}",
133
String::from_utf8_lossy(&output.stderr)
134
);
135
assert!(out.is_file());
136
}
137
138
#[test]
139
fn publish_release_dry_run_uses_real_filenames() {
140
let tmp = tempfile::tempdir().unwrap();
141
let dist = tmp.path();
142
fs::write(dist.join("posprint_0.5.7-1_amd64.deb"), b"deb").unwrap();
143
fs::write(
144
dist.join("posprint-0.5.7-1-x86_64.pkg.tar.zst"),
145
b"pkg",
146
)
147
.unwrap();
148
fs::write(dist.join("posprint-debug-0.5.7-1-x86_64.pkg.tar.zst"), b"dbg").unwrap();
149
fs::write(dist.join("posprint-0.5.7-x86_64.tar.gz"), b"tgz").unwrap();
150
fs::write(dist.join("posprint.exe"), b"exe").unwrap();
151
152
let output = run_publish_release(&[
153
"--dry-run",
154
"--dist",
155
dist.to_str().unwrap(),
156
"0.5.7",
157
]);
158
assert!(
159
output.status.success(),
160
"stdout:\n{}\nstderr:\n{}",
161
String::from_utf8_lossy(&output.stdout),
162
String::from_utf8_lossy(&output.stderr)
163
);
164
let stdout = String::from_utf8_lossy(&output.stdout);
165
assert!(stdout.contains("posprint_0.5.7-1_amd64.deb"));
166
assert!(stdout.contains("posprint-0.5.7-1-x86_64.pkg.tar.zst"));
167
assert!(
168
!stdout.contains("posprint-debug-"),
169
"debug package must not be a release asset:\n{stdout}"
170
);
171
assert!(
172
!stdout.contains("posprint_0.5.7-1-x86_64"),
173
"Arch package must use hyphens, not posprint_ver:\n{stdout}"
174
);
175
assert!(stdout.contains("posprint-0.5.7-x86_64.tar.gz"));
176
assert!(stdout.contains("posprint.exe"));
177
}
178
179
#[test]
180
fn publish_release_dry_run_rejects_missing_tarball() {
181
let tmp = tempfile::tempdir().unwrap();
182
let dist = tmp.path();
183
fs::write(dist.join("posprint_0.5.7-1_amd64.deb"), b"deb").unwrap();
184
fs::write(
185
dist.join("posprint-0.5.7-1-x86_64.pkg.tar.zst"),
186
b"pkg",
187
)
188
.unwrap();
189
fs::write(dist.join("posprint.exe"), b"exe").unwrap();
190
191
let output = run_publish_release(&[
192
"--dry-run",
193
"--dist",
194
dist.to_str().unwrap(),
195
"0.5.7",
196
]);
197
assert!(!output.status.success());
198
let stderr = String::from_utf8_lossy(&output.stderr);
199
assert!(
200
stderr.contains("tar.gz"),
201
"expected missing-tarball error, got: {stderr}"
202
);
203
}
204
}
205
206
#[test]
207
fn gitlab_ci_does_not_use_tag_artifact_permalinks() {
208
let yml = include_str!("../.gitlab-ci.yml");
209
assert!(
210
!yml.contains("jobs/artifacts/"),
211
"release links must not use jobs/artifacts/TAG permalinks"
212
);
213
assert!(
214
!yml.contains("posprint_${CI_COMMIT_TAG#v}_amd64.deb"),
215
"deb link must not drop cargo-deb revision -1"
216
);
217
assert!(
218
!yml.contains("posprint_${CI_COMMIT_TAG#v}-1-x86_64.pkg.tar.zst"),
219
"pkg link must not use underscore after posprint"
220
);
221
assert!(yml.contains("publish-gitlab-release.sh"));
222
assert!(yml.contains("make-linux-bin-tarball.sh"));
223
assert!(
224
yml.contains("build:linux-arch"),
225
"publish:aur must still need the Arch job"
226
);
227
assert!(yml.contains("allow_failure: true"));
228
}
229
230
#[test]
231
fn aur_bin_uses_generic_package_registry() {
232
let pkgbuild = include_str!("../packaging/aur-bin/PKGBUILD");
233
let srcinfo = include_str!("../packaging/aur-bin/.SRCINFO");
234
let publish = include_str!("../scripts/publish-aur.sh");
235
for text in [pkgbuild, srcinfo] {
236
assert!(
237
!text.contains("jobs/artifacts"),
238
"AUR bin templates must not use jobs/artifacts permalinks"
239
);
240
assert!(
241
text.contains("packages/generic/posprint"),
242
"AUR bin templates must use the Generic Package Registry URL"
243
);
244
}
245
assert!(
246
publish.contains("packages/generic/posprint"),
247
"publish-aur.sh fallback must use the Generic Package Registry"
248
);
249
assert!(
250
!publish.contains("BIN_ARTIFACT_URL"),
251
"publish-aur.sh must not curl the old jobs/artifacts permalink"
252
);
253
assert!(
254
publish.contains("Using local binary tarball"),
255
"publish-aur.sh must prefer the local dist/ tarball from CI artifacts"
256
);
257
}
258
259
#[test]
260
fn expected_release_filenames_match_packaging_tools() {
261
// cargo-deb: <name>_<version>-<revision>_<arch>.deb (revision defaults to 1)
262
// makepkg: <pkgname>-<pkgver>-<pkgrel>-<arch>.pkg.tar.zst
263
let version = "0.5.7";
264
assert_eq!(
265
format!("posprint_{version}-1_amd64.deb"),
266
"posprint_0.5.7-1_amd64.deb"
267
);
268
assert_eq!(
269
format!("posprint-{version}-1-x86_64.pkg.tar.zst"),
270
"posprint-0.5.7-1-x86_64.pkg.tar.zst"
271
);
272
assert_eq!(
273
format!("posprint-{version}-x86_64.tar.gz"),
274
"posprint-0.5.7-x86_64.tar.gz"
275
);
276
}
@@ -0,0 +1,276 @@1
//! Regression tests for tag-release packaging scripts and CI asset names.2
//!3
//! Shell-script integration tests run on Unix only. Windows SaaS runners do not4
//! have bash; the Linux release path is unchanged and still covered by `test:linux`.5
6
#[cfg(unix)]7
mod unix_scripts {8
use std::fs;9
use std::path::Path;10
use std::process::Command;11
12
fn repo_root() -> std::path::PathBuf {13
Path::new(env!("CARGO_MANIFEST_DIR")).to_path_buf()14
}15
16
fn write_fake_usr_tree(dir: &Path, marker: &str) {17
let bin = dir.join("usr/bin");18
fs::create_dir_all(&bin).unwrap();19
fs::write(bin.join("posprint"), marker).unwrap();20
}21
22
fn tar_usr(src_root: &Path, dest_pkg: &Path) {23
let status = Command::new("tar")24
.args(["-C", src_root.to_str().unwrap(), "-cf"])25
.arg(dest_pkg)26
.arg("usr")27
.status()28
.expect("spawn tar");29
assert!(status.success(), "tar failed creating {}", dest_pkg.display());30
}31
32
fn run_tarball_script(args: &[&str]) -> std::process::Output {33
let script = repo_root().join("scripts/make-linux-bin-tarball.sh");34
Command::new("bash")35
.arg(&script)36
.args(args)37
.output()38
.unwrap_or_else(|e| panic!("run make-linux-bin-tarball.sh: {e}"))39
}40
41
fn run_publish_release(args: &[&str]) -> std::process::Output {42
let script = repo_root().join("scripts/publish-gitlab-release.sh");43
Command::new("bash")44
.arg(&script)45
.args(args)46
.output()47
.unwrap_or_else(|e| panic!("run publish-gitlab-release.sh: {e}"))48
}49
50
#[test]51
fn tarball_script_ignores_debug_package_when_glob_expands_to_two() {52
let tmp = tempfile::tempdir().unwrap();53
let main_root = tmp.path().join("main");54
let debug_root = tmp.path().join("debug");55
write_fake_usr_tree(&main_root, "main-bin");56
write_fake_usr_tree(&debug_root, "debug-bin");57
58
let main_pkg = tmp.path().join("posprint-0.5.7-1-x86_64.pkg.tar");59
let debug_pkg = tmp.path().join("posprint-debug-0.5.7-1-x86_64.pkg.tar");60
tar_usr(&main_root, &main_pkg);61
tar_usr(&debug_root, &debug_pkg);62
let debug_before = fs::read(&debug_pkg).unwrap();63
64
let out = tmp.path().join("posprint-0.5.7-x86_64.tar.gz");65
let output = run_tarball_script(&[66
main_pkg.to_str().unwrap(),67
debug_pkg.to_str().unwrap(),68
out.to_str().unwrap(),69
"0.5.7",70
]);71
assert!(72
output.status.success(),73
"stdout:\n{}\nstderr:\n{}",74
String::from_utf8_lossy(&output.stdout),75
String::from_utf8_lossy(&output.stderr)76
);77
assert!(out.is_file(), "tarball was not written to the intended out path");78
assert_ne!(out.metadata().unwrap().len(), 0);79
assert_eq!(80
fs::read(&debug_pkg).unwrap(),81
debug_before,82
"debug package must not be overwritten when it is $2"83
);84
85
let extract = tmp.path().join("extract");86
fs::create_dir_all(&extract).unwrap();87
let status = Command::new("tar")88
.args(["-C", extract.to_str().unwrap(), "-xzf"])89
.arg(&out)90
.status()91
.unwrap();92
assert!(status.success());93
let packed = fs::read_to_string(extract.join("usr/bin/posprint")).unwrap();94
assert_eq!(packed, "main-bin");95
}96
97
#[test]98
fn tarball_script_rejects_only_debug_packages() {99
let tmp = tempfile::tempdir().unwrap();100
let debug_root = tmp.path().join("debug");101
write_fake_usr_tree(&debug_root, "debug-bin");102
let debug_pkg = tmp.path().join("posprint-debug-0.5.7-1-x86_64.pkg.tar");103
tar_usr(&debug_root, &debug_pkg);104
let out = tmp.path().join("posprint-0.5.7-x86_64.tar.gz");105
106
let output = run_tarball_script(&[107
debug_pkg.to_str().unwrap(),108
out.to_str().unwrap(),109
"0.5.7",110
]);111
assert!(!output.status.success());112
let stderr = String::from_utf8_lossy(&output.stderr);113
assert!(114
stderr.contains("No non-debug"),115
"unexpected stderr: {stderr}"116
);117
assert!(!out.exists());118
}119
120
#[test]121
fn tarball_script_classic_three_args_still_works() {122
let tmp = tempfile::tempdir().unwrap();123
let main_root = tmp.path().join("main");124
write_fake_usr_tree(&main_root, "only-main");125
let main_pkg = tmp.path().join("posprint-0.5.7-1-x86_64.pkg.tar");126
tar_usr(&main_root, &main_pkg);127
let out = tmp.path().join("out.tar.gz");128
129
let output = run_tarball_script(&[main_pkg.to_str().unwrap(), out.to_str().unwrap(), "0.5.7"]);130
assert!(131
output.status.success(),132
"stderr: {}",133
String::from_utf8_lossy(&output.stderr)134
);135
assert!(out.is_file());136
}137
138
#[test]139
fn publish_release_dry_run_uses_real_filenames() {140
let tmp = tempfile::tempdir().unwrap();141
let dist = tmp.path();142
fs::write(dist.join("posprint_0.5.7-1_amd64.deb"), b"deb").unwrap();143
fs::write(144
dist.join("posprint-0.5.7-1-x86_64.pkg.tar.zst"),145
b"pkg",146
)147
.unwrap();148
fs::write(dist.join("posprint-debug-0.5.7-1-x86_64.pkg.tar.zst"), b"dbg").unwrap();149
fs::write(dist.join("posprint-0.5.7-x86_64.tar.gz"), b"tgz").unwrap();150
fs::write(dist.join("posprint.exe"), b"exe").unwrap();151
152
let output = run_publish_release(&[153
"--dry-run",154
"--dist",155
dist.to_str().unwrap(),156
"0.5.7",157
]);158
assert!(159
output.status.success(),160
"stdout:\n{}\nstderr:\n{}",161
String::from_utf8_lossy(&output.stdout),162
String::from_utf8_lossy(&output.stderr)163
);164
let stdout = String::from_utf8_lossy(&output.stdout);165
assert!(stdout.contains("posprint_0.5.7-1_amd64.deb"));166
assert!(stdout.contains("posprint-0.5.7-1-x86_64.pkg.tar.zst"));167
assert!(168
!stdout.contains("posprint-debug-"),169
"debug package must not be a release asset:\n{stdout}"170
);171
assert!(172
!stdout.contains("posprint_0.5.7-1-x86_64"),173
"Arch package must use hyphens, not posprint_ver:\n{stdout}"174
);175
assert!(stdout.contains("posprint-0.5.7-x86_64.tar.gz"));176
assert!(stdout.contains("posprint.exe"));177
}178
179
#[test]180
fn publish_release_dry_run_rejects_missing_tarball() {181
let tmp = tempfile::tempdir().unwrap();182
let dist = tmp.path();183
fs::write(dist.join("posprint_0.5.7-1_amd64.deb"), b"deb").unwrap();184
fs::write(185
dist.join("posprint-0.5.7-1-x86_64.pkg.tar.zst"),186
b"pkg",187
)188
.unwrap();189
fs::write(dist.join("posprint.exe"), b"exe").unwrap();190
191
let output = run_publish_release(&[192
"--dry-run",193
"--dist",194
dist.to_str().unwrap(),195
"0.5.7",196
]);197
assert!(!output.status.success());198
let stderr = String::from_utf8_lossy(&output.stderr);199
assert!(200
stderr.contains("tar.gz"),201
"expected missing-tarball error, got: {stderr}"202
);203
}204
}205
206
#[test]207
fn gitlab_ci_does_not_use_tag_artifact_permalinks() {208
let yml = include_str!("../.gitlab-ci.yml");209
assert!(210
!yml.contains("jobs/artifacts/"),211
"release links must not use jobs/artifacts/TAG permalinks"212
);213
assert!(214
!yml.contains("posprint_${CI_COMMIT_TAG#v}_amd64.deb"),215
"deb link must not drop cargo-deb revision -1"216
);217
assert!(218
!yml.contains("posprint_${CI_COMMIT_TAG#v}-1-x86_64.pkg.tar.zst"),219
"pkg link must not use underscore after posprint"220
);221
assert!(yml.contains("publish-gitlab-release.sh"));222
assert!(yml.contains("make-linux-bin-tarball.sh"));223
assert!(224
yml.contains("build:linux-arch"),225
"publish:aur must still need the Arch job"226
);227
assert!(yml.contains("allow_failure: true"));228
}229
230
#[test]231
fn aur_bin_uses_generic_package_registry() {232
let pkgbuild = include_str!("../packaging/aur-bin/PKGBUILD");233
let srcinfo = include_str!("../packaging/aur-bin/.SRCINFO");234
let publish = include_str!("../scripts/publish-aur.sh");235
for text in [pkgbuild, srcinfo] {236
assert!(237
!text.contains("jobs/artifacts"),238
"AUR bin templates must not use jobs/artifacts permalinks"239
);240
assert!(241
text.contains("packages/generic/posprint"),242
"AUR bin templates must use the Generic Package Registry URL"243
);244
}245
assert!(246
publish.contains("packages/generic/posprint"),247
"publish-aur.sh fallback must use the Generic Package Registry"248
);249
assert!(250
!publish.contains("BIN_ARTIFACT_URL"),251
"publish-aur.sh must not curl the old jobs/artifacts permalink"252
);253
assert!(254
publish.contains("Using local binary tarball"),255
"publish-aur.sh must prefer the local dist/ tarball from CI artifacts"256
);257
}258
259
#[test]260
fn expected_release_filenames_match_packaging_tools() {261
// cargo-deb: <name>_<version>-<revision>_<arch>.deb (revision defaults to 1)262
// makepkg: <pkgname>-<pkgver>-<pkgrel>-<arch>.pkg.tar.zst263
let version = "0.5.7";264
assert_eq!(265
format!("posprint_{version}-1_amd64.deb"),266
"posprint_0.5.7-1_amd64.deb"267
);268
assert_eq!(269
format!("posprint-{version}-1-x86_64.pkg.tar.zst"),270
"posprint-0.5.7-1-x86_64.pkg.tar.zst"271
);272
assert_eq!(273
format!("posprint-{version}-x86_64.tar.gz"),274
"posprint-0.5.7-x86_64.tar.gz"275
);276
}