Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

Commit ae2148d

Browse files
committed
First attempt to automate release process
1 parent 7ba6b2e commit ae2148d

6 files changed

+115
-11
lines changed

.github/workflows/prepare-release.yml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
# schedule:
6+
# - cron: '0 12 * * 6'
7+
# - cron: '0 12 * * 3'
8+
9+
jobs:
10+
deploy:
11+
name: Prepare Release
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Setup Node.js
16+
uses: actions/[email protected]
17+
with:
18+
node-version: 16
19+
20+
- name: Checkout CLI for Microsoft 365 Extension
21+
uses: actions/checkout@v3
22+
with:
23+
path: cli-for-microsoft-365-extension
24+
25+
- name: Checkout CLI for Microsoft 365
26+
uses: actions/checkout@v3
27+
with:
28+
repository: pnp/cli-microsoft365
29+
path: cli-microsoft365
30+
31+
- name: Checkout PnP Script Samples
32+
uses: actions/checkout@v3
33+
with:
34+
repository: pnp/script-samples
35+
path: script-samples
36+
37+
- name: Run create script samples script
38+
run: .\cli-for-microsoft-365-extension\scripts\createScriptSampleDefenition.ps1 -scriptSampleFolderPath ".\script-samples" -cliScriptSampleFolderPath ".\cli-microsoft365\docs\docs\sample-scripts" -workingDirectory ".\cli-for-microsoft-365-extension"
39+
shell: pwsh
40+
continue-on-error: false
41+
42+
- name: Run create snippets script
43+
run: .\cli-for-microsoft-365-extension\scripts\createSnippetDefenition.ps1 -cliDocsFolderPath ".\cli-microsoft365\docs" -workingDirectory ".\cli-for-microsoft-365-extension"
44+
shell: pwsh
45+
continue-on-error: false
46+
47+
- name: Run update package version script
48+
run: .\cli-for-microsoft-365-extension\scripts\updatePackageVersion.ps1 -currentWorkspace ".\cli-for-microsoft-365-extension" -workingDirectory ".\cli-for-microsoft-365-extension"
49+
shell: pwsh
50+
continue-on-error: false
51+
52+
- name: Install dependencies
53+
run: npm run install:all
54+
working-directory: cli-for-microsoft-365-extension
55+
56+
- name: Build
57+
run: npm run vscode:prepublish
58+
working-directory: cli-for-microsoft-365-extension
59+
60+
- name: Create Pull Request
61+
uses: peter-evans/create-pull-request@v5
62+
with:
63+
path: cli-for-microsoft-365-extension
64+
commit-message: prepare release
65+
branch: prepare-release
66+
title: Prepare Release
67+
body: Prepare Release
68+
...

.github/workflows/release.yml

+17-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,30 @@ on:
44
push:
55
tags:
66
- '*'
7+
# push:
8+
# branches: "main"
9+
# workflow_dispatch:
710

811
jobs:
912
deploy:
13+
name: Release
1014
runs-on: ubuntu-latest
15+
1116
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/setup-node@v1
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v3.8.1
1419
with:
1520
node-version: 16
16-
- run: npm run install:all
17-
- run: npm run vscode:prepublish
21+
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
25+
- name: Install dependencies
26+
run: npm run install:all
27+
28+
- name: Build
29+
run: npm run vscode:prepublish
30+
1831
- name: Publish to Visual Studio Marketplace
1932
uses: HaaLeo/publish-vscode-extension@v1
2033
with:

data/samples.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5452,4 +5452,4 @@
54525452
"source": "cli"
54535453
}
54545454
]
5455-
}
5455+
}

scripts/createScriptSampleDefenition.ps1

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
param ($scriptSampleFolderPath, $cliScriptSampleFolderPath)
1+
param ($scriptSampleFolderPath, $cliScriptSampleFolderPath, $workingDirectory)
22

33
if ($null -eq $scriptSampleFolderPath -or $scriptSampleFolderPath -eq "") {
44
write-host "Please pass path to script samples from pnp/script-sample repo"
@@ -10,6 +10,11 @@ if ($null -eq $cliScriptSampleFolderPath -or $cliScriptSampleFolderPath -eq "")
1010
exit
1111
}
1212

