-
Notifications
You must be signed in to change notification settings - Fork 5
215 lines (191 loc) · 7.77 KB
/
Copy pathrelease.yml
File metadata and controls
215 lines (191 loc) · 7.77 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Publish JetBrains plugin
on:
schedule:
- cron: "17 0 * * *"
repository_dispatch:
types:
- vscode-marketplace-released
workflow_dispatch:
inputs:
version:
description: Zoo Code version to publish (for example, 3.78.0)
required: true
type: string
permissions:
contents: read
concurrency:
group: jetbrains-marketplace-production
cancel-in-progress: false
jobs:
prepare:
name: Find unpublished stable release
runs-on: ubuntu-latest
outputs:
version: ${{ steps.release.outputs.number }}
marketplace-published: ${{ steps.marketplace.outputs.published }}
github-released: ${{ steps.github-release.outputs.published }}
steps:
- name: Resolve and verify the VS Code Marketplace release
id: release
env:
DISPATCH_REPOSITORY: ${{ github.event.client_payload.repository }}
DISPATCH_VERSION: ${{ github.event.client_payload.version }}
MANUAL_VERSION: ${{ inputs.version }}
shell: bash
run: |
expected_repository="Zoo-Code-Org/Zoo-Code"
requested_version="${DISPATCH_VERSION:-$MANUAL_VERSION}"
requested_version="${requested_version#v}"
if [ "$GITHUB_EVENT_NAME" = "repository_dispatch" ] && [ "$DISPATCH_REPOSITORY" != "$expected_repository" ]; then
echo "Expected a release from ${expected_repository}, received ${DISPATCH_REPOSITORY:-<empty>}."
exit 1
fi
if [ -n "$requested_version" ] && [[ ! "$requested_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Version must be a stable semantic version (x.y.z), received: $requested_version."
exit 1
fi
query='{"filters":[{"criteria":[{"filterType":7,"value":"ZooCodeOrganization.zoo-code"}]}],"flags":439}'
response="$(curl --fail --silent --show-error --retry 3 \
-H "Content-Type: application/json" \
-H "Accept: application/json;api-version=7.1-preview.1" \
--data "$query" \
https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery)"
# shellcheck disable=SC2016
version="$(printf '%s' "$response" | REQUESTED_VERSION="$requested_version" node -e '
let input = "";
process.stdin.on("data", chunk => input += chunk);
process.stdin.on("end", () => {
const data = JSON.parse(input);
const requested = process.env.REQUESTED_VERSION;
const versions = data.results?.[0]?.extensions?.[0]?.versions ?? [];
const stable = versions.filter(({ properties = [] }) =>
!properties.some(({ key, value }) =>
key === "Microsoft.VisualStudio.Code.PreRelease" && value === "true"
)
);
const release = requested
? stable.find(({ version }) => version === requested)
: stable[0];
if (!release) {
console.error(requested
? `ZooCodeOrganization.zoo-code ${requested} is not a stable VS Code Marketplace release.`
: "The VS Code Marketplace did not return a stable Zoo Code release.");
process.exit(1);
}
process.stdout.write(release.version);
});
')"
echo "Resolved stable Zoo Code release $version."
echo "number=$version" >> "$GITHUB_OUTPUT"
- name: Check whether this version is already published
id: marketplace
env:
VERSION: ${{ steps.release.outputs.number }}
shell: bash
run: |
if curl --fail --silent --show-error --retry 3 \
"https://plugins.jetbrains.com/api/plugins/32979/updates?size=100" | \
node -e '
let input = "";
process.stdin.on("data", chunk => input += chunk);
process.stdin.on("end", () => {
const updates = JSON.parse(input);
process.exit(updates.some(update => update.version === process.env.VERSION) ? 0 : 1);
});
'; then
echo "published=true" >> "$GITHUB_OUTPUT"
echo "Zoo Code $VERSION is already present on JetBrains Marketplace; skipping the build and upload."
else
echo "published=false" >> "$GITHUB_OUTPUT"
fi
- name: Check whether the GitHub release exists
id: github-release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.release.outputs.number }}
shell: bash
run: |
if gh release view "v${VERSION}" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
echo "published=true" >> "$GITHUB_OUTPUT"
echo "GitHub release v${VERSION} already exists."
else
echo "published=false" >> "$GITHUB_OUTPUT"
fi
publish:
name: Publish Zoo Code ${{ needs.prepare.outputs.version }}
needs: prepare
if: needs.prepare.outputs.marketplace-published != 'true' || needs.prepare.outputs.github-released != 'true'
runs-on: ubuntu-latest
environment: jetbrains-marketplace-production
permissions:
contents: write
steps:
- name: Check out the JetBrains plugin
uses: actions/checkout@v5
with:
lfs: true
submodules: recursive
- name: Set up Java 17
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "17"
cache: gradle
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
cache: npm
cache-dependency-path: extension_host/package-lock.json
- name: Install native Node.js build dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends \
build-essential \
libx11-dev \
libxkbfile-dev \
pkg-config
- name: Prepare the extension host source
run: ./scripts/setup.sh --skip-deps --verbose
- name: Build the plugin from the released VS Code extension
env:
GITHUB_TOKEN: ${{ github.token }}
ZOO_EXTENSION_VERSION: ${{ needs.prepare.outputs.version }}
run: ./scripts/release.sh --mode release --clean --verbose
- name: Publish to JetBrains Marketplace
if: needs.prepare.outputs.marketplace-published != 'true'
env:
PUBLISH_TOKEN: ${{ secrets.JETBRAINS_MARKETPLACE_TOKEN }}
VERSION: ${{ needs.prepare.outputs.version }}
working-directory: jetbrains_plugin
shell: bash
run: |
test -n "$PUBLISH_TOKEN"
test -f "build/distributions/ZooCode-${VERSION}.zip"
./gradlew publishPlugin \
-PdebugMode=release \
-PvscodePlugin=zoo-code \
-PpluginVersion="$VERSION" \
--no-configuration-cache
- name: Create or update the GitHub release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.prepare.outputs.version }}
shell: bash
run: |
tag="v${VERSION}"
artifact="dist/ZooCode-${VERSION}.zip"
notes="Zoo Code ${VERSION} for JetBrains IDEs. This build packages the stable Zoo Code ${VERSION} VS Code Marketplace release."
test -f "$artifact"
if gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release upload "$tag" "$artifact" \
--repo "$GITHUB_REPOSITORY" \
--clobber
else
gh release create "$tag" "$artifact" \
--repo "$GITHUB_REPOSITORY" \
--target "$GITHUB_SHA" \
--title "Zoo Code ${tag}" \
--notes "$notes"
fi