-
Notifications
You must be signed in to change notification settings - Fork 5
56 lines (55 loc) · 2.49 KB
/
tester.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
# working dir : D:\a\chef-powershell-shim\chef-powershell-shim
name: Manual Tester Workflow
on:
workflow_dispatch:
jobs:
Build-And-Push-Chef-PowerShell-Gem:
if: github.event_name == 'workflow_dispatch'
runs-on: windows-latest
steps:
- name: Check out repo
uses: actions/checkout@v2
- name: Update the Gem version
run: |
$project_root = $pwd
$update_type = $null
try {
$file = (Get-Content $("$project_root\chef-powershell\lib\chef-powershell\version.rb"))
}
catch {
Write-Error "Failed to Get the Version from version.rb"
}
[version]$Version = [regex]::matches($file, "\s*VERSION\s=\s\`"(\d*.\d*.\d*)\`"\s*").groups[1].value
$update_type = [System.Environment]::GetEnvironmentVariable("CHEF_POWERSHELL_VERSION_UPDATE", "Machine")
# Add one to the build of the version number
if ($update_type -eq "Major") {
[version]$NewVersion = "{0}.{1}.{2}" -f ($Version.Major + 1), $Version.Minor, $Version.Build
}
elseif ($update_type -eq "Minor") {
[version]$NewVersion = "{0}.{1}.{2}" -f $Version.Major, ($Version.Minor + 1), $Version.Build
}
elseif (([string]::IsNullOrEmpty($update_type)) -or ($update_type -eq "Version")) {
[version]$NewVersion = "{0}.{1}.{2}" -f $Version.Major, $Version.Minor, ($Version.Build + 1)
}
else {
Write-Error "failed to update the version string"
}
# Replace Old Version Number with New Version number in the file
try {
(Get-Content .\chef-powershell\lib\chef-powershell\version.rb) -replace $version, $NewVersion | Out-File .\chef-powershell\lib\chef-powershell\version.rb -Encoding utf8
Write-Output "Updated Module Version from $Version to $NewVersion"
}
catch {
$_
Write-Error "failed to set file"
}
shell: powershell
- name: Commit changes to the Version file
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git checkout -b version_pr
git add -u
git commit -sm "Automated version update PR"
git push origin version_pr