Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
Adds prepare release flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam-it committed May 18, 2024
1 parent d75d22e commit 57c2026
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 21 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Prepare Release"

on:
workflow_dispatch:

jobs:
deploy:
name: "Prepare Release"
runs-on: windows-latest
steps:
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- name: Checkout PnP PowerShell VS Code Extension
uses: actions/checkout@v4
with:
path: pnp-powershell-extension
- name: Checkout PnP PowerShell
uses: actions/checkout@v4
with:
repository: pnp/powershell
path: powershell
- name: Checkout PnP Script Samples
uses: actions/checkout@v4
with:
repository: pnp/script-samples
path: script-samples
- name: Run create script samples script
run: .\pnp-powershell-extension\scripts\createScriptSampleDefenition.ps1 -PathToWorkspace ".\"
shell: pwsh
continue-on-error: false
- name: Run create snippet defenition script
run: .\pnp-powershell-extension\scripts\createSnippetDefenition.ps1 -PathToWorkspace ".\"
shell: pwsh
continue-on-error: false
- name: Run update package version script
run: .\pnp-powershell-extension\scripts\updatePackageVersion.ps1 -PathToWorkspace ".\"
shell: pwsh
continue-on-error: false
- name: Install dependencies
run: npm run install:all
working-directory: pnp-powershell-extension
- name: Build
run: npm run vscode:prepublish
working-directory: pnp-powershell-extension
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
path: pnp-powershell-extension
commit-message: prepare release
branch: prepare-release
title: Prepare Release
body: Prepare Release
...
22 changes: 11 additions & 11 deletions scripts/createScriptSampleDefenition.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
param ($scriptSampleFolderPath)
param (
[Parameter(Mandatory = $true)]
[string]$PathToWorkspace
)

if ($null -eq $scriptSampleFolderPath -or $scriptSampleFolderPath -eq "") {
write-host "Please pass path to script samples from pnp/script-sample repo"
exit
}

$allSamples = Get-ChildItem -Path "$scriptSampleFolderPath\scripts\**\sample.json" -Recurse -Force
$allSamples = Get-ChildItem -Path "$PathToWorkspace\script-samples\scripts\**\sample.json" -Recurse -Force

[hashtable]$sampleModel = @{}
$samples = @()
Expand All @@ -31,10 +29,10 @@ foreach ($sample in $allSamples) {
$rawUrl = $rawUrl.Replace('.html', '.md')

$sampleAuthors = @()
foreach($author in $sampleJson.authors) {
foreach ($author in $sampleJson.authors) {
$sampleAuthors += [pscustomobject]@{
name = $author.name;
pictureUrl = $author.pictureUrl;
name = $author.name;
pictureUrl = $author.pictureUrl;
}
}

Expand All @@ -53,7 +51,9 @@ foreach ($sample in $allSamples) {

$sampleModel.Add('samples', $samples)
$orderedSampleModel = [ordered]@{}

foreach ($Item in ($sampleModel.GetEnumerator() | Sort-Object -Property Key)) {
$orderedSampleModel[$Item.Key] = $Item.Value
}
New-Object -TypeName psobject -Property $orderedSampleModel | ConvertTo-Json -Depth 10 | Out-File "..\data\samples.json"

New-Object -TypeName psobject -Property $orderedSampleModel | ConvertTo-Json -Depth 10 | Out-File "$PathToWorkspace\pnp-powershell-extension\data\samples.json"
18 changes: 8 additions & 10 deletions scripts/createSnippetDefenition.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
param ($PSDocsFolderPath)
param (
[Parameter(Mandatory = $true)]
[string]$PathToWorkspace
)

if ($null -eq $PSDocsFolderPath -or $PSDocsFolderPath -eq "") {
write-host "Please pass path to PS docs folder"
exit
}

$allCommands = Get-ChildItem -Path "$PSDocsFolderPath\documentation\*.md" -Recurse -Force -Exclude "_global*"
$allCommands = Get-ChildItem -Path "$PathToWorkspace\powershell\documentation\*.md" -Recurse -Force -Exclude "_global*"

[hashtable]$commandSnippets = @{}
[hashtable]$pnpPsModel = @{}
$commands = @()

foreach ($command in $allCommands) {
$commandDocs = ConvertFrom-Markdown -Path $command
$html = New-Object -Com 'HTMLFile'
$html = New-Object -ComObject 'HTMLFile'
$html.write([ref]$commandDocs.Html)

$title = $html.all.tags('h1')[0]
Expand Down Expand Up @@ -68,11 +66,11 @@ $orderedCommandSnippets = [ordered]@{}
foreach ($Item in ($commandSnippets.GetEnumerator() | Sort-Object -Property Key)) {
$orderedCommandSnippets[$Item.Key] = $Item.Value
}
New-Object -TypeName psobject -Property $orderedCommandSnippets | ConvertTo-Json | Out-File "..\snippets\pnpPowerShell.code-snippets"
New-Object -TypeName psobject -Property $orderedCommandSnippets | ConvertTo-Json | Out-File "$PathToWorkspace\pnp-powershell-extension\snippets\pnpPowerShell.code-snippets"

$pnpPsModel.Add('commands', $commands)
$orderedPnpPsModel = [ordered]@{}
foreach ($Item in ($pnpPsModel.GetEnumerator() | Sort-Object -Property Key)) {
$orderedPnpPsModel[$Item.Key] = $Item.Value
}
New-Object -TypeName psobject -Property $orderedPnpPsModel | ConvertTo-Json | Out-File "..\data\pnpPsModel.json"
New-Object -TypeName psobject -Property $orderedPnpPsModel | ConvertTo-Json | Out-File "$PathToWorkspace\pnp-powershell-extension\data\pnpPsModel.json"
11 changes: 11 additions & 0 deletions scripts/updatePackageVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
param (
[Parameter(Mandatory = $true)]
[string]$PathToWorkspace
)

$packageJson = Get-Content "$PathToWorkspace\pnp-powershell-extension\package.json" | ConvertFrom-Json
$oldVersion = $packageJson.version
$oldVersionParts = $oldVersion.Split(".")
$newVersion = "$($oldVersionParts[0]).$($oldVersionParts[1]).$([int]$oldVersionParts[2] + 1)"
$packageJson.version = $newVersion
$packageJson | ConvertTo-Json -Depth 10 | Out-File "$PathToWorkspace\pnp-powershell-extension\package.json" -Encoding utf8 -Force

0 comments on commit 57c2026

Please sign in to comment.