forked from bambulab/BambuStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (154 loc) · 6.1 KB
/
Copy pathcd-deploy-aur.yml
File metadata and controls
173 lines (154 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: 'CD: AUR Update'
run-name: "AUR update (${{ inputs.channel || 'stable' }}) — ${{ github.event.release.tag_name || inputs.tag || 'latest' }}"
on:
release:
types: [released]
workflow_dispatch:
inputs:
tag:
description: 'Release tag (stable: v02.07.00.55-bj.1 / nightly: nightly-20260531-abc1234)'
required: false
type: string
channel:
description: 'AUR package to update'
required: false
type: choice
default: stable
options: [stable, nightly]
workflow_call:
inputs:
tag:
description: 'Release tag'
required: true
type: string
channel:
description: 'AUR channel: stable or nightly'
required: false
type: string
default: stable
permissions: read-all
concurrency:
group: cd-deploy-aur-${{ inputs.channel || 'stable' }}
cancel-in-progress: false
jobs:
aur-update:
name: Update AUR PKGBUILD (${{ inputs.channel || 'stable' }})
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- name: Harden Runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Determine tag, channel, pkgname, pkgver
id: meta
run: |
set -euo pipefail
# release event → always stable
if [[ "${{ github.event_name }}" == "release" ]]; then
TAG="${{ github.event.release.tag_name }}"
CHANNEL="stable"
elif [[ -n "${{ inputs.tag }}" ]]; then
TAG="${{ inputs.tag }}"
CHANNEL="${{ inputs.channel || 'stable' }}"
else
echo "::error::No tag provided for non-release trigger"
exit 1
fi
if [[ "$CHANNEL" == "nightly" ]]; then
PKGNAME="bambu-studio-nightly-bin"
# nightly tag: nightly-YYYYMMDD-sha7 → pkgver: YYYYMMDD.sha7
DATE_PART=$(echo "$TAG" | cut -d- -f2)
SHA_PART=$(echo "$TAG" | cut -d- -f3)
PKGVER="${DATE_PART}.${SHA_PART}"
else
PKGNAME="bambu-studio-bin"
VERSION="${TAG#v}"
PKGVER="${VERSION//-/.}" # no hyphens in AUR pkgver
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "channel=$CHANNEL" >> "$GITHUB_OUTPUT"
echo "pkgname=$PKGNAME" >> "$GITHUB_OUTPUT"
echo "pkgver=$PKGVER" >> "$GITHUB_OUTPUT"
echo "Tag: $TAG Channel: $CHANNEL pkgname: $PKGNAME pkgver: $PKGVER"
- name: Get AppImage URL and SHA256
id: asset
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="${{ steps.meta.outputs.tag }}"
# Find Ubuntu 24.04 AppImage (GitHub-hosted, not self-hosted).
# Release assets can lag behind the publish job (GitHub eventual
# consistency), so retry a few times before giving up.
URL=""
for attempt in 1 2 3 4 5 6; do
URL=$(gh release view "$TAG" --repo "${{ github.repository }}" --json assets \
--jq '[.assets[]
| select(
(.name | test("^BambuStudio_ubuntu-24\\.04_amd64_.*\\.AppImage$"; "i")) and
(.name | test("_selfhosted\\.AppImage$"; "i") | not)
)] | .[0].url // ""')
[[ -n "$URL" ]] && break
echo "AppImage asset not visible yet for $TAG (attempt $attempt/6) — waiting 20s…"
sleep 20
done
if [[ -z "$URL" ]]; then
echo "::error::No AppImage asset found for tag $TAG after retries"
exit 1
fi
SHA256=$(curl -fsSL "$URL" | sha256sum | cut -d' ' -f1)
echo "url=$URL" >> "$GITHUB_OUTPUT"
echo "sha256=$SHA256" >> "$GITHUB_OUTPUT"
echo "AppImage URL: $URL"
- name: Write PKGBUILD
run: |
set -euo pipefail
PKGNAME="${{ steps.meta.outputs.pkgname }}"
CHANNEL="${{ steps.meta.outputs.channel }}"
if [[ "$CHANNEL" == "nightly" ]]; then
PKGDESC="BambuStudio nightly pre-release builds for Bambu Lab 3D printers"
# Nightly coexists with stable — no provides/conflicts
PROVIDES=""
CONFLICTS=""
else
PKGDESC="BambuStudio slicer for Bambu Lab 3D printers"
PROVIDES="provides=('bambu-studio')"
CONFLICTS="conflicts=('bambu-studio')"
fi
cat > PKGBUILD << PKGBUILD_EOF
# Maintainer: BenJule <benjamin.luetker@gmail.com>
pkgname=${PKGNAME}
pkgver=PKGVER_PLACEHOLDER
pkgrel=1
pkgdesc="${PKGDESC}"
arch=('x86_64')
url="https://github.com/BenJule/BambuStudio"
license=('AGPL3')
${PROVIDES}
${CONFLICTS}
depends=('gtk3' 'glib2' 'glibc' 'libsecret' 'webkit2gtk')
source=("BambuStudio.AppImage::URL_PLACEHOLDER")
sha256sums=('SHA256_PLACEHOLDER')
package() {
install -Dm755 "\$srcdir/BambuStudio.AppImage" "\$pkgdir/usr/bin/bambu-studio"
}
PKGBUILD_EOF
sed -i \
-e "s|PKGVER_PLACEHOLDER|${{ steps.meta.outputs.pkgver }}|g" \
-e "s|URL_PLACEHOLDER|${{ steps.asset.outputs.url }}|g" \
-e "s|SHA256_PLACEHOLDER|${{ steps.asset.outputs.sha256 }}|g" \
PKGBUILD
# Remove blank provides/conflicts lines for nightly
sed -i '/^[[:space:]]*$/d' PKGBUILD
cat PKGBUILD
- name: Publish to AUR
uses: KSXGitHub/github-actions-deploy-aur@da03e160361ce01bf087e790b6ffd196d7dccff7 # v4.1.3
with:
pkgname: ${{ steps.meta.outputs.pkgname }}
pkgbuild: ./PKGBUILD
commit_username: ${{ github.repository_owner }}
commit_email: ${{ github.repository_owner }}@users.noreply.github.com
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "update to ${{ steps.meta.outputs.tag }}"