forked from bambulab/BambuStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
169 lines (153 loc) · 6.23 KB
/
Copy pathcd-deploy-flatpak.yml
File metadata and controls
169 lines (153 loc) · 6.23 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
name: 'CD: Flatpak'
run-name: "Flatpak — ${{ github.event.release.tag_name || inputs.tag || 'latest' }}"
on:
release:
types: [released]
workflow_dispatch:
inputs:
tag:
description: 'Release tag (e.g. v2.6.1) — leave empty for latest release'
required: false
type: string
permissions: read-all
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
flatpak:
name: Build Flatpak bundle
runs-on: ubuntu-24.04
timeout-minutes: 120
permissions:
contents: write
id-token: write
attestations: write
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 release tag
id: tag
run: |
if [[ "${{ github.event_name }}" == "release" ]]; then
TAG="${{ github.event.release.tag_name }}"
elif [[ -n "${{ inputs.tag }}" ]]; then
TAG="${{ inputs.tag }}"
else
TAG=$(gh release list --repo "${{ github.repository }}" \
--limit 1 --json tagName -q '.[0].tagName')
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Using tag: $TAG"
env:
GH_TOKEN: ${{ github.token }}
- name: Install dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
flatpak flatpak-builder squashfs-tools desktop-file-utils \
appstream elfutils
- name: Add Flathub remote
run: |
flatpak remote-add --user --if-not-exists flathub \
https://dl.flathub.org/repo/flathub.flatpakrepo
- name: Install Flatpak runtimes
run: |
flatpak install --user -y flathub \
org.freedesktop.Platform//24.08 \
org.freedesktop.Sdk//24.08
- name: Download AppImage
id: appimage
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ steps.tag.outputs.tag }}"
VER="${TAG#v}" # 02.07.00.55-bj.2
UPSTREAM_VER="${VER%-bj.*}" # 02.07.00.55 (filename only uses upstream ver)
# Primary: find the GitHub-hosted ubuntu-24.04 amd64 AppImage via API (name pattern: BambuStudio_ubuntu-24.04_amd64_*.AppImage, excluding _selfhosted)
ASSET_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 // ""')
if [[ -n "${ASSET_URL}" ]]; then
echo "Downloading: ${ASSET_URL}"
if curl -fL -o BambuStudio.AppImage "${ASSET_URL}"; then
echo "url=${ASSET_URL}" >> "$GITHUB_OUTPUT"
else
rm -f BambuStudio.AppImage
fi
fi
# Legacy fallback: explicit patterns for older releases
if [[ ! -f BambuStudio.AppImage ]]; then
for PATTERN in \
"Bambu_Studio_ubuntu-24.04_V${UPSTREAM_VER}.AppImage" \
"Bambu_Studio_ubuntu-22.04_V${UPSTREAM_VER}.AppImage" \
"BambuStudio_linux_x86_64_${TAG}.AppImage" \
"BambuStudio_linux_amd64_${TAG}.AppImage" \
"BambuStudio-${TAG}-linux-x86_64.AppImage" \
"BambuStudio.AppImage"; do
URL="https://github.com/${{ github.repository }}/releases/download/${TAG}/${PATTERN}"
if curl -sIf "$URL" >/dev/null 2>&1; then
echo "Fallback download: $URL"
if curl -fL -o BambuStudio.AppImage "$URL"; then
echo "url=$URL" >> "$GITHUB_OUTPUT"
break
else
rm -f BambuStudio.AppImage
fi
fi
done
fi
if [[ ! -f BambuStudio.AppImage ]]; then
echo "::error::No AppImage found for tag $TAG"
exit 1
fi
chmod +x BambuStudio.AppImage
- name: Extract AppImage
run: |
./BambuStudio.AppImage --appimage-extract
echo "Extracted to squashfs-root/"
ls squashfs-root/ | head -10
ls squashfs-root/bin/ 2>/dev/null | head -5 || true
- name: Prepare Flatpak sources
run: |
# Move squashfs-root into flatpak/ so flatpak-builder can find it
mv squashfs-root flatpak/squashfs-root
- name: Build Flatpak bundle
run: |
# flatpak-builder 1.4.2 + AppStream 1.0.2 incompatibility:
# appstreamcli compose exits 1 on 'filters-but-no-output' and 'file-read-error'.
# Both are fixed in flatpak-builder ≥1.4.6 / AppStream ≥1.0.6, but Ubuntu 24.04
# ships the older versions. Wrap appstreamcli so compose never blocks the build.
mkdir -p /tmp/asc-shim
printf '#!/bin/sh\n/usr/bin/appstreamcli "$@" || true\n' \
> /tmp/asc-shim/appstreamcli
chmod +x /tmp/asc-shim/appstreamcli
PATH="/tmp/asc-shim:$PATH" \
flatpak-builder \
--user \
--force-clean \
--repo=flatpak-repo \
--bundle-sources \
flatpak-build \
flatpak/com.bambulab.BambuStudio.yaml
- name: Export Flatpak bundle
run: |
flatpak build-bundle \
--runtime-repo=https://dl.flathub.org/repo/flathub.flatpakrepo \
flatpak-repo \
BambuStudio.flatpak \
com.bambulab.BambuStudio
- name: Upload as artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: BambuStudio-${{ steps.tag.outputs.tag }}-flatpak
path: BambuStudio.flatpak
retention-days: 30
- name: Attach to release
if: github.event_name == 'release'
uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3
with:
tag_name: ${{ steps.tag.outputs.tag }}
files: BambuStudio.flatpak