-
Notifications
You must be signed in to change notification settings - Fork 2
149 lines (132 loc) · 5.62 KB
/
pipeline.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
# This workflow has been modified from the default supplied in codaamok.build
name: "Pipeline"
on:
push:
paths:
- 'src/**'
branches:
- main
- master
schedule:
- cron: '30 7 * * *'
workflow_dispatch:
jobs:
job-main:
name: main
runs-on: ubuntu-latest
services:
shlink:
image: shlinkio/shlink:stable
ports:
- 80:8080
env:
IS_HTTPS_ENABLED: false
DEFAULT_DOMAIN: psshlink.codaamok
options: --name shlink
steps:
- name: Checkout repository
uses: actions/checkout@v2.3.1
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.10
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.10
with:
useConfigFile: true
- name: Install codaamok.build and dependent modules, and set environment variables
run: |
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Install-Module "InvokeBuild" -Force
$Username, $ProjectName = $env:GITHUB_REPOSITORY -split "/"
Invoke-Build -File "invoke.build.ps1" -ModuleName $ProjectName -Author $Username -Task "InstallDependencies","ImportBuildModule","SetGitHubActionEnvironmentVariables"
shell: pwsh
- name: Build
run: |
$Params = @{
ModuleName = $env:GH_PROJECTNAME
Author = $env:GH_USERNAME
Version = $env:GitVersion_SemVer
NewRelease = ('push','workflow_dispatch' -contains $env:EVENT_NAME)
}
Invoke-Build -File "custom.build.ps1" @Params -Task PreBuild
Invoke-Build -File "invoke.build.ps1" @Params
Invoke-Build -File "custom.build.ps1" @Params -Task PostBuild
shell: pwsh
env:
EVENT_NAME: ${{ github.event_name }}
- name: Modify DNS
run: echo "127.0.0.1 psshlink.codaamok" | sudo tee -a /etc/hosts
- name: Generate Shlink API key
run: |
New-BuildEnvironmentVariable -Platform "GitHubActions" -Variable @{
"ShlinkAPIKey" = [Regex]::Match((docker exec -t shlink shlink api-key:generate --no-ansi), '([0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12})') |
Select-Object -ExpandProperty Value |
ConvertTo-SecureString -AsPlainText -Force |
ConvertFrom-SecureString
"ShlinkServer" = "http://psshlink.codaamok"
}
shell: pwsh
- name: Pester Tests
if: hashFiles('tests/invoke.tests.ps1') != ''
run: pwsh -File "tests/invoke.tests.ps1"
- name: Pester Tests Report
if: hashFiles('testResults.xml') != ''
uses: zyborg/pester-tests-report@v1
with:
test_results_path: 'testResults.xml'
report_name: Pester Tests Report
report_title: Pester Tests Report
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Custom pre-release tasks
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
run: Invoke-Build -File "custom.build.ps1" -ModuleName $env:GH_PROJECTNAME -Author $env:GH_USERNAME -Version $env:GitVersion_SemVer -NewRelease $true -Task PreRelease
shell: pwsh
- name: Publish to PowerShell Gallery
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
run: Invoke-Build -File "invoke.build.ps1" -ModuleName $env:GH_PROJECTNAME -Task "PublishModule"
shell: pwsh
env:
PSGALLERY_API_KEY: ${{ secrets.PSGALLERY_API_KEY }}
- name: Create release
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.GitVersion_SemVer }}
release_name: v${{ env.GitVersion_SemVer }}
body_path: release/releasenotes.txt
draft: false
prerelease: false
- name: Upload release asset
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
id: upload_release_asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/${{ env.GH_PROJECTNAME }}_${{ env.GitVersion_SemVer }}.zip
asset_name: ${{ env.GH_PROJECTNAME }}_${{ env.GitVersion_SemVer }}.zip
asset_content_type: application/zip
- name: Commit CHANGELOG.md and module manifest
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git add CHANGELOG.md src/${GH_PROJECTNAME}.psd1 docs
git commit -m "Released ${{ env.GitVersion_SemVer }}"
- name: Push commit
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Custom post-release tasks
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
run: Invoke-Build -File "custom.build.ps1" -ModuleName $env:GH_PROJECTNAME -Author $env:GH_USERNAME -Version $env:GitVersion_SemVer -NewRelease $true -Task PostRelease
shell: pwsh