-
Notifications
You must be signed in to change notification settings - Fork 1
114 lines (93 loc) · 4.55 KB
/
tag-and-release.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
name: Tag, Release, and Publish to PSGallery and Chocolatey Community Repo
on:
workflow_dispatch:
pull_request:
types:
- closed
branches:
- master
jobs:
run-build-test:
if: github.event.pull_request.merged == true
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Run the build test workflow
run: gh workflow run build-test.yml
env:
GH_TOKEN: ${{ github.token }}
confirm-build-test:
needs: run-build-test
runs-on: windows-latest
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
- name: Wait for the runs to start
run: start-sleep 60
- name: Get run IDs
run: |
$runid=((& gh run list --workflow build-test.yml --json databaseId --limit 1) | convertfrom-json).databaseId
echo "RUNID=$runid" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: confirm build succeeded
run: |
$runstatus=""
while (($runstatus -ne "success") -AND ($runstatus -ne "failure")) {
start-sleep 15
$runstatus=((& gh run view $env:RUNID --exit-status --json conclusion) | Convertfrom-json).conclusion
}
if ($runstatus -eq "failure") {
exit 1
} else {
exit 0
}
publish-built-module:
needs: confirm-build-test
runs-on: windows-latest
env:
GH_TOKEN: ${{ github.token }}
GalKey: ${{ secrets.PSGALLERY }}
ChocoKey: ${{ secrets.CHOCOLATEY }}
steps:
- uses: actions/checkout@v4
- uses: fregante/[email protected]
- name: Build and publish module
run: |
"Building and publishing module and committing changes" | out-host;
Install-PSResource -Name PlatyPS -TrustRepository -Version 0.14.2 -Scope CurrentUser -AcceptLicense
$releaseNote = (git log -1 --pretty=%B)
"Setting release note to last commit message:`n$releaseNote" | out-host;
"Building docs, module, and incrementing version..." | out-host;
.\build.ps1 -releasenote "$($releaseNote | out-string)"
$version = (Test-ModuleManifest .\FogApi\FogApi.psd1).version
"Pushing Changes from publish" | out-host;
git add -A
git commit -m "$($releaseNote | out-string) - publish build for $version"
git push
"Publishing module to gallery..." | out-host;
Publish-PSResource -apikey $env:GalKey -Path .\_module_build\FogApi -Repository PSGallery;
"Creating Github Release..." | out-host;
gh release create $version --latest --generate-notes --target master
"Adding link to release notes doc page in release..." | out-host;
$notes = (gh release view $version --json body | convertfrom-json).body
$notes += "`n**Full Release Note History**: https://fogapi.readthedocs.io/en/latest/ReleaseNotes/"
gh release edit $version -n $notes
"Zipping up built and published module..." | out-host;
Compress-Archive -Path .\_module_build\FogApi -DestinationPath ".\_module_build\FogApi.$version.BuiltModule.zip"
"Downloading published nupkg..." | out-host;
$webClient = [System.Net.WebClient]::new();
$url = "https://www.powershellgallery.com/api/v2/package/FogApi/$version"
$webClient.DownloadFile($url,"$PWD\_module_build\FogApi.$version.psgallery.nupkg")
"Adding assets to release..." | out-host;
gh release upload $version ".\_module_build\FogApi.$version.psgallery.nupkg"
gh release upload $version ".\_module_build\FogApi.$version.BuiltModule.zip"
"building choco package from local build and temp psresource repo..." | out-host;
.\build-choco.ps1 -uselocal;
"adding choco package to release" | out-host;
copy-item ".\FogApi.$version.nupkg" ".\FogApi.$version.chocolatey.nupkg"
gh release upload $version ".\FogApi.$version.chocolatey.nupkg"
remove-item ".\FogApi.$version.chocolatey.nupkg" -force -recurse -ea 0;
#"publishing choco package..." | out-host;
#choco apikey add -s "https://push.chocolatey.org/" -k="$env:ChocoKey"
#choco apikey add -s "https://community.chocolatey.org/api/v2/" -k="$env:ChocoKey"
#choco push "FogApi.$version.nupkg" --source https://push.chocolatey.org/