Repository navigation
155 lines (136 loc) · 5.54 KB
/
Copy pathsnap-package.yml
File metadata and controls
155 lines (136 loc) · 5.54 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
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
name: Snap Package
on:
workflow_call:
inputs:
checkout-ref:
required: true
type: string
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
build-snap:
name: Build Snap (Linux ${{ matrix.arch }})
strategy:
matrix:
include:
- arch: amd64
rust_arch: x86_64
runner: ubuntu-24.04
- arch: arm64
rust_arch: aarch64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.checkout-ref }}
fetch-depth: 0
- name: Download prebuilt CLI binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: openshell-${{ matrix.rust_arch }}-unknown-linux-musl
path: prebuilt/cli
- name: Download prebuilt prover binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: openshell-prover-${{ matrix.rust_arch }}-unknown-linux-musl
path: prebuilt/prover
- name: Download prebuilt gateway binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: openshell-gateway-${{ matrix.rust_arch }}-unknown-linux-gnu
path: prebuilt/gateway
- name: Download prebuilt sandbox binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: openshell-sandbox-${{ matrix.rust_arch }}-unknown-linux-musl
path: prebuilt/sandbox
- name: Configure prebuilt binaries
run: |
set -euo pipefail
chmod +x prebuilt/cli/openshell
chmod +x prebuilt/prover/openshell-prover
chmod +x prebuilt/gateway/openshell-gateway
chmod +x prebuilt/sandbox/openshell-sandbox
ls -laR prebuilt/
- name: Prepare snap build directory
run: |
set -euo pipefail
mkdir -p snap/prebuilt
cp prebuilt/cli/openshell snap/prebuilt/openshell
cp prebuilt/prover/openshell-prover snap/prebuilt/openshell-prover
cp prebuilt/gateway/openshell-gateway snap/prebuilt/openshell-gateway
cp prebuilt/sandbox/openshell-sandbox snap/prebuilt/openshell-sandbox
cp tasks/scripts/snap-gateway-wrapper.sh snap/prebuilt/openshell-gateway-wrapper
cp LICENSE snap/prebuilt/
cp README.md snap/prebuilt/
mkdir -p snap/prebuilt/meta/gui
cp snap/local/term.desktop snap/prebuilt/meta/gui/term.desktop
cp snap/local/icon.png snap/prebuilt/meta/gui/icon.png
python3 tasks/scripts/release.py get-version --snap > snap/prebuilt/version
# Canonical's snapcraft image builds on the container itself
# (SNAPCRAFT_BUILD_ENVIRONMENT=host) and runs `snapcraft pack` in
# /project, so no LXD instance or base image download is involved.
- name: Build snap
timeout-minutes: 20
env:
ARCH: ${{ matrix.arch }}
SNAPCRAFT_IMAGE: ghcr.io/canonical/snapcraft:8_core24@sha256:f51fc5081f844bece0bb69d7b19a9c543f4666685da630dd9f9f7d0fb74e08f5
run: |
set -euo pipefail
volume="openshell-snap-${GITHUB_RUN_ID}-${ARCH}"
docker volume create "${volume}" >/dev/null
mkdir -p snapcraft-logs
docker run --rm --platform "linux/${ARCH}" \
--volume "${PWD}:/input:ro" \
--volume "${volume}:/project" \
--entrypoint /bin/sh \
"${SNAPCRAFT_IMAGE}" \
-c 'cp -a /input/snapcraft.yaml /input/snap /project/'
docker run --rm --platform "linux/${ARCH}" \
--volume "${volume}:/project" \
--volume "${PWD}/snapcraft-logs:/root/.local/state/snapcraft/log" \
"${SNAPCRAFT_IMAGE}"
docker run --rm --platform "linux/${ARCH}" \
--volume "${volume}:/project:ro" \
--volume "${PWD}:/output" \
--entrypoint /bin/sh \
"${SNAPCRAFT_IMAGE}" \
-c 'set -eu
for artifact in /project/*.snap /project/*.comp; do
[ -e "${artifact}" ] || continue
cp "${artifact}" /output/
chown "$1" "/output/${artifact##*/}"
done' sh "$(id -u):$(id -g)"
- name: Upload snapcraft logs on failure
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: snapcraft-logs-${{ matrix.arch }}
path: snapcraft-logs/snapcraft-*.log
retention-days: 7
- name: Capture snap filename
id: capture
run: |
set -euo pipefail
SNAP_FILE=$(ls -1 *.snap 2>/dev/null | head -1)
if [ -z "$SNAP_FILE" ]; then
echo "ERROR: No .snap file found after snapcraft pack"
exit 1
fi
echo "snap-file=${SNAP_FILE}" >> $GITHUB_OUTPUT
echo "Built snap: ${SNAP_FILE}"
- name: Upload snap artifact (${{ matrix.arch }})
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: snap-linux-${{ matrix.arch }}
path: |
${{ steps.capture.outputs.snap-file }}
*.comp
retention-days: 5