Skip to content

Commit 8890bcd

Browse files
ismayilov-ismayilKonstantin Tyukalovlocalconst
authored
Added publish script for PowerShell SDK (#975)
* 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 <[email protected]> Co-authored-by: Konstantin Tyukalov <[email protected]>
1 parent 5adbfed commit 8890bcd

File tree

8 files changed

+58
-30
lines changed

8 files changed

+58
-30
lines changed

ci/powershell/publish-job.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
jobs:
2+
- job: Publish
3+
displayName: Publish SDK to PowerShell gallery
4+
pool:
5+
vmImage: windows-2022
6+
steps:
7+
- powershell: |
8+
Install-Module -Name Microsoft.PowerShell.PSResourceGet -Verbose
9+
displayName: Install new publish cmdlets
10+
11+
- powershell: |
12+
$publishOptions = @{
13+
Path = './VstsTaskSdk'
14+
ApiKey = $env:API_KEY
15+
Repository = 'PSGallery'
16+
Verbose = $true
17+
}
18+
Publish-PSResource @publishOptions
19+
20+
displayName: Publish to gallery
21+
workingDirectory: powershell/_build
22+
env:
23+
API_KEY: $(PSGalleryApiKey)

powershell/CompiledHelpers/VstsTaskSdk.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<AssemblyName>VstsTaskSdk</AssemblyName>
1212
<SignAssembly>true</SignAssembly>
1313
<AssemblyOriginatorKeyFile>FinalPublicKey.snk</AssemblyOriginatorKeyFile>
14-
<DelaySign>true</DelaySign>
14+
<DelaySign>true</DelaySign>
1515
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1616
<FileAlignment>512</FileAlignment>
1717
</PropertyGroup>
-831 Bytes
Binary file not shown.

powershell/make-util.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,10 @@ const downloadFileAsync = async function (url, fileName) {
145145
});
146146

147147

148-
const { fileName } = await downloader.download(); // Downloader.download() resolves with some useful properties.
149-
fs.writeFileSync(marker, '');
150-
return fileName;
148+
const { filePath } = await downloader.download(); // Downloader.download() resolves with some useful properties.
149+
fs.writeFileSync(marker, '');
150+
151+
return filePath;
151152
};
152153

153154
exports.downloadFileAsync = downloadFileAsync;

powershell/make.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ target.clean = function () {
1616
// TODO: target.buildCompiledHelper
1717
// This will only build the C# compiled helper csproj.
1818

19-
target.build = function() {
19+
target.build = function () {
2020
target.clean();
2121
target.loc();
2222

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

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

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

63-
target.test = function() {
63+
target.test = function () {
6464
util.ensureTool('tsc', '--version', 'Version 1.8.7');
6565
util.ensureTool('mocha', '--version', '5.2.0');
6666
target.build();
@@ -72,12 +72,12 @@ target.test = function() {
7272
util.run('mocha "' + path.join(testPath, 'L0', '_suite.js') + '"');
7373
}
7474

75-
target.loc = function() {
75+
target.loc = function () {
7676
// build the content for the en-US resjson file
7777
var lib = require('./VstsTaskSdk/lib.json');
7878
var strPath = path.join('VstsTaskSdk', 'Strings', 'resources.resjson', 'en-US');
7979
util.mkdir('-p', strPath);
80-
var strings = { };
80+
var strings = {};
8181
if (lib.messages) {
8282
for (var key in lib.messages) {
8383
var messageKey = 'loc.messages.' + key;

powershell/package-lock.json

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

powershell/package.json

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
11
{
2-
"name": "vsts-task-sdk",
3-
"version": "0.16.0",
4-
"description": "VSTS Task SDK",
2+
"version": "0.17.0",
3+
"private": true,
54
"scripts": {
65
"build": "node make.js build",
76
"test": "node make.js test"
87
},
9-
"repository": {
10-
"type": "git",
11-
"url": "https://github.com/Microsoft/azure-pipelines-task-lib"
12-
},
13-
"keywords": [
14-
"vsts",
15-
"xplat",
16-
"agent",
17-
"build"
18-
],
198
"author": "Microsoft",
209
"license": "MIT",
21-
"bugs": {
22-
"url": "https://github.com/Microsoft/azure-pipelines-task-lib/issues"
23-
},
24-
"homepage": "https://github.com/Microsoft/azure-pipelines-task-lib#readme",
2510
"devDependencies": {
2611
"adm-zip": "^0.5.9",
2712
"deasync": "^0.1.28",

powershell/publish.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[string]$ApiKey
4+
)
5+
6+
# Install newest version of powershell management api
7+
Install-Module -Name Microsoft.PowerShell.PSResourceGet
8+
9+
$makePath = Join-Path $PSScriptRoot 'make.js'
10+
& node $makePath build
11+
12+
$buildPath = Join-Path $PSScriptRoot '_build'
13+
$moduleBuildPath = Join-Path $buildPath "VstsTaskSdk"
14+
15+
$publishOptions = @{
16+
Path = $moduleBuildPath
17+
ApiKey = $ApiKey
18+
Repository = 'PSGallery'
19+
Verbose = $true
20+
}
21+
Publish-PSResource @publishOptions

0 commit comments

Comments
 (0)