Skip to content

Commit 519a117

Browse files
authored
Create cd.yml
1 parent 1cc7e60 commit 519a117

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/cd.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CD
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
deployment:
7+
runs-on: ubuntu-latest
8+
env:
9+
module_name: ServiceNow
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
token: ${{ secrets.CD_TOKEN }}
14+
- name: Update psd version
15+
shell: pwsh
16+
run: |
17+
$manifestPath = '${{ github.workspace }}/${{ env.module_name }}/${{ env.module_name }}.psd1'
18+
$manifest = Import-PowerShellDataFile $manifestPath
19+
[version]$version = $manifest.ModuleVersion
20+
[version]$newVersion = "{0}.{1}.{2}" -f $Version.Major, $Version.Minor, ($Version.Build + 1)
21+
Update-ModuleManifest -Path $manifestPath -ModuleVersion $newVersion
22+
23+
# update-modulemanifest introduces whitepsace so get rid of it
24+
(Get-Content $manifestPath).TrimEnd() | Set-Content $manifestPath
25+
26+
"New version: $newVersion"
27+
# set version to be used in later steps
28+
"module_new_version=$newVersion" | Out-File -FilePath $env:GITHUB_ENV -Append
29+
- name: Update changelog
30+
shell: pwsh
31+
run: |
32+
$newVersionString = '## ${{ env.module_new_version }}'
33+
$releaseNotes = Get-Content -Path '${{ github.workspace }}/RELEASE.md' -Raw
34+
$changelog = Get-Content -Path '${{ github.workspace }}/CHANGELOG.md' -Raw
35+
Set-Content -Path '${{ github.workspace }}/CHANGELOG.md' -Value ($newVersionString + "`r`n" + $releaseNotes + "`r`n`r`n" + $changelog)
36+
- name: Update repo
37+
run: |
38+
git config --global user.name 'Greg Brownstein'
39+
git config --global user.email 'greg@jagtechnical.com'
40+
git add ${{ env.module_name }}
41+
git add CHANGELOG.md
42+
git status
43+
git commit -m "Update manifest to ${{ env.module_new_version }}"
44+
git push
45+
- name: Create GitHub release
46+
if: github.ref == 'refs/heads/master'
47+
uses: softprops/action-gh-release@v1
48+
with:
49+
tag_name: v${{ env.module_new_version }}
50+
body_path: ${{ github.workspace }}/RELEASE.md
51+
- name: Publish
52+
if: github.ref == 'refs/heads/master'
53+
shell: pwsh
54+
run: |
55+
Publish-Module -Path "${{ github.workspace }}/${{ env.module_name }}" -NuGetApiKey ${{ secrets.NUGET_KEY }} -Verbose

0 commit comments

Comments
 (0)