BlueGit

timfa posprint

Fix AUR CI key handling and bootstrap docs.

Co-authored-by: Cursor <cursoragent@cursor.com>

timfa Tim Falken · pushed by timfa

Authored 2026-07-21 · 3 months ago

Hash
9611cde414fc25475d8dffbd4bd1d2f63a27eb01
Parent
8d260d25
5 files changed +122 −55
.gitlab-ci.yml +3 −5
@@ -138,11 +138,9 @@ publish:aur:
138 138 - release:gitlab
139 139 before_script:
140 140 - pacman -Syu --noconfirm
141 - pacman -S --noconfirm --needed rust cargo pkgconf openssl libxkbcommon libxcb dbus wayland libx11 fontconfig freetype2 libglvnd git rsync curl openssh
142 - install -d -m 700 ~/.ssh
143 - printf "%s\n" "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
144 - chmod 600 ~/.ssh/id_ed25519
145 - ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
141 - pacman -S --noconfirm --needed rust cargo pkgconf openssl libxkbcommon libxcb dbus wayland libx11 fontconfig freetype2 libglvnd git rsync curl openssh coreutils
142 - chmod +x scripts/aur-ssh-setup.sh
143 - ./scripts/aur-ssh-setup.sh
146 144 script:
147 145 - chmod +x scripts/publish-aur.sh
148 146 - ./scripts/publish-aur.sh "$CI_COMMIT_TAG"
@@ -138,11 +138,9 @@ publish:aur:
138 - release:gitlab
138 - release:gitlab
139 before_script:
139 before_script:
140 - pacman -Syu --noconfirm
140 - pacman -Syu --noconfirm
141 - pacman -S --noconfirm --needed rust cargo pkgconf openssl libxkbcommon libxcb dbus wayland libx11 fontconfig freetype2 libglvnd git rsync curl openssh
141 - pacman -S --noconfirm --needed rust cargo pkgconf openssl libxkbcommon libxcb dbus wayland libx11 fontconfig freetype2 libglvnd git rsync curl openssh coreutils
142 - install -d -m 700 ~/.ssh
142 - chmod +x scripts/aur-ssh-setup.sh
143 - printf "%s\n" "$AUR_SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
143 - ./scripts/aur-ssh-setup.sh
144 - chmod 600 ~/.ssh/id_ed25519
145 - ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts
146 script:
144 script:
147 - chmod +x scripts/publish-aur.sh
145 - chmod +x scripts/publish-aur.sh
148 - ./scripts/publish-aur.sh "$CI_COMMIT_TAG"
146 - ./scripts/publish-aur.sh "$CI_COMMIT_TAG"
docs/AUR.md +57 −23
@@ -24,6 +24,8 @@ That keeps the AUR package simple, reproducible, and aligned with upstream tags.
24 24 | `packaging/aur/PKGBUILD` | AUR package template |
25 25 | `packaging/aur/.SRCINFO` | Initial generated metadata |
26 26 | `scripts/publish-aur.sh` | Clone AUR repo, update `PKGBUILD`/`.SRCINFO`, commit, push |
27 | `scripts/aur-ssh-setup.sh` | Install SSH key from GitLab File or base64 variable |
28 | `scripts/bootstrap-aur-repo.sh` | One-time initial push to create the AUR repo |
27 29 | `.gitlab-ci.yml` | Runs AUR publish on tags |
28 30
29 31 ## Release flow
@@ -43,46 +45,78 @@ When a Git tag is pushed:
43 45
44 46 ## GitLab CI secrets
45 47
46 Create these **CI/CD variables** in GitLab:
48 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.
47 49
48 | Variable | Required | Notes |
49 |----------|----------|-------|
50 | `AUR_SSH_PRIVATE_KEY` | yes | Private SSH key for your AUR account; use **masked** + **protected** |
51 | `AUR_GIT_AUTHOR_NAME` | recommended | Example: `Tim Falken` or `posprint release bot` |
52 | `AUR_GIT_AUTHOR_EMAIL` | recommended | Example: `you@example.com` |
53 | `AUR_PKGBASE` | optional | Defaults to `posprint`; only needed if the AUR repo name differs |
50 Use **one** of these:
54 51
55 Recommended GitLab settings:
52 ### Option A — File variable (simplest)
56 53
57 - mark the variables as **Protected**
58 - mark `AUR_SSH_PRIVATE_KEY` as **Masked**
59 - only allow the release/tag pipeline on protected tags
54 | Variable | Type | Value |
55 |----------|------|--------|
56 | `AUR_SSH_PRIVATE_KEY` | **File** | Paste the full private key file (including `BEGIN` / `END` lines) |
57 | `AUR_GIT_AUTHOR_NAME` | Variable | Your name |
58 | `AUR_GIT_AUTHOR_EMAIL` | Variable | Your email |
59 | `AUR_PKGBASE` | Variable (optional) | Defaults to `posprint` |
60 60
61 ## How to create the AUR repository
61 Mark `AUR_SSH_PRIVATE_KEY` as **Protected**. File variables cannot be masked; that is normal for SSH keys.
62 62
63 If you have an AUR account but no package yet:
63 ### Option B — Base64 (maskable)
64 64
65 1. Make sure your **SSH public key** is added to your AUR account profile.
66 2. On an Arch machine (or any machine with `git` + `makepkg`), create a working directory:
65 On your machine, encode the private key as **one line** (no spaces):
67 66
68 67 ```bash
69 mkdir ~/posprint-aur
70 cd ~/posprint-aur
71 git init
72 git remote add origin ssh://aur@aur.archlinux.org/posprint.git
68 # Linux
69 base64 -w0 ~/.ssh/id_ed25519
70
71 # macOS
72 base64 -i ~/.ssh/id_ed25519 | tr -d '\n'
73
74 # PowerShell (Windows)
75 [Convert]::ToBase64String([IO.File]::ReadAllBytes("$env:USERPROFILE\.ssh\id_ed25519"))
73 76 ```
74 77
75 3. Copy in the initial metadata from this repo:
78 Store the output in GitLab as:
79
80 | Variable | Notes |
81 |----------|--------|
82 | `AUR_SSH_PRIVATE_KEY_B64` | The single-line base64 string; can be **Masked** + **Protected** |
83
84 CI decodes it via `scripts/aur-ssh-setup.sh`.
85
86 ### Public vs private key
87
88 What you add on [aur.archlinux.org](https://aur.archlinux.org) under **SSH keys** is the **public** key (one line starting with `ssh-ed25519 AAAA...`).
89 Never paste the **private** key (`-----BEGIN OPENSSH PRIVATE KEY-----`) in chat, GitLab logs, or the repo.
90
91 Recommended:
92
93 - mark release variables as **Protected**
94 - run tag pipelines only on **protected tags**
95
96 ## How to create the AUR repository
97
98 If you have an AUR account but no package yet:
99
100 1. Add your **SSH public key** (one line, `ssh-ed25519 AAAA...`) on [aur.archlinux.org](https://aur.archlinux.org) → Account → SSH keys.
101 That is **not** the private key file from `~/.ssh/id_ed25519`.
102 2. On a machine where `ssh -T aur@aur.archlinux.org` works, from this repo:
76 103
77 104 ```bash
78 cp /path/to/posprint/packaging/aur/PKGBUILD .
79 cp /path/to/posprint/packaging/aur/.SRCINFO .
105 chmod +x scripts/bootstrap-aur-repo.sh scripts/aur-ssh-setup.sh
106 ./scripts/bootstrap-aur-repo.sh
80 107 ```
81 108
82 4. Commit and push:
109 This copies `packaging/aur/PKGBUILD` and `.SRCINFO`, commits, and pushes to `ssh://aur@aur.archlinux.org/posprint.git`.
110
111 Manual equivalent:
83 112
84 113 ```bash
114 mkdir ~/posprint-aur && cd ~/posprint-aur
115 git init
116 git remote add origin ssh://aur@aur.archlinux.org/posprint.git
85 117 git checkout -b master
118 cp /path/to/posprint/packaging/aur/PKGBUILD .
119 cp /path/to/posprint/packaging/aur/.SRCINFO .
86 120 git add PKGBUILD .SRCINFO
87 121 git commit -m "initial import"
88 122 git push origin master
@@ -24,6 +24,8 @@ That keeps the AUR package simple, reproducible, and aligned with upstream tags.
24| `packaging/aur/PKGBUILD` | AUR package template |
24| `packaging/aur/PKGBUILD` | AUR package template |
25| `packaging/aur/.SRCINFO` | Initial generated metadata |
25| `packaging/aur/.SRCINFO` | Initial generated metadata |
26| `scripts/publish-aur.sh` | Clone AUR repo, update `PKGBUILD`/`.SRCINFO`, commit, push |
26| `scripts/publish-aur.sh` | Clone AUR repo, update `PKGBUILD`/`.SRCINFO`, commit, push |
27| `scripts/aur-ssh-setup.sh` | Install SSH key from GitLab File or base64 variable |
28| `scripts/bootstrap-aur-repo.sh` | One-time initial push to create the AUR repo |
27| `.gitlab-ci.yml` | Runs AUR publish on tags |
29| `.gitlab-ci.yml` | Runs AUR publish on tags |
28
30
29## Release flow
31## Release flow
@@ -43,46 +45,78 @@ When a Git tag is pushed:
43
45
44## GitLab CI secrets
46## GitLab CI secrets
45
47
46Create these **CI/CD variables** in GitLab:
48GitLab **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.
47
49
48| Variable | Required | Notes |
50Use **one** of these:
49|----------|----------|-------|
50| `AUR_SSH_PRIVATE_KEY` | yes | Private SSH key for your AUR account; use **masked** + **protected** |
51| `AUR_GIT_AUTHOR_NAME` | recommended | Example: `Tim Falken` or `posprint release bot` |
52| `AUR_GIT_AUTHOR_EMAIL` | recommended | Example: `you@example.com` |
53| `AUR_PKGBASE` | optional | Defaults to `posprint`; only needed if the AUR repo name differs |
54
51
55Recommended GitLab settings:
52### Option A — File variable (simplest)
56
53
57- mark the variables as **Protected**
54| Variable | Type | Value |
58- mark `AUR_SSH_PRIVATE_KEY` as **Masked**
55|----------|------|--------|
59- only allow the release/tag pipeline on protected tags
56| `AUR_SSH_PRIVATE_KEY` | **File** | Paste the full private key file (including `BEGIN` / `END` lines) |
57| `AUR_GIT_AUTHOR_NAME` | Variable | Your name |
58| `AUR_GIT_AUTHOR_EMAIL` | Variable | Your email |
59| `AUR_PKGBASE` | Variable (optional) | Defaults to `posprint` |
60
60
61## How to create the AUR repository
61Mark `AUR_SSH_PRIVATE_KEY` as **Protected**. File variables cannot be masked; that is normal for SSH keys.
62
62
63If you have an AUR account but no package yet:
63### Option B — Base64 (maskable)
64
64
651. Make sure your **SSH public key** is added to your AUR account profile.
65On your machine, encode the private key as **one line** (no spaces):
662. On an Arch machine (or any machine with `git` + `makepkg`), create a working directory:
67
66
68```bash
67```bash
69mkdir ~/posprint-aur
68# Linux
70cd ~/posprint-aur
69base64 -w0 ~/.ssh/id_ed25519
71git init
70
72git remote add origin ssh://aur@aur.archlinux.org/posprint.git
71# macOS
72base64 -i ~/.ssh/id_ed25519 | tr -d '\n'
73
74# PowerShell (Windows)
75[Convert]::ToBase64String([IO.File]::ReadAllBytes("$env:USERPROFILE\.ssh\id_ed25519"))
73```
76```
74
77
753. Copy in the initial metadata from this repo:
78Store the output in GitLab as:
79
80| Variable | Notes |
81|----------|--------|
82| `AUR_SSH_PRIVATE_KEY_B64` | The single-line base64 string; can be **Masked** + **Protected** |
83
84CI decodes it via `scripts/aur-ssh-setup.sh`.
85
86### Public vs private key
87
88What you add on [aur.archlinux.org](https://aur.archlinux.org) under **SSH keys** is the **public** key (one line starting with `ssh-ed25519 AAAA...`).
89Never paste the **private** key (`-----BEGIN OPENSSH PRIVATE KEY-----`) in chat, GitLab logs, or the repo.
90
91Recommended:
92
93- mark release variables as **Protected**
94- run tag pipelines only on **protected tags**
95
96## How to create the AUR repository
97
98If you have an AUR account but no package yet:
99
1001. Add your **SSH public key** (one line, `ssh-ed25519 AAAA...`) on [aur.archlinux.org](https://aur.archlinux.org) → Account → SSH keys.
101 That is **not** the private key file from `~/.ssh/id_ed25519`.
1022. On a machine where `ssh -T aur@aur.archlinux.org` works, from this repo:
76
103
77```bash
104```bash
78cp /path/to/posprint/packaging/aur/PKGBUILD .
105chmod +x scripts/bootstrap-aur-repo.sh scripts/aur-ssh-setup.sh
79cp /path/to/posprint/packaging/aur/.SRCINFO .
106./scripts/bootstrap-aur-repo.sh
80```
107```
81
108
824. Commit and push:
109This copies `packaging/aur/PKGBUILD` and `.SRCINFO`, commits, and pushes to `ssh://aur@aur.archlinux.org/posprint.git`.
110
111Manual equivalent:
83
112
84```bash
113```bash
114mkdir ~/posprint-aur && cd ~/posprint-aur
115git init
116git remote add origin ssh://aur@aur.archlinux.org/posprint.git
85git checkout -b master
117git checkout -b master
118cp /path/to/posprint/packaging/aur/PKGBUILD .
119cp /path/to/posprint/packaging/aur/.SRCINFO .
86git add PKGBUILD .SRCINFO
120git add PKGBUILD .SRCINFO
87git commit -m "initial import"
121git commit -m "initial import"
88git push origin master
122git push origin master
packaging/aur/.SRCINFO +0 −27
@@ -25,30 +25,3 @@ pkgbase = posprint
25 25 sha256sums = b54a73c38deb9c57388039b00fd451038264b6fa3694348456108fb3c117f923
26 26
27 27 pkgname = posprint
28 pkgbase = posprint
29 pkgdesc = Designer for POS-print documents with live preview and USB ESC/POS printing
30 pkgver = 0.4.0
31 pkgrel = 1
32 url = https://gitlab.com/Timfa/posprint
33 arch = x86_64
34 license = MIT
35 makedepends = rust
36 makedepends = cargo
37 makedepends = pkgconf
38 makedepends = git
39 makedepends = rsync
40 depends = gcc-libs
41 depends = libxkbcommon
42 depends = libxcb
43 depends = openssl
44 depends = dbus
45 depends = wayland
46 depends = libx11
47 depends = fontconfig
48 depends = freetype2
49 depends = libglvnd
50 options = !lto
51 source = https://gitlab.com/Timfa/posprint/-/archive/0.4.0/posprint-0.4.0.tar.gz
52 sha256sums = b54a73c38deb9c57388039b00fd451038264b6fa3694348456108fb3c117f923
53
54 pkgname = posprint
@@ -25,30 +25,3 @@ pkgbase = posprint
25 sha256sums = b54a73c38deb9c57388039b00fd451038264b6fa3694348456108fb3c117f923
25 sha256sums = b54a73c38deb9c57388039b00fd451038264b6fa3694348456108fb3c117f923
26
26
27pkgname = posprint
27pkgname = posprint
28pkgbase = posprint
29 pkgdesc = Designer for POS-print documents with live preview and USB ESC/POS printing
30 pkgver = 0.4.0
31 pkgrel = 1
32 url = https://gitlab.com/Timfa/posprint
33 arch = x86_64
34 license = MIT
35 makedepends = rust
36 makedepends = cargo
37 makedepends = pkgconf
38 makedepends = git
39 makedepends = rsync
40 depends = gcc-libs
41 depends = libxkbcommon
42 depends = libxcb
43 depends = openssl
44 depends = dbus
45 depends = wayland
46 depends = libx11
47 depends = fontconfig
48 depends = freetype2
49 depends = libglvnd
50 options = !lto
51 source = https://gitlab.com/Timfa/posprint/-/archive/0.4.0/posprint-0.4.0.tar.gz
52 sha256sums = b54a73c38deb9c57388039b00fd451038264b6fa3694348456108fb3c117f923
53
54pkgname = posprint
scripts/aur-ssh-setup.sh added +28 −0
@@ -0,0 +1,28 @@
1 #!/usr/bin/env bash
2 # Write ~/.ssh/id_ed25519 for AUR pushes from CI or local scripts.
3 #
4 # Supported GitLab CI variables (pick one):
5 # AUR_SSH_PRIVATE_KEY_B64 — base64-encoded private key (one line; can be Masked)
6 # AUR_SSH_PRIVATE_KEY — GitLab "File" variable (path to temp file), or raw key text
7 set -euo pipefail
8
9 KEY_PATH="${1:-$HOME/.ssh/id_ed25519}"
10
11 install -d -m 700 "$(dirname "$KEY_PATH")"
12
13 if [[ -n "${AUR_SSH_PRIVATE_KEY_B64:-}" ]]; then
14 echo "$AUR_SSH_PRIVATE_KEY_B64" | base64 -d > "$KEY_PATH"
15 elif [[ -n "${AUR_SSH_PRIVATE_KEY:-}" && -f "${AUR_SSH_PRIVATE_KEY}" ]]; then
16 # GitLab CI/CD variable type "File"
17 cp "$AUR_SSH_PRIVATE_KEY" "$KEY_PATH"
18 elif [[ -n "${AUR_SSH_PRIVATE_KEY:-}" ]]; then
19 printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$KEY_PATH"
20 elif [[ -f "$HOME/.ssh/id_ed25519" ]]; then
21 cp "$HOME/.ssh/id_ed25519" "$KEY_PATH"
22 else
23 echo "No AUR SSH key found. Set AUR_SSH_PRIVATE_KEY_B64 or AUR_SSH_PRIVATE_KEY." >&2
24 exit 1
25 fi
26
27 chmod 600 "$KEY_PATH"
28 ssh-keyscan aur.archlinux.org >> "$HOME/.ssh/known_hosts" 2>/dev/null || true
@@ -0,0 +1,28 @@
1#!/usr/bin/env bash
2# Write ~/.ssh/id_ed25519 for AUR pushes from CI or local scripts.
3#
4# Supported GitLab CI variables (pick one):
5# AUR_SSH_PRIVATE_KEY_B64 — base64-encoded private key (one line; can be Masked)
6# AUR_SSH_PRIVATE_KEY — GitLab "File" variable (path to temp file), or raw key text
7set -euo pipefail
8
9KEY_PATH="${1:-$HOME/.ssh/id_ed25519}"
10
11install -d -m 700 "$(dirname "$KEY_PATH")"
12
13if [[ -n "${AUR_SSH_PRIVATE_KEY_B64:-}" ]]; then
14 echo "$AUR_SSH_PRIVATE_KEY_B64" | base64 -d > "$KEY_PATH"
15elif [[ -n "${AUR_SSH_PRIVATE_KEY:-}" && -f "${AUR_SSH_PRIVATE_KEY}" ]]; then
16 # GitLab CI/CD variable type "File"
17 cp "$AUR_SSH_PRIVATE_KEY" "$KEY_PATH"
18elif [[ -n "${AUR_SSH_PRIVATE_KEY:-}" ]]; then
19 printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$KEY_PATH"
20elif [[ -f "$HOME/.ssh/id_ed25519" ]]; then
21 cp "$HOME/.ssh/id_ed25519" "$KEY_PATH"
22else
23 echo "No AUR SSH key found. Set AUR_SSH_PRIVATE_KEY_B64 or AUR_SSH_PRIVATE_KEY." >&2
24 exit 1
25fi
26
27chmod 600 "$KEY_PATH"
28ssh-keyscan aur.archlinux.org >> "$HOME/.ssh/known_hosts" 2>/dev/null || true
scripts/bootstrap-aur-repo.sh added +34 −0
@@ -0,0 +1,34 @@
1 #!/usr/bin/env bash
2 # One-time: create the AUR package repo and push initial PKGBUILD + .SRCINFO.
3 # Run on a machine where your AUR SSH key works (same key as on aur.archlinux.org).
4 set -euo pipefail
5
6 ROOT="$(cd "$(dirname "$0")/.." && pwd)"
7 PKGBASE="${AUR_PKGBASE:-posprint}"
8 AUR_REMOTE="ssh://aur@aur.archlinux.org/${PKGBASE}.git"
9 WORKDIR="${TMPDIR:-/tmp}/${PKGBASE}-aur-bootstrap-$$"
10 cleanup() { rm -rf "$WORKDIR"; }
11 trap cleanup EXIT
12
13 for cmd in git ssh; do
14 command -v "$cmd" >/dev/null || { echo "Missing: $cmd" >&2; exit 1; }
15 done
16
17 "$ROOT/scripts/aur-ssh-setup.sh"
18
19 mkdir -p "$WORKDIR/repo"
20 cd "$WORKDIR/repo"
21 git init
22 git remote add origin "$AUR_REMOTE"
23 git checkout -b master
24
25 cp "$ROOT/packaging/aur/PKGBUILD" .
26 cp "$ROOT/packaging/aur/.SRCINFO" .
27
28 git add PKGBUILD .SRCINFO
29 git commit -m "initial import"
30
31 echo "Pushing to $AUR_REMOTE ..."
32 git push -u origin master
33
34 echo "Done. AUR package should appear at: https://aur.archlinux.org/packages/${PKGBASE}"
@@ -0,0 +1,34 @@
1#!/usr/bin/env bash
2# One-time: create the AUR package repo and push initial PKGBUILD + .SRCINFO.
3# Run on a machine where your AUR SSH key works (same key as on aur.archlinux.org).
4set -euo pipefail
5
6ROOT="$(cd "$(dirname "$0")/.." && pwd)"
7PKGBASE="${AUR_PKGBASE:-posprint}"
8AUR_REMOTE="ssh://aur@aur.archlinux.org/${PKGBASE}.git"
9WORKDIR="${TMPDIR:-/tmp}/${PKGBASE}-aur-bootstrap-$$"
10cleanup() { rm -rf "$WORKDIR"; }
11trap cleanup EXIT
12
13for cmd in git ssh; do
14 command -v "$cmd" >/dev/null || { echo "Missing: $cmd" >&2; exit 1; }
15done
16
17"$ROOT/scripts/aur-ssh-setup.sh"
18
19mkdir -p "$WORKDIR/repo"
20cd "$WORKDIR/repo"
21git init
22git remote add origin "$AUR_REMOTE"
23git checkout -b master
24
25cp "$ROOT/packaging/aur/PKGBUILD" .
26cp "$ROOT/packaging/aur/.SRCINFO" .
27
28git add PKGBUILD .SRCINFO
29git commit -m "initial import"
30
31echo "Pushing to $AUR_REMOTE ..."
32git push -u origin master
33
34echo "Done. AUR package should appear at: https://aur.archlinux.org/packages/${PKGBASE}"