Skip to content

Commit

Permalink
Use single extension with prerelease flag via pipeline parameter (#741)…
Browse files Browse the repository at this point in the history
… (#757)

* Use single extension with prerelease flag via pipelien parameter

* cleanup

* Use Release-It to handle incrementing the version in official builds

* Remove Version variable, set values from NPM package after release-it
  • Loading branch information
tehcrashxor authored Oct 30, 2023
1 parent 91f7da7 commit 0dedc48
Show file tree
Hide file tree
Showing 5 changed files with 3,809 additions and 433 deletions.
42 changes: 21 additions & 21 deletions .azure-pipelines/OfficialBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#
# Official build to produce versioned and signed VSIX

parameters:
- name: isPreRelease
displayName: 'Build as pre-release extension'
type: boolean
default: true

variables:
# https://aka.ms/gdn-injection
GDN_CODESIGN_TARGETDIRECTORY: "$(Build.SourcesDirectory)\\package"
Expand All @@ -15,7 +21,6 @@ variables:
# set the following in the pipeline's web UI editor:
# GITHUB_TOKEN # GitHub PAT with scopes: repo; must have SSO enabled for GH org 'microsoft' for corp user
# AZ_DevOps_Read_PAT # PAT to read from AzDO feed in msazure
# VSIX_VERSION # VSIX package/release version; must be manually managed for now!

# trigger:
# - release/*
Expand All @@ -27,12 +32,6 @@ pool:
vmImage: 'windows-latest'

steps:
- script: echo "##vso[build.updatebuildnumber]$(VSIX_VERSION)
displayName: Set Job version

- script: mkdir package && echo $(VSIX_VERSION),$(Build.SourceVersion) > package/version.csv
displayName: Capture build version in package/version.csv

- task: NodeTool@0
displayName: 'Use nodejs 18.x'
inputs:
Expand All @@ -51,28 +50,29 @@ steps:
customCommand: run set-git-authn -- --repoToken $(GITHUB_TOKEN)

- task: Npm@1
displayName: 'set version via npm'
displayName: 'increment version'
inputs:
command: custom
customCommand: run increment-version-npm

# - task: Npm@1
# displayName: 'increment version'
# inputs:
# command: custom
# customCommand: run increment-version
customCommand: run increment-version

- task: Npm@1
displayName: 'Official Build and Package VSIX'
- task: PowerShell@2
displayName: 'Record build version'
inputs:
command: custom
customCommand: run dist -- --feedPAT $(AZ_DevOps_Read_PAT) --isOfficialBuild true
targetType: 'inline'
script: |
$version = npm pkg get version
# Set the ADO Build number
Write-Host "##vso[build.updatebuildnumber]$version"
mkdir package
echo $version,$(Build.SourceVersion) > package/version.csv
- task: Npm@1
displayName: 'Preview Build and Package VSIX'
displayName: 'Build and Package VSIX'
inputs:
command: custom
customCommand: run dist -- --feedPAT $(AZ_DevOps_Read_PAT) --isPreviewBuild true
customCommand: run dist -- --feedPAT $(AZ_DevOps_Read_PAT) --isOfficialBuild true --isPreviewBuild ${{ parameter.isPreRelease }}

# https://microsoft.sharepoint.com/teams/prss/esrp/info/ESRP%20Onboarding%20Wiki/Generating%20Signing%20JSON.aspx
# https://microsoft.sharepoint.com/teams/prss/esrp/info/ESRP%20Onboarding%20Wiki/Selecting%20CodeSign%20Certificates.aspx
Expand Down
34 changes: 34 additions & 0 deletions .release-it.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# https://github.com/release-it/release-it/blob/master/config/release-it.json

hooks: {}

# https://github.com/release-it/release-it/blob/master/docs/git.md
git:
addUntrackedFiles: false
commit: false
push: false # ADO build pushes the tag when build is complete, and fails if it's already there
# need to specify pushRepo, since AzDO insists on disconnected refs, breaking upstream
requireUpstream: false
pushArgs: [ '--tags' ]
pushRepo: https://github.com/microsoft/powerplatform-vscode

# requireBranch: main
requireCommits: false
requireCleanWorkingDir: false
tag: true
tagArgs: [ '--force' ]
tagAnnotation: |
build ${version}:
${changelog}
tagName: 'v${version}'
getLatestTagFromAllRefs: true

#https://github.com/release-it/release-it/blob/master/docs/npm.md
npm:
ignoreVersion: true
publish: false

# https://github.com/release-it/release-it/blob/master/docs/github-releases.md
github:
draft: true
release: false
42 changes: 1 addition & 41 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function clean() {
}

function setTelemetryTarget() {
const telemetryConfigurationSource = isOfficialBuild && !isPreviewBuild
const telemetryConfigurationSource = isOfficialBuild
? 'src/common/telemetry/telemetryConfigurationProd.ts'
: 'src/common/telemetry/telemetryConfigurationDev.ts';

Expand Down Expand Up @@ -246,45 +246,11 @@ const testDesktopIntegration = gulp.series(compileIntegrationTests, async () =>
const testDesktopInt = gulp.series(testDesktopIntegration);

async function packageVsix() {
const standardHeader = '# Power Platform Extension';
const previewHeader = '# Power Platform Tools [PREVIEW]\n\n## This extension is used for internal testing against targets such as vscode.dev which require Marketplace published extensions, and is not supported.';
const standardPackageOptions = {
name: 'powerplatform-vscode',
displayName: 'Power Platform Tools',
description: 'Tooling to create Power Platform solutions & packages, manage Power Platform environments and edit Power Apps Portals',
readmeHeader: standardHeader,
readmeReplacementTarget: previewHeader,
};
const previewPackageOptions = {
name: 'powerplatform-vscode-preview',
displayName: 'Power Platform Tools [PREVIEW]',
description: 'Unsupported extension for testing Power Platform Tools',
readmeHeader: previewHeader,
readmeReplacementTarget: standardHeader,
};

const setPackageInfo = async function(pkgOptions) {
await npm(['pkg', 'set', `name=${pkgOptions.name}`]);
await npm(['pkg', 'set', `displayName="${pkgOptions.displayName}"`]);
await npm(['pkg', 'set', `description="${pkgOptions.description}"`]);

gulp.src('README.md')
.pipe(replace(pkgOptions.readmeReplacementTarget, pkgOptions.readmeHeader))
.pipe(gulp.dest('./'));
}

await setPackageInfo(isPreviewBuild ? previewPackageOptions : standardPackageOptions);

fs.ensureDirSync(packagedir);
await vsce.createVSIX({
packagePath: packagedir,
preRelease: isPreviewBuild,
});

// Reset to non-preview settings to prevent polluting git diffs
if (isPreviewBuild) {
await setPackageInfo(standardPackageOptions);
}
}

async function git(args) {
Expand All @@ -293,12 +259,6 @@ async function git(args) {
return { stdout: stdout, stderr: stderr };
}

async function npm(args) {
args.unshift('npm');
const {stdout, stderr } = await exec(args.join(' '));
return {stdout: stdout, stderr: stderr};
}

async function npx(args) {
args.unshift('npx');
const {stdout, stderr } = await exec(args.join(' '));
Expand Down
Loading

0 comments on commit 0dedc48

Please sign in to comment.