forked from opensandbox-group/OpenSandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (171 loc) · 5.88 KB
/
release-generic.yml
File metadata and controls
193 lines (171 loc) · 5.88 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Generic Release
on:
workflow_dispatch:
inputs:
target:
description: "Release target key"
required: true
type: choice
options:
- js/sandbox
- js/code-interpreter
- python/sandbox
- python/code-interpreter
- python/mcp/sandbox
- java/sandbox
- java/code-interpreter
- csharp/sandbox
- csharp/code-interpreter
- sdks/sandbox/go
- cli
- server
- docker/execd
- docker/code-interpreter
- docker/ingress
- docker/egress
- k8s/controller
- k8s/task-executor
- helm/opensandbox
- helm
version:
description: "Version to release (e.g. 1.0.5 or v0.3.0)"
required: true
type: string
from_tag:
description: "Optional previous tag override"
required: false
type: string
no_path_filter:
description: "Disable default target path filtering"
required: true
default: false
type: boolean
extra_paths:
description: "Optional extra paths (comma-separated)"
required: false
type: string
initial_release:
description: "Allow release without previous tag"
required: true
default: false
type: boolean
push_tag:
description: "Push new tag to origin"
required: true
default: false
type: boolean
dry_run:
description: "Preview only, no side effects"
required: true
default: true
type: boolean
permissions:
contents: write
id-token: write
attestations: write
artifact-metadata: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Ensure script executable
run: chmod +x scripts/release/create-release.sh
- name: Run generic release script
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
ARGS=(
--target "${{ inputs.target }}"
--version "${{ inputs.version }}"
)
if [[ -n "${{ inputs.from_tag }}" ]]; then
ARGS+=(--from-tag "${{ inputs.from_tag }}")
fi
if [[ "${{ inputs.no_path_filter }}" == "true" ]]; then
ARGS+=(--no-path-filter)
fi
if [[ -n "${{ inputs.extra_paths }}" ]]; then
IFS=',' read -r -a EXTRA_PATHS <<< "${{ inputs.extra_paths }}"
for path in "${EXTRA_PATHS[@]}"; do
trimmed="$(echo "$path" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
if [[ -n "$trimmed" ]]; then
ARGS+=(--path "$trimmed")
fi
done
fi
if [[ "${{ inputs.initial_release }}" == "true" ]]; then
ARGS+=(--initial-release)
fi
if [[ "${{ inputs.push_tag }}" == "true" ]]; then
ARGS+=(--push)
fi
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
ARGS+=(--dry-run)
fi
scripts/release/create-release.sh "${ARGS[@]}"
- name: Verify release tag on origin
if: ${{ inputs.dry_run == false }}
env:
RELEASE_TAG: ${{ steps.release.outputs.tag }}
run: |
set -euo pipefail
local_commit="$(git rev-parse "${RELEASE_TAG}^{commit}")"
remote_commit="$(git ls-remote origin "refs/tags/${RELEASE_TAG}^{}" | awk 'NR == 1 { print $1 }')"
if [[ -z "$remote_commit" ]]; then
remote_commit="$(git ls-remote origin "refs/tags/${RELEASE_TAG}" | awk 'NR == 1 { print $1 }')"
fi
if [[ -z "$remote_commit" ]]; then
echo "::error::Release tag '${RELEASE_TAG}' does not exist on origin. Re-run with push_tag=true or push the tag before publishing source artifacts."
exit 1
fi
if [[ "$local_commit" != "$remote_commit" ]]; then
echo "::error::Local release tag '${RELEASE_TAG}' resolves to ${local_commit}, but origin resolves to ${remote_commit}. Refusing to publish source artifacts."
exit 1
fi
- name: Create release source archive
if: ${{ inputs.dry_run == false }}
id: source_archive
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ steps.release.outputs.tag }}
run: |
set -euo pipefail
SAFE_TAG="$(printf '%s' "$RELEASE_TAG" | tr '/:' '--')"
ARCHIVE_NAME="opensandbox-${SAFE_TAG}.tar.gz"
ARCHIVE_DIR="dist/release-source"
mkdir -p "$ARCHIVE_DIR"
git archive \
--format=tar.gz \
--prefix="opensandbox-${SAFE_TAG}/" \
-o "${ARCHIVE_DIR}/${ARCHIVE_NAME}" \
"$RELEASE_TAG"
(
cd "$ARCHIVE_DIR"
sha256sum "$ARCHIVE_NAME" > SHA256SUMS
)
echo "archive_path=${ARCHIVE_DIR}/${ARCHIVE_NAME}" >> "$GITHUB_OUTPUT"
echo "checksums_path=${ARCHIVE_DIR}/SHA256SUMS" >> "$GITHUB_OUTPUT"
- name: Attest source release artifacts
if: ${{ inputs.dry_run == false }}
uses: actions/attest@v4
with:
subject-path: |
${{ steps.source_archive.outputs.archive_path }}
${{ steps.source_archive.outputs.checksums_path }}
- name: Upload source release artifacts
if: ${{ inputs.dry_run == false }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ steps.release.outputs.tag }}
run: |
set -euo pipefail
gh release upload "$RELEASE_TAG" \
"${{ steps.source_archive.outputs.archive_path }}" \
"${{ steps.source_archive.outputs.checksums_path }}" \
--clobber