Skip to content
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
78 changes: 15 additions & 63 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resources:
ref: refs/tags/release

extends:
template: v1/1ES.Official.PipelineTemplate.yml@1esPipelines
template: v1/1ES.Unofficial.PipelineTemplate.yml@1esPipelines
parameters:
sdl:
sourceAnalysisPool: 1es-oss-windows-2022-x64
Expand All @@ -24,97 +24,49 @@ extends:
pool:
name: 1es-oss-ubuntu-22.04-x64
os: Linux
strategy:
matrix:
node_20_x:
node_version: 20.x
steps:
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
versionSpec: 20.x
displayName: 'Install Node.js'
- script: |
npm i
- script: npm ci
displayName: 'Install dependencies and build'
- script: |
npm test
- script: npm test
displayName: 'Test'
- script: |
npm run lint
- script: npm run lint
displayName: 'Lint'

- job: macOS
pool:
name: Azure Pipelines
vmImage: 'macOS-latest'
vmImage: 'macOS-14'
os: macOS
strategy:
matrix:
node_20_x:
node_version: 20.x
steps:
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
versionSpec: 20.x
displayName: 'Install Node.js'
- script: |
python3 -m pip install setuptools
- script: python3 -m pip install setuptools
displayName: Install setuptools (macOS)
- script: |
npm i
- script: npm ci
displayName: 'Install dependencies and build'
- script: |
npm test
- script: npm test
displayName: 'Test'
- script: |
npm run lint
- script: npm run lint
displayName: 'Lint'

- job: Windows
pool:
name: 1es-oss-windows-2022-x64
os: Windows
strategy:
matrix:
node_20_x:
node_version: 20.x
steps:
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
versionSpec: 20.x
displayName: 'Install Node.js'
- script: |
npm i
- script: npm ci
displayName: 'Install dependencies and build'
- script: |
npm test
- script: npm test
displayName: 'Test'
- script: |
npm run lint
- script: npm run lint
displayName: 'Lint'

- stage: Release
dependsOn: Build
jobs:
- job: Release
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
# Output artifact to produce SBOM and to run SDL checks
templateContext:
outputs:
- output: pipelineArtifact
targetPath: $(Build.SourcesDirectory)
artifactName: drop
pool:
name: 1es-oss-ubuntu-22.04-x64
os: Linux
steps:
- task: NodeTool@0
inputs:
versionSpec: '20.x'
displayName: 'Install Node.js'
- script: |
npm i
displayName: 'Install dependencies and build'
- script: |
NPM_AUTH_TOKEN="$(NPM_AUTH_TOKEN)" node ./scripts/publish.js
displayName: 'Publish to npm'
61 changes: 61 additions & 0 deletions publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: $(Date:yyyyMMdd)$(Rev:.r)

trigger:
batch: true
branches:
include:
- main
pr: none

resources:
repositories:
- repository: templates
type: github
name: microsoft/vscode-engineering
ref: main
endpoint: Monaco

parameters:
- name: publishPackage
displayName: 🚀 Publish node-pty
type: boolean
default: false
- name: releaseQuality
displayName: Quality
type: string
default: beta
values:
- beta
- stable

variables:
- name: releaseQuality
value: ${{ parameters.releaseQuality }}

extends:
template: azure-pipelines/npm-package/pipeline.yml@templates
parameters:
npmPackages:
- name: node-pty

buildSteps:
- script: npm ci
displayName: 'Install dependencies and build'
# The following script leaves the version unchanged for
# stable releases, but increments the version for beta releases.
- script: node scripts/increment-version.js
displayName: 'Increment version'

testSteps:
- script: npm ci
displayName: 'Install dependencies and build'
- script: npm test
displayName: 'Test'
- script: npm run lint
displayName: 'Lint'

publishPackage: ${{ parameters.publishPackage }}
${{ if eq(variables['releaseQuality'], 'stable') }}:
tag: latest
${{ else }}:
tag: beta
17 changes: 3 additions & 14 deletions scripts/publish.js → scripts/increment-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,19 @@ const fs = require('fs');
const path = require('path');
const packageJson = require('../package.json');

// Setup auth
fs.writeFileSync(`${process.env['HOME']}/.npmrc`, `//registry.npmjs.org/:_authToken=${process.env['NPM_AUTH_TOKEN']}`);

// Determine if this is a stable or beta release
const publishedVersions = getPublishedVersions();
const isStableRelease = publishedVersions.indexOf(packageJson.version) === -1;
const isStableRelease = !publishedVersions.includes(packageJson.version);

// Get the next version
let nextVersion = isStableRelease ? packageJson.version : getNextBetaVersion();
console.log(`Publishing version: ${nextVersion}`);
const nextVersion = isStableRelease ? packageJson.version : getNextBetaVersion();
console.log(`Setting version to ${nextVersion}`);

// Set the version in package.json
const packageJsonFile = path.resolve(__dirname, '..', 'package.json');
packageJson.version = nextVersion;
fs.writeFileSync(packageJsonFile, JSON.stringify(packageJson, null, 2));

// Publish
const args = ['publish'];
if (!isStableRelease) {
args.push('--tag', 'beta');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the pipeline will have to support this tag functionality as well. Leaving the PR unmerged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we automatically create a GH release and tag.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an npm release tag, not a gh/git one. It's critical that this is published to npm under the beta tag.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added tag parameters to the YAML that should tell ESRP to publish with the correct tag.

}
const result = cp.spawn('npm', args, { stdio: 'inherit' });
result.on('exit', code => process.exit(code));

function getNextBetaVersion() {
if (!/^[0-9]+\.[0-9]+\.[0-9]+$/.exec(packageJson.version)) {
console.error('The package.json version must be of the form x.y.z');
Expand Down