Skip to content

Commit ab7225e

Browse files
committed
Handle bumping the version ourselves
1 parent 77b3d81 commit ab7225e

File tree

5 files changed

+103
-3
lines changed

5 files changed

+103
-3
lines changed

.github/workflows/Deploy.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Weekly builds of the Svelte Language Tools Beta
1+
name: Daily builds of the Svelte Language Tools Beta
22

33
# For testing
44
# on: push
@@ -50,7 +50,10 @@ jobs:
5050
5151
# Have commits been added in the last day?
5252
if [[ $(git log --pretty=format: --name-only --since="1 days ago") ]]; then
53-
npx vsce publish patch --yarn -p $VSCE_TOKEN
53+
# Bump the version
54+
yarn workspace svelte-vscode update:package:beta
55+
# Ship it
56+
npx vsce publish --yarn -p $VSCE_TOKEN
5457
fi
5558
5659
env:

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
"build": "tsc -b",
1212
"test": "CI=true yarn workspaces run test",
1313
"watch": "tsc -b -watch"
14+
},
15+
"dependencies": {
16+
"axios": "0.19.2"
1417
}
1518
}

packages/svelte-vscode/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"vscode:prepublish": "tsc -p ./",
88
"build": "tsc -p ./",
99
"watch": "tsc -w -p ./",
10-
"test": "echo 'NOOP'"
10+
"test": "echo 'NOOP'",
11+
"update:package:beta": "node scripts/bump-beta-version.js"
1112
},
1213
"repository": {
1314
"type": "git",
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// @ts-check
2+
3+
const { writeFileSync, readFileSync } = require("fs")
4+
const { join } = require("path")
5+
6+
const axios = require("axios").default
7+
8+
9+
const getBetaExtension = async () => {
10+
const headers = {
11+
"Content-Type": "application/json",
12+
Accept: "application/json;api-version=5.2-preview.1;excludeUrls=true",
13+
Host: "marketplace.visualstudio.com",
14+
Origin: "https://marketplace.visualstudio.com",
15+
Referer:
16+
// prettier-ignore
17+
`https://marketplace.visualstudio.com/search?term=svelte&category=All%20categories&vsVersion=&sortBy=Relevance`,
18+
"User-Agent":
19+
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15",
20+
"Content-Length": "1082",
21+
Connection: "keep-alive",
22+
"X-TFS-Session": "e16c1b5b-850f-42ee-ab7c-519c79f6e356",
23+
"X-Requested-With": "XMLHttpRequest",
24+
"X-VSS-ReauthenticationAction": "Suppress",
25+
}
26+
27+
const query = name =>
28+
`{"assetTypes":["Microsoft.VisualStudio.Services.Icons.Default","Microsoft.VisualStudio.Services.Icons.Branding","Microsoft.VisualStudio.Services.Icons.Small"],"filters":[{"criteria":[{"filterType":10,"value":"${name}"},{"filterType":12,"value":"37888"}],"direction":2,"pageSize":54,"pageNumber":1,"sortBy":0,"sortOrder":0,"pagingToken":null}],"flags":870}`
29+
30+
const extensionSearchResults = await axios({
31+
url:
32+
"https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery",
33+
method: "POST",
34+
headers: headers,
35+
data: query(`svelte`),
36+
})
37+
38+
if (!extensionSearchResults.data || !extensionSearchResults.data.results) {
39+
throw new Error("Got a bad response from VS marketplace")
40+
}
41+
42+
const extensions = extensionSearchResults.data.results[0].extensions
43+
44+
const officialExtensions = extensions.find(
45+
e => e.publisher.publisherId === "c3bf51ad-baaa-466c-952c-9c3ca9bfabed"
46+
)
47+
return officialExtensions
48+
}
49+
50+
51+
const go = async () => {
52+
const ext = await getBetaExtension()
53+
if (!ext) throw new Error("Could not find the beta extension in the vscode marketplace")
54+
55+
const latestVersion = ext.versions[0].version
56+
const semverMarkers = latestVersion.split(".")
57+
const newVersion = `${semverMarkers[0]}.${semverMarkers[1]}.${Number(semverMarkers[2]) + 1}`
58+
59+
const pkgPath = join(__dirname, "..", "package.json")
60+
const oldPackageJSON = JSON.parse(readFileSync(pkgPath, "utf8"))
61+
oldPackageJSON.version = newVersion
62+
writeFileSync(pkgPath, JSON.stringify(oldPackageJSON))
63+
64+
console.log("Updated to " + newVersion)
65+
}
66+
67+
go()

yarn.lock

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ argparse@^1.0.7:
162162
dependencies:
163163
sprintf-js "~1.0.2"
164164

165+
166+
version "0.19.2"
167+
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
168+
integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==
169+
dependencies:
170+
follow-redirects "1.5.10"
171+
165172
balanced-match@^1.0.0:
166173
version "1.0.0"
167174
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
@@ -291,6 +298,13 @@ [email protected]:
291298
dependencies:
292299
ms "^2.1.1"
293300

301+
debug@=3.1.0:
302+
version "3.1.0"
303+
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
304+
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
305+
dependencies:
306+
ms "2.0.0"
307+
294308
decamelize@^1.2.0:
295309
version "1.2.0"
296310
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
@@ -392,6 +406,13 @@ flat@^4.1.0:
392406
dependencies:
393407
is-buffer "~2.0.3"
394408

409+
410+
version "1.5.10"
411+
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
412+
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
413+
dependencies:
414+
debug "=3.1.0"
415+
395416
fs.realpath@^1.0.0:
396417
version "1.0.0"
397418
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
@@ -676,6 +697,11 @@ mocha@^7.1.0:
676697
yargs-parser "13.1.1"
677698
yargs-unparser "1.6.0"
678699

700+
701+
version "2.0.0"
702+
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
703+
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
704+
679705
680706
version "2.1.1"
681707
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"

0 commit comments

Comments
 (0)