Skip to content

Commit

Permalink
Added publish script for PowerShell SDK (#975)
Browse files Browse the repository at this point in the history
* simple yampl to create pipeline

* Add additional steps into pipeline to publish nuget feed

* Upgrade net framework version

* Revert csproj changes

* Specify msbuild version for old netframework support

* Add arch argument to msbuild installation

* Bump package version

* Use nuspec version directly

* Fix downloadFileAsync

* rm committed minimatch dll

* Move publish steps to job + temp disable it

* Move version to package back. Fix encoding

* Add publish script

* Update tags

* update company metadata

* Update to publish to powershell gallery

---------

Co-authored-by: Konstantin Tyukalov <v-ktyukalov@microsoft.com>
Co-authored-by: Konstantin Tyukalov <52399739+KonstantinTyukalov@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 26, 2023
1 parent 5fb0f50 commit f952803
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 30 deletions.
23 changes: 23 additions & 0 deletions ci/powershell/publish-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
jobs:
- job: Publish
displayName: Publish SDK to PowerShell gallery
pool:
vmImage: windows-2022
steps:
- powershell: |
Install-Module -Name Microsoft.PowerShell.PSResourceGet -Verbose
displayName: Install new publish cmdlets
- powershell: |
$publishOptions = @{
Path = './VstsTaskSdk'
ApiKey = $env:API_KEY
Repository = 'PSGallery'
Verbose = $true
}
Publish-PSResource @publishOptions
displayName: Publish to gallery
workingDirectory: powershell/_build
env:
API_KEY: $(PSGalleryApiKey)
2 changes: 1 addition & 1 deletion powershell/CompiledHelpers/VstsTaskSdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AssemblyName>VstsTaskSdk</AssemblyName>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>FinalPublicKey.snk</AssemblyOriginatorKeyFile>
<DelaySign>true</DelaySign>
<DelaySign>true</DelaySign>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
Expand Down
Binary file modified powershell/VstsTaskSdk/VstsTaskSdk.psd1
Binary file not shown.
7 changes: 4 additions & 3 deletions powershell/make-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ const downloadFileAsync = async function (url, fileName) {
});


const { fileName } = await downloader.download(); // Downloader.download() resolves with some useful properties.
fs.writeFileSync(marker, '');
return fileName;
const { filePath } = await downloader.download(); // Downloader.download() resolves with some useful properties.
fs.writeFileSync(marker, '');

return filePath;
};

exports.downloadFileAsync = downloadFileAsync;
Expand Down
12 changes: 6 additions & 6 deletions powershell/make.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ target.clean = function () {
// TODO: target.buildCompiledHelper
// This will only build the C# compiled helper csproj.

target.build = function() {
target.build = function () {
target.clean();
target.loc();

Expand All @@ -33,7 +33,7 @@ target.build = function() {

// stamp the version number from the package.json onto the PowerShell module definition
var targetPsd1 = path.join(buildPath, 'VstsTaskSdk', 'VstsTaskSdk.psd1');
var psd1Contents = fs.readFileSync(targetPsd1, 'ucs2'); // UCS-2 is a subset of UTF-16. UTF-16 is not supported by node.
var psd1Contents = fs.readFileSync(targetPsd1, 'utf-8'); // UCS-2 is a subset of UTF-16. UTF-16 is not supported by node.
var token = "ModuleVersion = '0.1'";
var tokenStart = psd1Contents.indexOf(token);
if (tokenStart < 0) {
Expand All @@ -57,10 +57,10 @@ target.build = function() {
psd1Contents = psd1Contents.substring(0, tokenStart) + commitHash + psd1Contents.substring(tokenStart + token.length);

// save the updated psd1 file
fs.writeFileSync(targetPsd1, psd1Contents, 'ucs2');
fs.writeFileSync(targetPsd1, psd1Contents, 'utf-8');
}

target.test = function() {
target.test = function () {
util.ensureTool('tsc', '--version', 'Version 1.8.7');
util.ensureTool('mocha', '--version', '5.2.0');
target.build();
Expand All @@ -72,12 +72,12 @@ target.test = function() {
util.run('mocha "' + path.join(testPath, 'L0', '_suite.js') + '"');
}

target.loc = function() {
target.loc = function () {
// build the content for the en-US resjson file
var lib = require('./VstsTaskSdk/lib.json');
var strPath = path.join('VstsTaskSdk', 'Strings', 'resources.resjson', 'en-US');
util.mkdir('-p', strPath);
var strings = { };
var strings = {};
if (lib.messages) {
for (var key in lib.messages) {
var messageKey = 'loc.messages.' + key;
Expand Down
4 changes: 1 addition & 3 deletions powershell/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 2 additions & 17 deletions powershell/package.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
{
"name": "vsts-task-sdk",
"version": "0.16.0",
"description": "VSTS Task SDK",
"version": "0.17.0",
"private": true,
"scripts": {
"build": "node make.js build",
"test": "node make.js test"
},
"repository": {
"type": "git",
"url": "https://github.com/Microsoft/azure-pipelines-task-lib"
},
"keywords": [
"vsts",
"xplat",
"agent",
"build"
],
"author": "Microsoft",
"license": "MIT",
"bugs": {
"url": "https://github.com/Microsoft/azure-pipelines-task-lib/issues"
},
"homepage": "https://github.com/Microsoft/azure-pipelines-task-lib#readme",
"devDependencies": {
"adm-zip": "^0.5.9",
"deasync": "^0.1.28",
Expand Down
21 changes: 21 additions & 0 deletions powershell/publish.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
param(
[Parameter(Mandatory = $true)]
[string]$ApiKey
)

# Install newest version of powershell management api
Install-Module -Name Microsoft.PowerShell.PSResourceGet

$makePath = Join-Path $PSScriptRoot 'make.js'
& node $makePath build

$buildPath = Join-Path $PSScriptRoot '_build'
$moduleBuildPath = Join-Path $buildPath "VstsTaskSdk"

$publishOptions = @{
Path = $moduleBuildPath
ApiKey = $ApiKey
Repository = 'PSGallery'
Verbose = $true
}
Publish-PSResource @publishOptions

0 comments on commit f952803

Please sign in to comment.