Skip to content

Commit

Permalink
releases work, disable pre-release for now
Browse files Browse the repository at this point in the history
  • Loading branch information
acao committed Apr 11, 2022
1 parent 7ac4987 commit 11d106a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"prepublishOnly": "./scripts/prepublish.sh",
"pretty": "node scripts/pretty.js",
"pretty-check": "node scripts/pretty.js --check",
"release": "yarn build && yarn build-bundles && yarn changeset publish && wsrun release",
"release": "yarn build && yarn build-bundles && yarn changeset publish",
"release:canary": "(node scripts/canary-release.js && yarn build && yarn build-bundles && yarn changeset publish --tag canary) || echo Skipping Canary...",
"repo:lint": "manypkg check",
"repo:fix": "manypkg fix",
Expand Down
4 changes: 2 additions & 2 deletions packages/vscode-graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-graphql",
"version": "0.4.3",
"version": "0.4.1",
"preview": true,
"private": true,
"license": "MIT",
Expand Down Expand Up @@ -220,7 +220,7 @@
"env:source": "export $(cat .envrc | xargs)",
"vsce:publish": "vsce publish --yarn --pat \"$PAT_TOKEN\"",
"open-vsx:publish": "ovsx publish --pat \"$OPEN_VSX_ACCESS_TOKEN\"",
"release": "npm run vsce:publish && npm run open-vsx:publish"
"postpublish": "npm run vsce:publish && npm run open-vsx:publish"
},
"devDependencies": {
"@types/capitalize": "2.0.0",
Expand Down
49 changes: 35 additions & 14 deletions scripts/canary-release.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */
const semver = require('semver');
const { execa } = import('execa');
const cp = require('child_process');
const { basename } = require('path');

Expand All @@ -19,22 +20,29 @@ function getNewVersion(version, type) {
return semver.inc(version, `pre${type}`, true, 'canary-' + gitHash);
}

function getRelevantChangesets(baseBranch) {
const comparePoint = cp
.spawnSync('git', ['merge-base', `origin/${baseBranch}`, 'HEAD'])
.stdout.toString()
.trim();
const listModifiedFiles = cp
.spawnSync('git', ['diff', '--name-only', comparePoint])
.stdout.toString()
.trim()
.split('\n');
const execOpts = { stderr: 'inherit', stdout: 'inherit' };

const items = listModifiedFiles
.filter(f => f.startsWith('.changeset'))
.map(f => basename(f, '.md'));
const git = async (...commands) => execa('git', commands, execOpts);

return items;
async function preReleaseVSCode(version) {
try {
await execa(
'yarn',
['workspace', `vscode-graphql`, 'run', 'release', '--pre'],
execOpts,
);
} catch (err) {
console.error('vscode-graphql pre-release failed on publish:', err);
process.exit(1);
}
try {
await git('add', `packages/vscode-graphql/package.json`);
await git('commit', `-m`, `pre-release \`vscode-graphql@${version}\``);
await git('push');
} catch (err) {
console.error('vscode-graphql pre-release failed on git command:', err);
process.exit(1);
}
}

async function updateVersions() {
Expand All @@ -45,6 +53,9 @@ async function updateVersions() {
const changesets = (await readChangesets(cwd)).filter(change =>
modifiedChangesets.includes(change.id),
);
const isMain = process.env.GITHUB_REF_NAME?.includes('main');

let vscodeRelease = false;

if (changesets.length === 0) {
console.warn(
Expand All @@ -67,6 +78,13 @@ async function updateVersions() {
process.exit(1);
} else {
for (const release of releasePlan.releases) {
if (
release.name.includes('vscode-graphql') &&
release.changesets?.type !== 'none'
) {
// vsce pre-release only accept x.y.z versions
release.newVersion = vscodeRelease = semver.patch(release.oldVersion);
}
if (release.type !== 'none') {
release.newVersion = getNewVersion(release.oldVersion, release.type);
}
Expand All @@ -82,6 +100,9 @@ async function updateVersions() {
false,
true,
);
// if(vscodeRelease) {
// await preReleaseVSCode(vscodeRelease)
// }
}
}
}
Expand Down

0 comments on commit 11d106a

Please sign in to comment.