Skip to content

Commit 7950752

Browse files
authored
Merge pull request #1 from Keyfactor/initial-version
Initial version
2 parents ed04dd6 + f551fcf commit 7950752

24 files changed

+1025
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This workflow will run automatic builds for checkins to feature branches
2+
# It runs automtatically for branches that are not main, or release-* branches (including prerelease)
3+
4+
name: Keyfactor - Build .NET Solution
5+
6+
on:
7+
push: # build on push
8+
# don't run on push to main or release branches
9+
branches-ignore:
10+
- 'main'
11+
- 'release-**'
12+
pull_request: # also build on PRs to pre-release
13+
branches:
14+
- 'release-[0-9]+.[0-9]+-pre'
15+
workflow_dispatch: # allow manual runs
16+
17+
jobs:
18+
build:
19+
runs-on: windows-latest
20+
steps:
21+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
22+
- uses: actions/checkout@v2
23+
24+
- name: Setup Envrionment
25+
id: setup_env
26+
run: |
27+
echo "Setup Envrionment Variables for Workflow"
28+
echo "Working Path: ${Env:GITHUB_WORKSPACE}"
29+
$slnPath = (Get-ChildItem -Include *.sln -File -Recurse).fullname
30+
echo "Solution File Path: ${slnPath}"
31+
echo "SOLUTION_PATH=${slnPath}" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
32+
33+
- uses: actions/setup-dotnet@v1
34+
with:
35+
dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel
36+
#dotnet-version:
37+
38+
- name: Add Package Source
39+
run: |
40+
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
41+
42+
# Configures msbuild path envrionment
43+
- name: setup-msbuild
44+
uses: microsoft/setup-msbuild@v1
45+
46+
# Restores Packages to Local Machine
47+
- name: restore nuget packages
48+
run: |
49+
nuget restore ${{ env.SOLUTION_PATH }}
50+
51+
# Runs a set of commands using the runners shell
52+
- name: Execute MSBuild Commands
53+
run: |
54+
MSBuild.exe $Env:SOLUTION_PATH -p:RestorePackagesConfig=true -p:Configuration=Release
55+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Update README
2+
on: [push, workflow_dispatch]
3+
4+
jobs:
5+
update_readme:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- uses: actions/checkout@master
10+
11+
- uses: cuchi/jinja2-action@v1.2.0
12+
with:
13+
template: README.md.tpl
14+
output_file: README.md
15+
data_file: integration-manifest.json
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.SDK_SYNC_PAT }}
18+
19+
- uses: stefanzweifel/git-auto-commit-action@v4
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
with:
23+
push_options: '--force'
24+
commit_message: Update generated README
25+
commit_user_name: Keyfactor
26+
commit_user_email: keyfactor@keyfactor.github.io
27+
commit_author: Keyfactor <keyfactor@keyfactor.github.io>
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
# This workflow will build a Release Candidate (pre-release)
2+
# It runs automatically when attempting a PR from pre-release branch to the release branch
3+
4+
name: Keyfactor Extension - Release Candidate
5+
6+
env:
7+
SOLUTION_FOLDER: '.'
8+
PROJECT_FOLDER: 'Fortanix'
9+
10+
# Controls when the action will run.
11+
on:
12+
# Triggers the workflow on PR open
13+
pull_request:
14+
types: [opened, synchronize]
15+
# only run this workflow when opening PR to release branch
16+
branches:
17+
- '!release-[0-9]+.[0-9]+-pre'
18+
- 'release-[0-9]+.[0-9]+'
19+
20+
# Release Candidate can be triggered manually
21+
workflow_dispatch:
22+
23+
jobs:
24+
# This workflow contains a single job called "build"
25+
build:
26+
# The type of runner that the job will run on
27+
runs-on: windows-latest
28+
29+
# Steps represent a sequence of tasks that will be executed as part of the job
30+
steps:
31+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
32+
- uses: actions/checkout@v2
33+
34+
- name: Setup Envrionment
35+
id: setup_env
36+
run: |
37+
echo "Setup Envrionment Variables for Workflow"
38+
echo "Working Path: ${Env:GITHUB_WORKSPACE}"
39+
$slnPath = (Get-ChildItem -Include *.sln -File -Recurse).fullname
40+
$relName = "${{ github.base_ref }}".Split("/")
41+
$repoName = "${{ github.repository }}".Split("/")
42+
$relVersion = "${{ github.base_ref }}".Split("-")
43+
echo "Solution File Path: ${slnPath}"
44+
echo "SOLUTION_PATH=${slnPath}" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
45+
echo "Release Name: $($relName[-1])"
46+
echo "RELEASE_NAME=$($relName[-1])" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
47+
echo "Repo Name: $($repoName[-1])"
48+
echo "REPO_NAME=$($repoName[-1])" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
49+
echo "Release Version: $($relVersion[-1])"
50+
echo "RELEASE_VERSION=$($relVersion[-1])" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
51+
52+
- uses: actions/setup-dotnet@v1
53+
with:
54+
dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel
55+
#dotnet-version:
56+
57+
- name: Add Package Source
58+
run: |
59+
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
60+
61+
# Configures msbuild path envrionment
62+
- name: setup-msbuild
63+
uses: microsoft/setup-msbuild@v1
64+
65+
# Restores Packages to Local Machine
66+
- name: restore nuget packages
67+
run: |
68+
nuget restore ${{ env.SOLUTION_PATH }}
69+
70+
- name: GitHub Script checks for existing version tags
71+
id: existing_version
72+
uses: actions/github-script@v4.0.2
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
VERSION_NUMBER: ${{ env.RELEASE_VERSION }}
76+
with:
77+
script: |
78+
// check for existing tags on this major.minor version
79+
const tagsList = await github.git.listMatchingRefs({
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
ref: 'tags'
83+
});
84+
85+
const { VERSION_NUMBER } = process.env;
86+
const tags = tagsList.data.reverse();
87+
88+
// assume linear release pattern - i.e. always working on latest major.minor version
89+
// if there are no tags, or latest tag does not start with VERSION_NUMBER, set a manual version for release
90+
if (tags.length < 1
91+
|| !tags.shift().ref.startsWith(`refs/tags/${VERSION_NUMBER}`)) {
92+
core.exportVariable('MANUAL_VERSION', `${VERSION_NUMBER}.0-rc.0`);
93+
}
94+
95+
# Create a new release to auto-increment (or use manual version number)
96+
- name: Create new release
97+
id: create_release
98+
#uses: zendesk/action-create-release@v1
99+
uses: keyfactor/action-create-release@786b73035fa09790f9eb11bb86834a6d7af1c256
100+
env:
101+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
MANUAL_VERSION: ${{ env.MANUAL_VERSION }}
103+
with:
104+
release_name: Release Candidate ${{ env.REPO_NAME }} ${{ env.RELEASE_VERSION }}
105+
body: |
106+
[Changelog](../CHANGELOG.MD)
107+
draft: false
108+
prerelease: true
109+
prerelease_suffix: rc
110+
tag_name: ${{ env.MANUAL_VERSION }}
111+
auto_increment_type: prerelease
112+
tag_schema: semantic
113+
commitish: ${{ github.sha }}
114+
115+
# update version number of AssemblyInfo.cs file
116+
- name: Increment Assembly Version
117+
run: |
118+
$VersionRegex = "\d+\.\d+\.\d+"
119+
$assemblyInfoFiles = (Get-ChildItem -Include AssemblyInfo.cs -File -Recurse).fullname
120+
$newVer = "${{ steps.create_release.outputs.current_tag }}".TrimStart('v').Split('-')[0]
121+
echo "Prepared to overwrite Assembly version to: ${newVer}"
122+
foreach ($assemblyInfoFile in $assemblyInfoFiles)
123+
{
124+
$filecontent = Get-Content($assemblyInfoFile)
125+
attrib $assemblyInfoFile -r
126+
$filecontent -replace $VersionRegex, $newVer | Out-File $assemblyInfoFile
127+
}
128+
129+
# Runs a set of commands using the runners shell
130+
- name: Execute MSBuild Commands
131+
run: |
132+
MSBuild.exe $Env:SOLUTION_PATH -p:RestorePackagesConfig=true -p:Configuration=Release
133+
134+
- name: Archive Files
135+
run: |
136+
md ${{ github.workspace }}\zip\Keyfactor
137+
Compress-Archive -Path `
138+
${{ env.SOLUTION_FOLDER }}\${{ env.PROJECT_FOLDER }}\bin\Release\netcoreapp3.1\* `
139+
-DestinationPath ${{ github.workspace }}\zip\Keyfactor\$Env:REPO_NAME.zip -Force
140+
141+
142+
- name: Upload a Build Artifact
143+
uses: actions/upload-artifact@v2.2.2
144+
with:
145+
# Artifact name
146+
name: ${{ env.REPO_NAME }}.zip
147+
# A file, directory or wildcard pattern that describes what to upload
148+
path: |
149+
${{ github.workspace }}\zip\Keyfactor\${{ env.REPO_NAME}}.zip
150+
# The desired behavior if no files are found using the provided path.
151+
if-no-files-found: error # optional, default is warn
152+
153+
- name: Upload Release Asset (x64)
154+
id: upload-release-asset-x64
155+
uses: actions/upload-release-asset@v1
156+
env:
157+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158+
with:
159+
upload_url: ${{ steps.create_release.outputs.upload_url }}
160+
asset_path: ${{ github.workspace }}\zip\Keyfactor\${{ env.REPO_NAME}}.zip
161+
asset_name: ${{ env.REPO_NAME}}_${{ steps.create_release.outputs.current_tag }}.zip
162+
asset_content_type: application/zip
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Keyfactor Extension - Release
4+
5+
env:
6+
SOLUTION_FOLDER: '.'
7+
PROJECT_FOLDER: 'Fortanix'
8+
9+
# Controls when the action will run.
10+
on:
11+
# Triggers the workflow on pull requests closing
12+
pull_request:
13+
# only run this workflow when closing a PR to a branch that contains a release number. ignore -pre
14+
branches:
15+
- 'release-[0-9]+.[0-9]+'
16+
- '!release-[0-9]+.[0-9]+-pre'
17+
types: [closed]
18+
19+
# Allows you to run this workflow manually from the Actions tab
20+
workflow_dispatch:
21+
22+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
23+
jobs:
24+
# This workflow contains a single job called "build"
25+
build:
26+
# run if pull request is completed and merged, or if manually dispatched
27+
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true)
28+
29+
# The type of runner that the job will run on
30+
runs-on: windows-latest
31+
32+
# Steps represent a sequence of tasks that will be executed as part of the job
33+
steps:
34+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
35+
- uses: actions/checkout@v2
36+
37+
- name: Setup Envrionment
38+
id: setup_env
39+
run: |
40+
echo "Setup Envrionment Variables for Workflow"
41+
echo "Working Path: ${Env:GITHUB_WORKSPACE}"
42+
$slnPath = (Get-ChildItem -Include *.sln -File -Recurse).fullname
43+
$relName = "${{ github.ref }}".Split("/")
44+
$repoName = "${{ github.repository }}".Split("/")
45+
$relVersion = "${{ github.ref }}".Split("-")
46+
echo "Solution File Path: ${slnPath}"
47+
echo "SOLUTION_PATH=${slnPath}" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
48+
echo "Release Name: $($relName[-1])"
49+
echo "RELEASE_NAME=$($relName[-1])" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
50+
echo "Repo Name: $($repoName[-1])"
51+
echo "REPO_NAME=$($repoName[-1])" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
52+
echo "Release Version: $($relVersion[-1])"
53+
echo "RELEASE_VERSION=$($relVersion[-1])" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
54+
55+
- uses: actions/setup-dotnet@v1
56+
with:
57+
dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel
58+
#dotnet-version:
59+
60+
- name: Add Package Source
61+
run: |
62+
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
63+
64+
# Configures msbuild path envrionment
65+
- name: setup-msbuild
66+
uses: microsoft/setup-msbuild@v1
67+
68+
# Restores Packages to Local Machine
69+
- name: restore nuget packages
70+
run: |
71+
nuget restore ${{ env.SOLUTION_PATH }}
72+
73+
- name: Create Release
74+
id: create_release
75+
#uses: zendesk/action-create-release@v1
76+
uses: keyfactor/action-create-release@786b73035fa09790f9eb11bb86834a6d7af1c256
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
with:
80+
release_name: ${{ env.REPO_NAME }} ${{ env.RELEASE_VERSION }}
81+
body: |
82+
[Changelog](../CHANGELOG.MD)
83+
draft: false
84+
prerelease: false
85+
auto_increment_type: patch
86+
tag_schema: semantic
87+
commitish: ${{ github.sha }}
88+
89+
# update version number of AssemblyInfo.cs file
90+
- name: Increment Assembly Version
91+
run: |
92+
$VersionRegex = "\d+\.\d+\.\d+"
93+
$assemblyInfoFiles = (Get-ChildItem -Include AssemblyInfo.cs -File -Recurse).fullname
94+
$newVer = "${{ steps.create_release.outputs.current_tag }}".TrimStart('v').Split('-')[0]
95+
echo "Prepared to overwrite Assembly version to: ${newVer}"
96+
foreach ($assemblyInfoFile in $assemblyInfoFiles)
97+
{
98+
$filecontent = Get-Content($assemblyInfoFile)
99+
attrib $assemblyInfoFile -r
100+
$filecontent -replace $VersionRegex, $newVer | Out-File $assemblyInfoFile
101+
}
102+
103+
- name: Execute MSBuild Commands
104+
run: |
105+
MSBuild.exe $Env:SOLUTION_PATH -p:RestorePackagesConfig=false -p:Configuration=Release
106+
107+
- name: Archive Files
108+
if: ${{ success() }}
109+
run: |
110+
md ${{ github.workspace }}\zip\Keyfactor
111+
Compress-Archive -Path `
112+
${{ env.SOLUTION_FOLDER }}\${{ env.PROJECT_FOLDER }}\bin\Release\netcoreapp3.1\* `
113+
-DestinationPath ${{ github.workspace }}\zip\Keyfactor\$Env:REPO_NAME.zip -Force
114+
115+
- name: Upload Release Asset (x64)
116+
if: ${{ success() }}
117+
id: upload-release-asset-x64
118+
uses: actions/upload-release-asset@v1
119+
env:
120+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
with:
122+
upload_url: ${{ steps.create_release.outputs.upload_url }}
123+
asset_path: ${{ github.workspace }}\zip\Keyfactor\${{ env.REPO_NAME}}.zip
124+
asset_name: ${{ env.REPO_NAME}}_${{ steps.create_release.outputs.current_tag }}.zip
125+
asset_content_type: application/zip
126+
127+
- name: On Failure - Remove Tags and Release
128+
if: ${{ failure() }}
129+
uses: dev-drprasad/delete-tag-and-release@v0.2.0
130+
with:
131+
delete_release: true # default: false
132+
tag_name: ${{ steps.create_release.outputs.current_tag }}
133+
env:
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)