Skip to content

GH Action to populate build stage yaml files (stable only for now) #18

GH Action to populate build stage yaml files (stable only for now)

GH Action to populate build stage yaml files (stable only for now) #18

# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
name: Update Channel Based ReleaseStage Yaml Files
permissions:
contents: read
on:
workflow_dispatch:
inputs:
stableReleaseTag:
description: 'release tag for stable'
required: false
previewReleaseTag:
description: 'release tag for preview'
required: false
ltsReleaseTag:
description: 'release tag for lts'
required: false
pull_request:
defaults:
run:
shell: pwsh
jobs:
update-yaml-stable:
name: Update ReleaseStageYaml for Stable Channel
timeout-minutes: 15
runs-on: ubuntu-20.04
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Validate Version Syntax
id: validateversion
run: |
$stableValue = '${{ inputs.stableReleaseTag }}'
if (!($stableValue -eq ""))
{
if ($stableValue -notmatch '^v\d+\.\d+\.\d+$') {
throw "stable release tag is not for a stable build: '$stableValue'"
}
echo "stableVersion=$stableValue" >> $GITHUB_OUTPUT
}
else
{
$stableValue = ''
echo "stableVersion=$stableValue" >> $GITHUB_OUTPUT
}
$previewValue = '${{ inputs.previewReleaseTag }}'
if (!($previewValue -eq ""))
{
if ($previewValue -notmatch '^v\d+\.\d+\.\d+-(preview|rc)\.\d+$') {
throw "preview release tag is not for a preview build: '$previewValue'"
}
echo "previewVersion=$previewValue" >> $GITHUB_OUTPUT
}
else
{
$previewValue = ''
echo "previewVersion=$previewValue" >> $GITHUB_OUTPUT
}
$ltsValue = '${{ inputs.ltsReleaseTag }}'
if (!($ltsValue -eq ""))
{
if ($ltsValue -notmatch '^v\d+\.\d+\.\d+$') {
throw "lts release tag is not for a lts build: '$ltsValue'"
}
echo "ltsVersion=$ltsValue" >> $GITHUB_OUTPUT
}
else
{
$ltsValue = ''
echo "ltsVersion=$ltsValue" >> $GITHUB_OUTPUT
}
- name: Update ReleaseStageYaml file for Stable
run: |
$toolsFolderPath = Join-Path -Path ${{ github.workspace }} -ChildPath 'tools'
$buildHelperFolderPath = Join-Path -Path $toolsFolderPath -ChildPath 'buildHelper'
$buildHelperModulePath = Join-Path -Path $buildHelperFolderPath -ChildPath 'buildHelper.psm1'
Import-Module $buildHelperModulePath
$stableVersionValue = '${{ steps.validateversion.outputs.stableVersion }}'
if (!($stableVersionValue -eq ""))
{
Write-Verbose -Verbose "using stable version: $stableVersionValue"
./build.ps1 -UpdateBuildYaml -Channel stable -StableVersion ${{ steps.validateversion.outputs.stableVersion }} -Verbose -Acr All -OsFilter All
}
else
{
# Use the version from channels.json when no version is provided
Write-Verbose -Verbose "not using stable version from input"
./build.ps1 -UpdateBuildYaml -Channel stable -Verbose -Acr All -OsFilter All
}
- name: Update ReleaseStageYaml file for Preview
run: |
$toolsFolderPath = Join-Path -Path ${{ github.workspace }} -ChildPath 'tools'
$buildHelperFolderPath = Join-Path -Path $toolsFolderPath -ChildPath 'buildHelper'
$buildHelperModulePath = Join-Path -Path $buildHelperFolderPath -ChildPath 'buildHelper.psm1'
Import-Module $buildHelperModulePath
$previewVersionValue = '${{ steps.validateversion.outputs.previewVersion }}'
if (!($previewVersionValue -eq ""))
{
./build.ps1 -UpdateBuildYaml -Channel preview -PreviewVersion ${{ steps.validateversion.outputs.previewVersion }} -Verbose -Acr All -OsFilter All
}
else
{
# Use the version from channels.json when no version is provided
./build.ps1 -UpdateBuildYaml -Channel preview -Verbose -Acr All -OsFilter All
}
- name: Update ReleaseStageYaml file for LTS
run: |
$toolsFolderPath = Join-Path -Path ${{ github.workspace }} -ChildPath 'tools'
$buildHelperFolderPath = Join-Path -Path $toolsFolderPath -ChildPath 'buildHelper'
$buildHelperModulePath = Join-Path -Path $buildHelperFolderPath -ChildPath 'buildHelper.psm1'
Import-Module $buildHelperModulePath
$ltsVersionValue = '${{ steps.validateversion.outputs.ltsVersion }}'
if (!($ltsVersionValue -eq ""))
{
./build.ps1 -UpdateBuildYaml -Channel lts -LtsVersion ${{ steps.validateversion.outputs.ltsVersion }} -Verbose -Acr All -OsFilter All
}
else
{
# Use the version from channels.json when no version is provided
./build.ps1 -UpdateBuildYaml -Channel lts -Verbose -Acr All -OsFilter All
}
- name: View Updated Files Content
run: |
$ciFolderPath = Join-Path -Path ${{ github.workspace }} -ChildPath '.vsts-ci'
$releaseStageFilePath = Join-Path -Path $ciFolderPath -ChildPath 'stableReleaseStage.yml'
$content = Get-Content -Path $releaseStageFilePath
Write-Verbose -Verbose "length of content: $content.Length"
for($i=0; $i -lt $content.Length;$i++)
{
Write-Verbose -Verbose $content[$i]
}
- name: Create Pull Request
if: github.event_name == 'workflow_dispatch'
id: cpr
uses: peter-evans/create-pull-request@v4
with:
token: "${{ secrets.PR_PAT }}"
commit-message: "Update the stableReleaseStage yaml file"
committer: PwshBot <[email protected]>
author: PwshBot <[email protected]>
title: "Update the stableReleaseStage json"
base: master
draft: false
branch: update-build-yaml-files
push-to-fork: pwshBot/PowerShell-Docker