Skip to content

Commit d7f04ca

Browse files
authored
🚀 pre-release for packaging and publishing (#858)
* pre-release for packaging * Use --yarn from command line * Adapted nightly
1 parent 54b9e56 commit d7f04ca

5 files changed

Lines changed: 105 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ jobs:
206206
207207
- name: Create vsix package
208208
run: |
209-
yarn package --target ${{ matrix.target }}
209+
yarn run package --target ${{ matrix.target }} --yarn
210210
211211
- name: Upload package
212212
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ jobs:
164164
165165
- name: Create vsix package
166166
run: |
167-
yarn package --target ${{ matrix.target }}
167+
yarn run package --target ${{ matrix.target }} --yarn
168168
169169
- name: Upload package
170170
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0

DEVELOPMENT.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,24 @@ Supported `<target>`s are:
5858
> yarn package [--target <target>]
5959
```
6060
61+
## Release versioning
62+
63+
This repository follows the VS Code Marketplace pre-release recommendation:
64+
65+
- **Odd** minor versions (`x.1.z`, `x.3.z`, ...) are pre-releases.
66+
- **Even** minor versions (`x.0.z`, `x.2.z`, ...) are full releases.
67+
68+
To enforce this consistently, both packaging and publishing use `scripts/vsce-release.js`, which:
69+
70+
- checks the current `package.json` version minor value.
71+
- automatically adds `--pre-release` to `vsce package` for odd minor versions.
72+
73+
Use the following commands:
74+
75+
```sh
76+
> yarn run package [--target <target>]
77+
```
78+
6179
## Developing
6280
6381
1. If you are developing and debugging this extension, we recommend you run the following command

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@
403403
"lint": "eslint .",
404404
"test": "jest --reporters=default --reporters=./node_modules/jest-html-reporter",
405405
"all": "yarn && yarn download-tools && yarn test",
406-
"package": "vsce package --yarn",
406+
"package": "node ./scripts/vsce-release.js --yarn",
407407
"tpip:report": "tsx scripts/tpip-reporter --header docs/tpip-header.md docs/third-party-licenses.json TPIP.md",
408408
"lint:md": "markdownlint **/*.md -c ./.github/markdownlint.jsonc -i ./node_modules -i ./dist -i ./coverage -i ./tools",
409409
"check:links": "tsx scripts/check-links.ts -i ./node_modules/** -i ./.github/** -c ./.github/markdown-link-check.jsonc",

scripts/vsce-release.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Copyright 2026 Arm Limited
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// generated with AI
20+
21+
/**
22+
* CLI usage:
23+
* - Preferred: npm run package
24+
* - With extra vsce flags: npm run package -- <vsce-args>
25+
* - Direct invocation: node ./scripts/vsce-release.js [package] [vsce-args]
26+
*
27+
* Notes:
28+
* - This helper only supports the `package` command.
29+
* - `--pre-release` is appended automatically for odd minor versions.
30+
*/
31+
32+
import fs from 'node:fs';
33+
import path from 'node:path';
34+
import { spawnSync } from 'node:child_process';
35+
import { fileURLToPath } from 'node:url';
36+
37+
const __filename = fileURLToPath(import.meta.url);
38+
const __dirname = path.dirname(__filename);
39+
const rootPath = path.resolve(__dirname, '..');
40+
const packageJsonPath = path.join(rootPath, 'package.json');
41+
42+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
43+
const version = packageJson.version;
44+
45+
const match = /^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(version);
46+
if (!match) {
47+
console.error(`Unsupported package.json version format: ${version}`);
48+
process.exit(1);
49+
}
50+
51+
const minor = Number(match[2]);
52+
const isPreReleaseChannel = minor % 2 === 1;
53+
54+
const allowedCommands = new Set(['package']);
55+
const firstArg = process.argv[2];
56+
const command = firstArg && !firstArg.startsWith('-') ? firstArg : 'package';
57+
58+
if (!allowedCommands.has(command)) {
59+
console.error(`Unsupported vsce command: ${command}`);
60+
console.error('Supported commands: package');
61+
process.exit(1);
62+
}
63+
64+
const passthroughArgs = command === firstArg ? process.argv.slice(3) : process.argv.slice(2);
65+
const args = [command, ...passthroughArgs];
66+
67+
if (isPreReleaseChannel) {
68+
args.push('--pre-release');
69+
}
70+
71+
console.log(`Running: vsce ${args.join(' ')}`);
72+
73+
const result = spawnSync('vsce', args, {
74+
cwd: rootPath,
75+
stdio: 'inherit',
76+
shell: process.platform === 'win32'
77+
});
78+
79+
if (result.error) {
80+
console.error(result.error.message);
81+
process.exit(1);
82+
}
83+
84+
process.exit(result.status ?? 1);

0 commit comments

Comments
 (0)