data type conversion fix #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 }} |