-
Notifications
You must be signed in to change notification settings - Fork 155
153 lines (144 loc) · 5.85 KB
/
updateBuildYamls.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# 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 ""))
{
./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
./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
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