-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (78 loc) · 3.19 KB
/
Copy pathsnap-release.yml
File metadata and controls
84 lines (78 loc) · 3.19 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
# Builds the AgentBridge classic snap from the official release archive and, when the
# store credentials are configured, publishes it to the Snap Store.
#
# Dispatch:
# gh workflow run snap-release.yml --repo Graphene-Lab/AgentBridge-Linux
#
# To enable the automatic store publish, register the snap name once
# (`snapcraft register agentbridge`, requires an Ubuntu SSO login) and set the
# SNAPCRAFT_STORE_CREDENTIALS secret (from `snapcraft export-login`) on this repo.
name: Build and Publish Snap
on:
workflow_dispatch:
inputs:
version:
description: "AgentBridge version to package (tag without v, e.g. 1.26.09.08)"
required: false
default: latest
concurrency:
group: snap-release
cancel-in-progress: false
jobs:
snap:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Render snapcraft.yaml for the target version
shell: bash
run: |
latest_tag() {
curl -fsSL "https://api.github.com/repos/Graphene-Lab/AgentBridge/releases/latest" 2>/dev/null \
| python3 -c 'import sys,json; print(json.load(sys.stdin).get("tag_name") or "")' 2>/dev/null || true
}
VER="${{ inputs.version }}"
if [ -z "$VER" ] || [ "$VER" = "latest" ]; then
VER="$(latest_tag)"; VER="${VER#v}"
fi
[ -n "$VER" ] || { echo "::error::cannot resolve version"; exit 1; }
echo "version=$VER"
# engine archive sha256 (digest) + version marker + source URL are pinned in the
# template; regenerate snap/snapcraft.yaml from snap/snapcraft.yml.in.
python3 - "$VER" <<'PY'
import json, os, pathlib, sys, urllib.request
ver = sys.argv[1]
tpl = pathlib.Path("snap/snapcraft.yml.in").read_text(encoding="utf-8")
digest = ""
with urllib.request.urlopen(
f"https://api.github.com/repos/Graphene-Lab/AgentBridge/releases/tags/v{ver}"
) as r:
rel = json.load(r)
digest = next(a["digest"].split(":", 1)[1]
for a in rel["assets"]
if a["name"] == "agentbridge-linux-x64.tar.gz")
out = tpl.replace("@@VERSION@@", ver).replace("@@SHA256@@", digest)
pathlib.Path("snap/snapcraft.yaml").write_text(out, encoding="utf-8")
pathlib.Path("snap/files/agentbridge-version.txt").write_text(ver + "\n", encoding="utf-8")
print("rendered snap/snapcraft.yaml")
PY
- name: Build the snap
shell: bash
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq snapd
sudo snap install snapcraft --classic
cd snap
sudo snapcraft --destructive-mode
ls -lh *.snap
- name: Publish to the Snap Store
shell: bash
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}
run: |
if [ -z "$SNAPCRAFT_STORE_CREDENTIALS" ]; then
echo "SNAPCRAFT_STORE_CREDENTIALS not configured — snap built locally, publish skipped"
exit 0
fi
cd snap
snapcraft upload *.snap --release=stable