1010 required : true
1111 type : string
1212 upload-channel :
13- required : true
13+ required : false
1414 type : string
15+ default : " "
1516 description : " Snap Store channel to upload to (e.g., latest/edge, latest/candidate, latest/stable)"
16- github-environment :
17- required : true
18- type : string
19- description : " GitHub deployment environment for approval gates (e.g., latest/edge, latest/stable)"
20- publish :
21- required : false
22- type : boolean
23- default : true
24- description : " Whether to upload the built snap to the Snap Store"
2517
2618 secrets :
2719 publish-credentials :
28- required : true
20+ required : false
2921 description : " Snap Store credentials (SNAPCRAFT_STORE_CREDENTIALS)"
3022
3123permissions :
@@ -47,141 +39,14 @@ jobs:
4739 - arch : arm64
4840 rust_arch : aarch64
4941 runner : linux-arm64-cpu8
50- runs-on : ${{ matrix.runner }}
51- timeout-minutes : 60
52- environment : ${{ inputs.github-environment }}
53- steps :
54- - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
55- with :
56- ref : ${{ inputs.checkout-ref }}
57- fetch-depth : 0
58-
59- - name : Install snapd
60- run : |
61- set -euo pipefail
62- if ! command -v snapd >/dev/null 2>&1; then
63- sudo apt-get update
64- sudo apt-get install -y snapd
65- fi
66- sudo systemctl enable --now snapd.socket
67- sudo systemctl start snapd
68- sudo snap wait system seed.loaded
69-
70- - name : Install LXD
71- run : |
72- set -euo pipefail
73- sudo snap install lxd
74- sudo usermod -aG lxd "$USER"
75- sudo lxd waitready
76- sudo lxd init --auto
77- sudo iptables -P FORWARD ACCEPT
78- sudo chgrp lxd /var/snap/lxd/common/lxd/unix.socket
79- sudo chmod 660 /var/snap/lxd/common/lxd/unix.socket
80-
81- - name : Install snapcraft
82- run : |
83- set -euo pipefail
84- sudo snap install snapcraft --classic
85-
86- - name : Download prebuilt CLI binary
87- uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
88- with :
89- name : openshell-${{ matrix.rust_arch }}-unknown-linux-musl
90- path : prebuilt/cli
91-
92- - name : Download prebuilt gateway binary
93- uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
94- with :
95- name : openshell-gateway-${{ matrix.rust_arch }}-unknown-linux-gnu
96- path : prebuilt/gateway
97-
98- - name : Download prebuilt sandbox binary
99- uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
100- with :
101- name : openshell-sandbox-${{ matrix.rust_arch }}-unknown-linux-musl
102- path : prebuilt/sandbox
103-
104- - name : Configure prebuilt binaries
105- run : |
106- set -euo pipefail
107- chmod +x prebuilt/cli/openshell
108- chmod +x prebuilt/gateway/openshell-gateway
109- chmod +x prebuilt/sandbox/openshell-sandbox
110- ls -laR prebuilt/
111-
112- - name : Prepare snap build directory
113- run : |
114- set -euo pipefail
115- mkdir -p snap/prebuilt
116-
117- cp prebuilt/cli/openshell snap/prebuilt/openshell
118- cp prebuilt/gateway/openshell-gateway snap/prebuilt/openshell-gateway
119- cp prebuilt/sandbox/openshell-sandbox snap/prebuilt/openshell-sandbox
120-
121- cp tasks/scripts/snap-gateway-wrapper.sh snap/prebuilt/openshell-gateway-wrapper
122- cp LICENSE snap/prebuilt/
123- cp README.md snap/prebuilt/
124-
125- mkdir -p snap/prebuilt/meta/gui
126- cp snap/local/term.desktop snap/prebuilt/meta/gui/term.desktop
127- cp snap/local/icon.png snap/prebuilt/meta/gui/icon.png
128-
129- python3 tasks/scripts/release.py get-version --snap > snap/prebuilt/version
130-
131- - name : Build snap
132- run : |
133- set -euo pipefail
134- runtime_dir="/run/user/$(id -u)"
135- sudo install -d -m 0700 -o "$(id -u)" -g "$(id -g)" "$runtime_dir"
136- export XDG_RUNTIME_DIR="$runtime_dir"
137- sg lxd -c "XDG_RUNTIME_DIR=${runtime_dir} snapcraft pack -v"
138-
139- - name : Upload snapcraft logs on failure
140- if : failure()
141- uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
142- with :
143- name : snapcraft-logs
144- path : " ~/.local/state/snapcraft/log/snapcraft-*.log"
145- retention-days : 7
146-
147- - name : Capture snap filename
148- id : capture
149- run : |
150- set -euo pipefail
151- SNAP_FILE=$(ls -1 *.snap 2>/dev/null | head -1)
152- if [ -z "$SNAP_FILE" ]; then
153- echo "ERROR: No .snap file found after snapcraft pack"
154- exit 1
155- fi
156- echo "snap-file=${SNAP_FILE}" >> $GITHUB_OUTPUT
157- echo "Built snap: ${SNAP_FILE}"
158-
159- - name : Upload snap artifact (${{ matrix.arch }})
160- uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
161- with :
162- name : snap-linux-${{ matrix.arch }}
163- path : |
164- ${{ steps.capture.outputs.snap-file }}
165- *.comp
166- retention-days : 5
167-
168- - name : Upload snap to Snap Store
169- if : inputs.publish
170- env :
171- SNAPCRAFT_STORE_CREDENTIALS : ${{ secrets.publish-credentials }}
172- INPUTS_UPLOAD_CHANNEL : ${{ inputs.upload-channel }}
173- run : |
174- set -euo pipefail
175- SNAP_FILE="${{ steps.capture.outputs.snap-file }}"
176- SNAP_NAME="${SNAP_FILE%.snap}"
177- SNAP_NAME="${SNAP_NAME%%_*}"
178-
179- COMPONENT_ARGS=()
180- shopt -s nullglob
181- for comp in "${SNAP_NAME}"+*.comp; do
182- echo "Adding component: $comp"
183- COMPONENT_ARGS+=(--component "$comp")
184- done
185-
186- echo "Uploading $SNAP_FILE to ${INPUTS_UPLOAD_CHANNEL}"
187- snapcraft upload --release "${INPUTS_UPLOAD_CHANNEL}" "$SNAP_FILE" "${COMPONENT_ARGS[@]}"
42+ uses : ./.github/workflows/build-snap.yml
43+ with :
44+ checkout-ref : ${{ inputs.checkout-ref }}
45+ arch : ${{ matrix.arch }}
46+ runner : ${{ matrix.runner }}
47+ cli-artifact-name : openshell-${{ matrix.rust_arch }}-unknown-linux-musl
48+ gateway-artifact-name : openshell-gateway-${{ matrix.rust_arch }}-unknown-linux-gnu
49+ supervisor-artifact-name : openshell-sandbox-${{ matrix.rust_arch }}-unknown-linux-musl
50+ upload-channel : ${{ inputs.upload-channel }}
51+ secrets :
52+ publish-credentials : ${{ secrets.publish-credentials }}
0 commit comments