Skip to content

Deploy nightly improvements #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/Deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Weekly builds of the Svelte Language Tools Beta
name: Daily builds of the Svelte Language Tools Beta

# For testing
# on: push
Expand Down Expand Up @@ -47,8 +47,14 @@ jobs:

# Just a hard constraint from azure
echo "Once a year this expires, tell Orta to access https://dev.azure.com/ortatherox0608/_usersSettings/tokens to get a new one"

npx vsce publish patch --yarn -p $VSCE_TOKEN

# Have commits been added in the last day?
if [[ $(git log --pretty=format: --name-only --since="1 days ago") ]]; then
# Bump the version
yarn workspace svelte-vscode update:package:beta
# Ship it
npx vsce publish --yarn -p $VSCE_TOKEN
fi

env:
VSCE_TOKEN: ${{ secrets.AZURE_PAN_TOKEN }}
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"build": "tsc -b",
"test": "CI=true yarn workspaces run test",
"watch": "tsc -b -watch"
},
"dependencies": {
"axios": "0.19.2"
}
}
3 changes: 2 additions & 1 deletion packages/svelte-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"vscode:prepublish": "tsc -p ./",
"build": "tsc -p ./",
"watch": "tsc -w -p ./",
"test": "echo 'NOOP'"
"test": "echo 'NOOP'",
"update:package:beta": "node scripts/bump-beta-version.js"
},
"repository": {
"type": "git",
Expand Down
67 changes: 67 additions & 0 deletions packages/svelte-vscode/scripts/bump-beta-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// @ts-check

const { writeFileSync, readFileSync } = require("fs")
const { join } = require("path")

const axios = require("axios").default


const getBetaExtension = async () => {
const headers = {
"Content-Type": "application/json",
Accept: "application/json;api-version=5.2-preview.1;excludeUrls=true",
Host: "marketplace.visualstudio.com",
Origin: "https://marketplace.visualstudio.com",
Referer:
// prettier-ignore
`https://marketplace.visualstudio.com/search?term=svelte&category=All%20categories&vsVersion=&sortBy=Relevance`,
"User-Agent":
"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",
"Content-Length": "1082",
Connection: "keep-alive",
"X-TFS-Session": "e16c1b5b-850f-42ee-ab7c-519c79f6e356",
"X-Requested-With": "XMLHttpRequest",
"X-VSS-ReauthenticationAction": "Suppress",
}

const query = name =>
`{"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}`

const extensionSearchResults = await axios({
url:
"https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery",
method: "POST",
headers: headers,
data: query(`svelte`),
})

if (!extensionSearchResults.data || !extensionSearchResults.data.results) {
throw new Error("Got a bad response from VS marketplace")
}

const extensions = extensionSearchResults.data.results[0].extensions

const officialExtensions = extensions.find(
e => e.publisher.publisherId === "c3bf51ad-baaa-466c-952c-9c3ca9bfabed"
)
return officialExtensions
}


const go = async () => {
const ext = await getBetaExtension()
if (!ext) throw new Error("Could not find the beta extension in the vscode marketplace")

const latestVersion = ext.versions[0].version
const semverMarkers = latestVersion.split(".")
const newVersion = `${semverMarkers[0]}.${semverMarkers[1]}.${Number(semverMarkers[2]) + 1}`

const pkgPath = join(__dirname, "..", "package.json")
const oldPackageJSON = JSON.parse(readFileSync(pkgPath, "utf8"))
oldPackageJSON.version = newVersion
writeFileSync(pkgPath, JSON.stringify(oldPackageJSON))

console.log("Updated to " + newVersion)
}

go()
26 changes: 26 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ argparse@^1.0.7:
dependencies:
sprintf-js "~1.0.2"

[email protected]:
version "0.19.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==
dependencies:
follow-redirects "1.5.10"

balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
Expand Down Expand Up @@ -291,6 +298,13 @@ [email protected]:
dependencies:
ms "^2.1.1"

debug@=3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
dependencies:
ms "2.0.0"

decamelize@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
Expand Down Expand Up @@ -392,6 +406,13 @@ flat@^4.1.0:
dependencies:
is-buffer "~2.0.3"

[email protected]:
version "1.5.10"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
dependencies:
debug "=3.1.0"

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
Expand Down Expand Up @@ -676,6 +697,11 @@ mocha@^7.1.0:
yargs-parser "13.1.1"
yargs-unparser "1.6.0"

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=

[email protected]:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
Expand Down