Skip to content

Commit 019deea

Browse files
committed
Add --pre-release automatically for odd minor versions
1 parent 8099915 commit 019deea

3 files changed

Lines changed: 46 additions & 52 deletions

File tree

.devcontainer/ubuntu-24.04/.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
@arm-debug:registry=https://npm.pkg.github.com
1+
@open-cmsis-pack:registry=https://npm.pkg.github.com
22
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}

DEVELOPMENT.md

Lines changed: 22 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,20 @@ In short, run this command from the extracted directory on the Arm network:
3333
## Running the extension in development
3434

3535
1. To download the tools, you must have a `GITHUB_TOKEN` environment variable containing a
36-
personal access token. This must have the `repo` scope and SSO enabled for the Arm-Debug
37-
organization.
36+
personal access token.
3837

39-
2. In order to install dependencies, you must have npm configured to access the Arm-Debug registry
40-
for packages that are scoped with `@arm-debug`. Edit your global .npmrc file, and add the
38+
2. In order to install dependencies, Edit your global .npmrc file, and add the
4139
following to it:
4240

4341
```txt
44-
@arm-debug:registry=https://npm.pkg.github.com
42+
@open-cmsis-pack:registry=https://npm.pkg.github.com
4543
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
4644
```
4745
4846
This assumes a `GITHUB_TOKEN` environment variable is exported in your environment. This needs
4947
to be a GitHub personal access token with the `read:packages` scope set on it.
5048
51-
3. Install NPM dependencies, Core Tools and build the TypeScript
49+
3. Install NPM dependencies and build the TypeScript
5250
5351
```sh
5452
npm install
@@ -198,59 +196,32 @@ Before running a release, check the following:
198196
199197
4. [Release Assessment](https://armh.sharepoint.com/sites/pwa/PJ1000480/SitePages/Assessments.aspx) for `CMSIS Solution Extension` is approved.
200198
201-
### Release workflow
199+
## Release versioning
202200
203-
Use GitHub Actions workflow dispatch to trigger a release:
201+
This repository follows the VS Code Marketplace pre-release recommendation:
204202
205-
1. Navigate to <https://github.com/Arm-Debug/vscode-cmsis-csolution/actions/workflows/ci.yml>,
206-
then click "Run workflow"
207-
2. Select the main branch
208-
3. Select type of new version, e.g. 'Minor'
209-
4. Select "Skip public publishing jobs' if the version should be created on GitHub but NOT being
210-
published to Marketplace
211-
5. Click "Run workflow"
203+
- **Odd** minor versions (`x.1.z`, `x.3.z`, ...) are pre-releases.
204+
- **Even** minor versions (`x.0.z`, `x.2.z`, ...) are full releases.
212205
213-
Notes
206+
To enforce this consistently, both packaging and publishing use `scripts/package.ts`, which:
214207
215-
- When 'Pre-release' is selected, the version is either:
216-
- incremented according the latest published pre-release (patch +1), if it is greater than the current version
217-
- incremented according the the current version, newMinorVersion is always an odd number (including 0), e.g. 0,1,3,...
218-
- When 'Major', 'Minor' or 'Patch' is selected, the version will be increased and the new version
219-
number will be committed to package.json. If a second release is triggered, it will also be
220-
increased, regardless of being pushed to marketplace or not.
221-
- 'Major' increments major version
222-
- 'Minor' increments to an even number, e.g. 0,2,4,...
223-
- 'Patch' increments patch version
224-
- see [vscode-actions](https://github.com/Arm-Debug/vscode-actions/blob/main/calculate-new-version/src/bump-version.ts)
208+
- checks the current `package.json` version minor value.
209+
- automatically adds `--pre-release` to `vsce package` for odd minor versions.
225210
226-
Github actions will then
211+
Use the following commands:
227212
228-
- Bump the versions in the package.json files
229-
- Add the new version to the CHANGELOG.md, and move all changes listed under "Unreleased" to the new version.
230-
- Commit and push the version and changelog updates
231-
- Build the VSIX package
232-
- Create a GitHub release with the VSIX package
233-
- Publish the package on [Open VSX](https://open-vsx.org/extension/arm/cmsis-csolution) and [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=Arm.cmsis-csolution)
234-
- Publish the API types to the Arm-Debug GitHub Packages npm registry
235-
- Sync the docs to [ARM-software/vscode-cmsis-csolution](https://github.com/ARM-software/vscode-cmsis-csolution)
236-
237-
After publishing, check that the new version is installable in VSCode and docs for the new version
238-
have been synced to Arm-Software.
239-
240-
### Publishing to VS Code Marketplace
241-
242-
The marketplace access token is controlled by the [DSG-OTG](https://dev.azure.com/DSG-OTG)
243-
organization in Azure. It is available in CI as an Arm-Debug GitHub organization secret. This must
244-
be rotated every 90 days.
245-
246-
See the documentation for publishing extensions:
247-
<https://code.visualstudio.com/api/working-with-extensions/publishing-extension>
213+
```sh
214+
> npm run package [--target <target>]
215+
```
248216
249-
### Publishing Open-VSX
217+
### Release Workflow
250218
251-
The arm namespace Open-VSX is accessible from your [user settings](https://open-vsx.org/user-settings)
252-
when your GitHub account has been linked to the arm namespace. An access token is stored as an
253-
Arm-Debug GitHub organization secret.
219+
1. Ensure the version in `package.json` is up to date.
220+
2. Update the `CHANGELOG` with the latest changes.
221+
3. Open a pull request with these updates and merge it into `main`.
222+
4. Create a new release at: https://github.com/Open-CMSIS-Pack/vscode-cmsis-solution/releases
223+
- This will trigger the `CI.yml` workflow.
224+
- Once the workflow completes successfully, the release artifacts will be generated automatically.
254225
255226
## Debugging in KSC
256227

scripts/package.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,20 @@ import * as path from 'path';
2222
import { glob } from 'glob';
2323
import { fileURLToPath } from 'url';
2424
import { execSync } from 'child_process';
25+
import { parse as parseSemver } from 'semver';
2526

2627
const argv = process.argv.slice(2);
2728

29+
function isOddMinorVersion(version: string): boolean {
30+
const parsedVersion = parseSemver(version);
31+
32+
if (!parsedVersion) {
33+
throw new Error(`Invalid package version: ${version}`);
34+
}
35+
36+
return parsedVersion.minor % 2 === 1;
37+
}
38+
2839
// default target: host OS and architecture
2940
let target = `${os.platform()}-${os.arch()}`;
3041

@@ -38,6 +49,18 @@ if (targetFlag !== -1) {
3849
// copy pre-downloaded node-pty for the target platform
3950
const __filename = fileURLToPath(import.meta.url);
4051
const __dirname = path.dirname(__filename);
52+
const packageJsonPath = path.resolve(__dirname, '..', 'package.json');
53+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) as { version?: string };
54+
const version = packageJson.version;
55+
56+
if (!version) {
57+
throw new Error(`Missing version in ${packageJsonPath}`);
58+
}
59+
60+
if (isOddMinorVersion(version) && !argv.includes('--pre-release')) {
61+
argv.push('--pre-release');
62+
}
63+
4164
const src = path.resolve(__dirname, '..','tools', 'node-pty');
4265
if (fs.existsSync(src)) {
4366
const dst = path.resolve(__dirname, '..', 'node_modules', '@lydell');

0 commit comments

Comments
 (0)