-
Notifications
You must be signed in to change notification settings - Fork 1
140 lines (122 loc) · 5.98 KB
/
keyfactor-extension-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
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
# This is a basic workflow to help you get started with Actions
name: Keyfactor Extension - Release
env:
SOLUTION_FOLDER: '.'
PROJECT_FOLDER: 'globalsign-atlas-cagateway'
# Controls when the action will run.
on:
# Triggers the workflow on pull requests closing
pull_request:
# only run this workflow when closing a PR to a branch that contains a release number. ignore -pre
branches:
- 'release-[0-9]+.[0-9]+'
- '!release-[0-9]+.[0-9]+-pre'
types: [closed]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# run if pull request is completed and merged, or if manually dispatched
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true)
# The type of runner that the job will run on
runs-on: windows-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Setup Envrionment
id: setup_env
run: |
echo "Setup Envrionment Variables for Workflow"
echo "Working Path: ${Env:GITHUB_WORKSPACE}"
$slnPath = (Get-ChildItem -Include *.sln -File -Recurse).fullname
$relName = "${{ github.ref }}".Split("/")
$repoName = "${{ github.repository }}".Split("/")
$relVersion = "${{ github.ref }}".Split("-")
echo "Solution File Path: ${slnPath}"
echo "SOLUTION_PATH=${slnPath}" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
echo "Release Name: $($relName[-1])"
echo "RELEASE_NAME=$($relName[-1])" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
echo "Repo Name: $($repoName[-1])"
echo "REPO_NAME=$($repoName[-1])" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
echo "Release Version: $($relVersion[-1])"
echo "RELEASE_VERSION=$($relVersion[-1])" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel
#dotnet-version:
- name: Add Package Source
run: |
dotnet nuget add source https://nuget.pkg.github.com/Keyfactor/index.json -n github -u ${{ github.actor }} -p ${{ secrets.BUILD_PACKAGE_ACCESS }} --store-password-in-clear-text
# Configures msbuild path envrionment
- name: setup-msbuild
uses: microsoft/setup-msbuild@v1
# Restores Packages to Local Machine
- name: restore nuget packages
run: |
nuget restore ${{ env.SOLUTION_PATH }}
- name: Create Release
id: create_release
#uses: zendesk/action-create-release@v1
uses: keyfactor/action-create-release@786b73035fa09790f9eb11bb86834a6d7af1c256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_name: ${{ env.REPO_NAME }} ${{ env.RELEASE_VERSION }}
body: |
[Changelog](../CHANGELOG.MD)
draft: false
prerelease: false
auto_increment_type: patch
tag_schema: semantic
commitish: ${{ github.sha }}
# update version number of AssemblyInfo.cs file
- name: Increment Assembly Version
run: |
$VersionRegex = "\d+\.\d+\.\d+"
$assemblyInfoFiles = (Get-ChildItem -Include AssemblyInfo.cs -File -Recurse).fullname
if ($assemblyInfoFiles -ne $null)
{
$newVer = "${{ steps.create_release.outputs.current_tag }}".TrimStart('v').Split('-')[0]
echo "Prepared to overwrite Assembly version to: ${newVer}"
foreach ($assemblyInfoFile in $assemblyInfoFiles)
{
$filecontent = Get-Content($assemblyInfoFile)
attrib $assemblyInfoFile -r
$filecontent -replace $VersionRegex, $newVer | Out-File $assemblyInfoFile
}
}
- name: Execute MSBuild Commands
run: |
$newVer = "${{ steps.create_release.outputs.current_tag }}".TrimStart('v').Split('-')[0]
MSBuild.exe $Env:SOLUTION_PATH -p:RestorePackagesConfig=false -p:Configuration=Release -p:Version=$newVer
- name: Archive Files
if: ${{ success() }}
run: |
md ${{ github.workspace }}\zip\Keyfactor
Compress-Archive -Path `
${{ env.SOLUTION_FOLDER }}\${{ env.PROJECT_FOLDER }}\bin\Release\*.dll, `
${{ env.SOLUTION_FOLDER }}\${{ env.PROJECT_FOLDER }}\bin\Release\*.json, `
${{ env.SOLUTION_FOLDER }}\${{ env.PROJECT_FOLDER }}\bin\Release\*.config `
-DestinationPath ${{ github.workspace }}\zip\Keyfactor\$Env:REPO_NAME.zip -Force
- name: Upload Release Asset (x64)
if: ${{ success() }}
id: upload-release-asset-x64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ github.workspace }}\zip\Keyfactor\${{ env.REPO_NAME}}.zip
asset_name: ${{ env.REPO_NAME}}_${{ steps.create_release.outputs.current_tag }}.zip
asset_content_type: application/zip
- name: On Failure - Remove Tags and Release
if: ${{ failure() }}
uses: dev-drprasad/[email protected]
with:
delete_release: true # default: false
tag_name: ${{ steps.create_release.outputs.current_tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}