-
Notifications
You must be signed in to change notification settings - Fork 171
77 lines (65 loc) · 2.79 KB
/
cd.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
name: CD
on: workflow_dispatch
jobs:
deployment:
runs-on: ubuntu-latest
env:
module_name: ServiceNow
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.CD_TOKEN }}
- name: Update psd version
shell: pwsh
run: |
$manifestPath = '${{ github.workspace }}/${{ env.module_name }}/${{ env.module_name }}.psd1'
$manifest = Import-PowerShellDataFile $manifestPath
[version]$version = $manifest.ModuleVersion
[version]$newVersion = "{0}.{1}.{2}" -f $Version.Major, $Version.Minor, ($Version.Build + 1)
Update-ModuleManifest -Path $manifestPath -ModuleVersion $newVersion
# update-modulemanifest introduces whitepsace so get rid of it
(Get-Content $manifestPath).TrimEnd() | Set-Content $manifestPath
"New version: $newVersion"
# set version to be used in later steps
"module_new_version=$newVersion" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Update changelog
shell: pwsh
run: |
$newVersionString = '## ${{ env.module_new_version }}'
$releaseNotes = Get-Content -Path '${{ github.workspace }}/RELEASE.md' -Raw
$changelog = Get-Content -Path '${{ github.workspace }}/CHANGELOG.md' -Raw
Set-Content -Path '${{ github.workspace }}/CHANGELOG.md' -Value ($newVersionString + "`r`n" + $releaseNotes + "`r`n`r`n" + $changelog)
- name: Update repo
run: |
git config --global user.name 'Greg Brownstein'
git config --global user.email '[email protected]'
git add ${{ env.module_name }}
git add CHANGELOG.md
git status
git commit -m "Update manifest to ${{ env.module_new_version }}"
git push
- name: Create GitHub release
if: github.ref == 'refs/heads/master'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.module_new_version }}
body_path: ${{ github.workspace }}/RELEASE.md
- name: Publish
if: github.ref == 'refs/heads/master'
shell: pwsh
run: |
Publish-Module -Path "${{ github.workspace }}/${{ env.module_name }}" -NuGetApiKey ${{ secrets.NUGET_KEY }} -Verbose
- name: Login to dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build image
run: >
docker build
--pull
-t ${{ secrets.DOCKER_USERNAME }}/servicenow-module:latest
-t ${{ secrets.DOCKER_USERNAME }}/servicenow-module:${{ env.module_new_version }}
.
- name: Publish image and tags
run: docker push --all-tags ${{ secrets.DOCKER_USERNAME }}/servicenow-module