Skip to content

Commit

Permalink
Merge pull request #529 from jvalue/ci-publish-safeguard
Browse files Browse the repository at this point in the history
CI Publish Safeguard
  • Loading branch information
georg-schwarz authored Feb 21, 2024
2 parents 4118b4b + bf38bac commit 0e505f2
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 15 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ jobs:

- name: Test
run: npx nx affected --target=test --parallel=3 --base=remotes/origin/main --head=HEAD --ci

# Ensure this works for future release publishing
- name: Publish Dry-Run
run: npx nx affected --target=pre-publish --parallel=3 --base=remotes/origin/main --head=HEAD --ci

# Ensure this works for future release publishing
- name: Pack VSCode Extension
run: npx nx run vs-code-extension:pack:prod
5 changes: 3 additions & 2 deletions apps/interpreter/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"commands": [
"node tools/scripts/interpreter/prepend-shebang.mjs interpreter main.js",
"node tools/scripts/add-package-json-version.mjs interpreter",
"node tools/scripts/interpreter/rewrite-version-mainjs.mjs interpreter"
"node tools/scripts/interpreter/rewrite-version-mainjs.mjs interpreter",
"node tools/scripts/publish.mjs interpreter false" // dry-run
],
"parallel": false
}
Expand All @@ -57,7 +58,7 @@
"executor": "nx:run-commands",
"dependsOn": ["pre-publish"],
"options": {
"commands": ["node tools/scripts/publish.mjs interpreter"],
"commands": ["node tools/scripts/publish.mjs interpreter true"],
"parallel": false
}
},
Expand Down
14 changes: 12 additions & 2 deletions apps/language-server-web-worker/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,25 @@
"jestConfig": "apps/language-server-web-worker/jest.config.ts"
}
},
"publish": {
"pre-publish": {
"executor": "nx:run-commands",
"dependsOn": ["build"],
"options": {
"commands": [
// Manually delete all dependencies in package.json because the "externalDependencies": "none" setting in "build" above seems to have no effect on the generated package.json
"node tools/scripts/delete-dependencies.mjs language-server-web-worker",
"node tools/scripts/add-package-json-version.mjs language-server-web-worker",
"node tools/scripts/publish.mjs language-server-web-worker"
"node tools/scripts/publish.mjs language-server-web-worker false" // dry-run
],
"parallel": false
}
},
"publish": {
"executor": "nx:run-commands",
"dependsOn": ["pre-publish"],
"options": {
"commands": [
"node tools/scripts/publish.mjs language-server-web-worker true"
],
"parallel": false
}
Expand Down
5 changes: 3 additions & 2 deletions libs/interpreter-lib/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"options": {
"commands": [
"node tools/scripts/relax-peer-dependency-versions.mjs interpreter-lib",
"node tools/scripts/add-package-json-version.mjs interpreter-lib"
"node tools/scripts/add-package-json-version.mjs interpreter-lib",
"node tools/scripts/publish.mjs interpreter-lib false" // dry-run
],
"parallel": false
}
Expand All @@ -41,7 +42,7 @@
"executor": "nx:run-commands",
"dependsOn": ["pre-publish"],
"options": {
"commands": ["node tools/scripts/publish.mjs interpreter-lib"],
"commands": ["node tools/scripts/publish.mjs interpreter-lib true"],
"parallel": false
}
},
Expand Down
5 changes: 3 additions & 2 deletions libs/language-server/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"options": {
"commands": [
"node tools/scripts/relax-peer-dependency-versions.mjs language-server",
"node tools/scripts/add-package-json-version.mjs language-server"
"node tools/scripts/add-package-json-version.mjs language-server",
"node tools/scripts/publish.mjs language-server false"
],
"parallel": false
}
Expand All @@ -58,7 +59,7 @@
"executor": "nx:run-commands",
"dependsOn": ["pre-publish"],
"options": {
"commands": ["node tools/scripts/publish.mjs language-server"],
"commands": ["node tools/scripts/publish.mjs language-server true"],
"parallel": false
}
},
Expand Down
5 changes: 3 additions & 2 deletions libs/monaco-editor/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"node tools/scripts/relax-peer-dependency-versions.mjs monaco-editor",
"node tools/scripts/monaco-editor/delete-vscode-peer-dependency.mjs monaco-editor",
"node tools/scripts/monaco-editor/relax-react-version.mjs monaco-editor",
"node tools/scripts/add-package-json-version.mjs monaco-editor"
"node tools/scripts/add-package-json-version.mjs monaco-editor",
"node tools/scripts/publish.mjs monaco-editor false" // dry-run
],
"parallel": false
}
Expand All @@ -60,7 +61,7 @@
"executor": "nx:run-commands",
"dependsOn": ["pre-publish"],
"options": {
"commands": ["node tools/scripts/publish.mjs monaco-editor"],
"commands": ["node tools/scripts/publish.mjs monaco-editor true"],
"parallel": false
}
},
Expand Down
12 changes: 7 additions & 5 deletions tools/scripts/publish.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
//
// SPDX-License-Identifier: AGPL-3.0-only

import {execSync} from 'child_process';
import {getOutputPath} from "./shared-util.mjs";
import { execSync } from 'child_process';
import { getOutputPath } from './shared-util.mjs';

// Executing this script: node path/to/publish.mjs {projectName}
const [, , projectName] = process.argv;
// Executing this script: node path/to/publish.mjs {projectName} {no-dry-run}
const [, , projectName, isNoDryRun] = process.argv;

const isDryRun = isNoDryRun !== 'true';

const outputPath = getOutputPath(projectName);

execSync(`npm publish ${outputPath}`);
execSync(`npm publish ${outputPath} ${!isDryRun ? '' : '--dry-run'}`);

0 comments on commit 0e505f2

Please sign in to comment.