Skip to content

Commit 11dec28

Browse files
Initial commit
0 parents  commit 11dec28

21 files changed

+1105
-0
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "nuget" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.github/issue-branch.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
defaultBranch: 'develop'
2+
branchName: '${issue.number}:${issue.title,}'
3+
mode: auto
4+
gitSafeReplacementChar: '-'
5+
branches:
6+
- label : feature
7+
prefix: feature/
8+
name: develop
9+
prTarget: develop
10+
skip: false
11+
- label : bug
12+
prefix: bugfix/
13+
name: develop
14+
prTarget: develop
15+
skip: false
16+
- label : critical
17+
prefix: hotfix/
18+
name: master
19+
prTarget: master
20+
skip: false
21+
- label : '*'
22+
skip: true
23+
24+
25+
prSkipCI: true
26+
copyIssueDescriptionToPR: true
27+
copyIssueLabelsToPR: true
28+
copyIssueAssigneeToPR: true
29+
openDraftPR: true
30+
autoCloseIssue: true
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Create Prerelease
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: 'Update branch version by:'
8+
type: choice
9+
options:
10+
- major
11+
- minor
12+
- patch
13+
required: true
14+
default: 'patch'
15+
is_draft:
16+
description: 'Create a draft of the release:'
17+
type: boolean
18+
required: true
19+
default: false
20+
21+
env:
22+
IS_PRERELEASE: ${{ startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/hotfix/') }}
23+
24+
jobs:
25+
update-version:
26+
runs-on: ubuntu-latest
27+
outputs:
28+
version_tag: ${{ env.version_tag }}
29+
previous_version_tag: ${{ env.previous_version_tag }}
30+
31+
steps:
32+
- name: Check For Main
33+
if: env.IS_PRERELEASE == false
34+
run: |
35+
echo "This workflow should not be triggered on the main branch, please use development or hotfix"
36+
exit 1
37+
38+
- name: Checkout Code
39+
uses: actions/checkout@v4
40+
41+
- name: Run Update Version
42+
id: set_version
43+
shell: pwsh
44+
run: |
45+
Import-Module ./solution-helper.psm1 -Force
46+
$previousVersion, $newVersion = Update-Version -type ${{ github.event.inputs.version_type }}
47+
echo "version_tag=$newVersion" | Out-File -FilePath $env:GITHUB_ENV -Append
48+
echo "previous_version_tag=$previousVersion" | Out-File -FilePath $env:GITHUB_ENV -Append
49+
50+
- name: Check for Existing Release
51+
run: |
52+
# Fetch the list of releases
53+
releases=$(gh release list --json createdAt,tagName --limit 100)
54+
55+
echo -e "$releases"
56+
57+
# Sort the releases by date and extract the most recent one that matches the version or version-prerelease
58+
release_line=$(echo "$releases" | jq -r 'sort_by(.createdAt) | reverse | .[0] | select(.tagName | test("-prerelease$")) | .tagName')
59+
60+
echo -e "$release_line"
61+
62+
# Check if the version or version-prerelease already exists
63+
if [[ -n "$release_line" ]]; then
64+
echo "⛔ Prerelease for '$previous_version_tag' already exists, please remove the release or fix the version."
65+
echo -e " - Failed on version: '$release_line'"
66+
exit 1
67+
else
68+
echo "✅ $previous_version_tag-prerelease does not exist"
69+
fi
70+
env:
71+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
73+
- name: Update Version Number
74+
run: |
75+
git config --global user.name 'github-actions'
76+
git config --global user.email '[email protected]'
77+
git commit -am "Previous version was '${{ env.previous_version_tag }}'. Version now '${{ env.version_tag }}'."
78+
git push
79+
80+
create-release:
81+
needs: update-version
82+
runs-on: ubuntu-latest
83+
84+
steps:
85+
- name: Checkout Code
86+
uses: actions/checkout@v4
87+
88+
- name: Create Release
89+
run: |
90+
TAG_NAME="${{ needs.update-version.outputs.version_tag }}-prerelease"
91+
if [[ ${{ github.event.inputs.is_draft }} ]]; then
92+
gh release create $TAG_NAME --target ${{ github.ref_name }} --title $TAG_NAME --generate-notes --draft --prerelease
93+
else
94+
gh release create $TAG_NAME --target ${{ github.ref_name }} --title $TAG_NAME --generate-notes --prerelease
95+
fi
96+
env:
97+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
is_draft:
7+
description: 'Create a draft of the release:'
8+
type: boolean
9+
required: true
10+
default: false
11+
12+
jobs:
13+
create-release:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Fail if branch is not main
18+
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main'
19+
run: |
20+
echo "This workflow should not be triggered with workflow_dispatch on a branch other than main"
21+
exit 1
22+
23+
- name: Checkout Code
24+
uses: actions/checkout@v4
25+
26+
- name: Get Current Version
27+
id: get_version
28+
shell: pwsh
29+
run: |
30+
Import-Module ./solution-helper.psm1 -Force
31+
$version = Get-Version
32+
echo "version_tag=$version" | Out-File -FilePath $env:GITHUB_ENV -Append
33+
34+
- name: Create Release
35+
run: |
36+
if [[ ${{ github.event.inputs.is_draft }} ]]; then
37+
gh release create ${{ env.version_tag }} --target ${{ github.ref_name }} --title ${{ env.version_tag }} --generate-notes --draft --latest
38+
else
39+
gh release create ${{ env.version_tag }} --target ${{ github.ref_name }} --title ${{ env.version_tag }} --generate-notes --latest
40+
fi
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/issue-branch.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Create Issue Branch
2+
3+
on:
4+
# The issue.opened event below is only needed for the "immediate" mode.
5+
# The issue.assigned event below is only needed for the default ("auto") mode.
6+
issues:
7+
types: [ opened, assigned ]
8+
# The issue_comment.created event below is only needed for the ChatOps mode.
9+
issue_comment:
10+
types: [ created ]
11+
# The pull_request events below are only needed for pull-request related features.
12+
pull_request:
13+
types: [ opened, closed ]
14+
15+
jobs:
16+
create_issue_branch_job:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Create Issue Branch
20+
id: Create_Issue_Branch
21+
uses: robvanderleek/create-issue-branch@main
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
BRANCH_NAME: ${{ github.event.release.target_commitish }}
9+
SOLUTION_NAME: ${{ vars.SOLUTION_NAME }}
10+
PROJECT_NAME: ${{ vars.PROJECT_NAME }}
11+
DOTNET_VERSION: '8.0.x'
12+
NUGET_SOURCE: 'https://api.nuget.org/v3/index.json'
13+
BUILD_CONFIGURATION: ''
14+
VERSION_SUFFIX: ''
15+
16+
jobs:
17+
build-publish:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Release Configuration
22+
if: ${{ env.BRANCH_NAME == 'main' && github.event.release.prerelease == false }}
23+
run: |
24+
echo "BUILD_CONFIGURATION=Release" >> $GITHUB_ENV
25+
echo "VERSION_SUFFIX=" >> $GITHUB_ENV
26+
27+
- name: Debug Configuration
28+
if: ${{ github.event.release.prerelease }}
29+
run: |
30+
echo "BUILD_CONFIGURATION=Debug" >> $GITHUB_ENV
31+
echo "VERSION_SUFFIX=develop.$(date +'%y%m%d%H%M%S')" >> $GITHUB_ENV
32+
33+
- name: Check Build Configuration
34+
if: ${{ env.BUILD_CONFIGURATION == '' }}
35+
run: |
36+
echo "Invalid Build Configuration"
37+
exit 1
38+
39+
- name: Checkout Code
40+
uses: actions/checkout@v4
41+
42+
- name: Setup .NET
43+
uses: actions/setup-dotnet@v1
44+
with:
45+
dotnet-version: ${{ env.DOTNET_VERSION }}
46+
47+
- name: Restore Dependencies
48+
run: dotnet restore ${{ env.SOLUTION_NAME }}
49+
50+
- name: Build
51+
run: dotnet build --no-restore --configuration ${{ env.BUILD_CONFIGURATION }} ${{ env.SOLUTION_NAME }}
52+
53+
- name: Test
54+
run: dotnet test --no-build --verbosity normal --configuration ${{ env.BUILD_CONFIGURATION }} ${{ env.SOLUTION_NAME }}
55+
56+
- name: Publish
57+
run: dotnet publish --no-build --configuration ${{ env.BUILD_CONFIGURATION }} -o ./publish ./src/${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj
58+
59+
- name: Pack and Push
60+
run: dotnet pack --no-build --configuration ${{ env.BUILD_CONFIGURATION }} -p:PackageOutputPath=../../output --version-suffix "${{ env.VERSION_SUFFIX }}" -p:PackageSource='${{ env.NUGET_SOURCE }}' -p:PushAfterPack=true -p:PackageApiKey='${{ secrets.NUGET_API_KEY }}'

.github/workflows/test-report.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test Report
2+
run-name: Generate Test Report for workflow ${{ github.event.workflow_run.name }} run ${{ github.event.workflow_run.run_number }} branch ${{ github.event.workflow_run.head_branch }}
3+
4+
# https://github.com/dorny/test-reporter#recommended-setup-for-public-repositories
5+
# This workflow is for test report
6+
7+
on:
8+
workflow_run:
9+
workflows: [ "Test" ]
10+
types:
11+
- completed
12+
13+
permissions:
14+
contents: read
15+
actions: read
16+
checks: write
17+
18+
jobs:
19+
report:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Test Report 🧪
23+
uses: dorny/test-reporter@v1
24+
with:
25+
artifact: test-results
26+
name: Unit Tests
27+
path: "*.trx"
28+
reporter: dotnet-trx
29+
fail-on-error: false

.github/workflows/test.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Test
2+
3+
on:
4+
workflow_run:
5+
workflows:
6+
- Create Prerelease
7+
- Create Release
8+
# - Publish
9+
types: [requested]
10+
workflow_dispatch:
11+
pull_request:
12+
types: [opened,edited,synchronize,reopened]
13+
branches:
14+
- main
15+
- develop
16+
17+
env:
18+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
19+
SOLUTION_NAME: ${{ vars.SOLUTION_NAME }}
20+
DOTNET_VERSION: '8.0.x'
21+
22+
jobs:
23+
test:
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Release Configuration
28+
if: ${{ env.BRANCH_NAME == 'main' }}
29+
run: |
30+
echo "BUILD_CONFIGURATION=Release" >> $GITHUB_ENV
31+
32+
- name: Debug Configuration
33+
if: ${{ env.BRANCH_NAME != 'main' }}
34+
run: |
35+
echo "BUILD_CONFIGURATION=Debug" >> $GITHUB_ENV
36+
37+
- name: Checkout Code
38+
uses: actions/checkout@v4
39+
40+
- name: Setup .NET
41+
uses: actions/setup-dotnet@v3
42+
with:
43+
dotnet-version: ${{ env.DOTNET_VERSION }}
44+
45+
- name: Restore Dependencies
46+
run: dotnet restore ${{ env.SOLUTION_NAME }}
47+
48+
- name: Build
49+
run: dotnet build --no-restore --configuration ${{ env.BUILD_CONFIGURATION }} ${{ env.SOLUTION_NAME }}
50+
51+
- name: Tests
52+
run: |
53+
dotnet test --no-build --configuration ${{ env.BUILD_CONFIGURATION }} --logger:trx --results-directory:./TestResults ${{ env.SOLUTION_NAME }}
54+
55+
- name: Upload Test Results
56+
uses: actions/upload-artifact@v3 # upload test results
57+
if: success() || failure() # run this step even if previous step failed
58+
with:
59+
name: test-results
60+
path: ./TestResults/**/*.trx
61+

.github/workflows/unlist-nuget.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Unlist NuGet
2+
3+
on:
4+
workflow_dispatch:
5+
# release:
6+
# types: [deleted]
7+
8+
env:
9+
BRANCH_NAME: ${{ github.event.release.target_commitish }}
10+
PROJECT_NAME: ${{ vars.PROJECT_NAME }}
11+
12+
jobs:
13+
publish:
14+
name: unlist on nuget
15+
runs-on: windows-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
# Unlist
21+
- name: Unlist Deleted Tag
22+
uses: darenm/unlist-nuget@v1
23+
with:
24+
NUGET_PACKAGE: ${{ env.PROJECT_NAME }} # Full Package ID
25+
VERSION_REGEX: ${{ github.event.release.tag_name }} # Regex pattern to match version
26+
NUGET_KEY: ${{ secrets.NUGET_API_KEY }} # nuget.org API key

0 commit comments

Comments
 (0)