13+
if ($null -eq $workingDirectory -or $workingDirectory -eq "") {
14+
write-host "Please pass path to working directory"
15+
exit
16+
}
17+
1318
$allSamples = Get-ChildItem -Path "$scriptSampleFolderPath\scripts\**\sample.json" -Recurse -Force
1419
$allCLiSamples = Get-ChildItem -Path "$cliScriptSampleFolderPath\**\sample.json" -Recurse -Force
1520

@@ -129,4 +134,4 @@ $orderedSampleModel = [ordered]@{}
129134
foreach ($Item in ($sampleModel.GetEnumerator() | Sort-Object -Property Key)) {
130135
$orderedSampleModel[$Item.Key] = $Item.Value
131136
}
132-
New-Object -TypeName psobject -Property $orderedSampleModel | ConvertTo-Json -Depth 10 | Out-File "..\data\samples.json"
137+
New-Object -TypeName psobject -Property $orderedSampleModel | ConvertTo-Json -Depth 10 | Out-File "$workingDirectory\data\samples.json"

scripts/createSnippetDefenition.ps1

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
param ($cliDocsFolderPath)
1+
param ($cliDocsFolderPath, $workingDirectory)
22

33
if ($null -eq $cliDocsFolderPath -or $cliDocsFolderPath -eq "") {
44
write-host "Please pass path to cli docs folder"
55
exit
66
}
77

8+
if ($null -eq $workingDirectory -or $workingDirectory -eq "") {
9+
write-host "Please pass path to working directory"
10+
exit
11+
}
12+
813
$allCommands = Get-ChildItem -Path "$cliDocsFolderPath\docs\cmd\*.mdx" -Recurse -Force -Exclude "_global*"
914

1015
$globalContent = Get-Content "$cliDocsFolderPath\docs\cmd\_global.mdx"
1116
$globalContent = $globalContent.Replace('```md definition-list', '').Replace('```', '')
1217
[hashtable]$global = @{}
1318
$global.Add('content', $globalContent)
14-
New-Object -TypeName psobject -Property $global | ConvertTo-Json | Out-File "..\data\global.json"
19+
New-Object -TypeName psobject -Property $global | ConvertTo-Json | Out-File "$workingDirectory\data\global.json"
1520

1621
[hashtable]$commandSnippets = @{}
1722
[hashtable]$m365Model = @{}
@@ -65,11 +70,11 @@ $orderedCommandSnippets = [ordered]@{}
6570
foreach ($Item in ($commandSnippets.GetEnumerator() | Sort-Object -Property Key)) {
6671
$orderedCommandSnippets[$Item.Key] = $Item.Value
6772
}
68-
New-Object -TypeName psobject -Property $orderedCommandSnippets | ConvertTo-Json | Out-File "..\snippets\cliForMicrosoft365.code-snippets"
73+
New-Object -TypeName psobject -Property $orderedCommandSnippets | ConvertTo-Json | Out-File "$workingDirectory\snippets\cliForMicrosoft365.code-snippets"
6974

7075
$m365Model.Add('commands', $commands)
7176
$orderedM365Model = [ordered]@{}
7277
foreach ($Item in ($m365Model.GetEnumerator() | Sort-Object -Property Key)) {
7378
$orderedM365Model[$Item.Key] = $Item.Value
7479
}
75-
New-Object -TypeName psobject -Property $orderedM365Model | ConvertTo-Json | Out-File "..\data\m365Model.json"
80+
New-Object -TypeName psobject -Property $orderedM365Model | ConvertTo-Json | Out-File "$workingDirectory\data\m365Model.json"

scripts/updatePackageVersion.ps1

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
param ($workingDirectory)
2+
3+
if ($null -eq $workingDirectory -or $workingDirectory -eq "") {
4+
write-host "Please pass path to working directory"
5+
exit
6+
}
7+
8+
$packageJson = Get-Content "$workingDirectory\package.json" | ConvertFrom-Json
9+
$oldVersion = $packageJson.version
10+
$oldVersionParts = $oldVersion.Split(".")
11+
$newVersion = "$($oldVersionParts[0]).$($oldVersionParts[1]).$([int]$oldVersionParts[2] + 1)"
12+
$packageJson.version = $newVersion
13+
$packageJson | ConvertTo-Json -Depth 10 | Out-File "$workingDirectory\package.json" -Encoding utf8 -Force

0 commit comments

Comments
 (0)