Skip to content

Commit 424ac7c

Browse files
Merge pull request #85 from Stillpoint-Software/develop
Develop
2 parents cd50abb + 3647fd5 commit 424ac7c

10 files changed

Lines changed: 144 additions & 289 deletions
Lines changed: 77 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,90 @@
1-
name: Create Release
1+
name: Prepare Release & Publish Package
22

33
on:
44
workflow_dispatch:
55
inputs:
6-
is_prerelease:
7-
description: 'Create a prerelease:'
8-
type: boolean
6+
target_branch:
7+
description: "Branch or tag to release from"
8+
type: choice
9+
options: [ main, master, develop ]
10+
default: main
911
required: true
10-
default: false
11-
is_draft:
12-
description: 'Set as a draft:'
13-
type: boolean
12+
increment:
13+
description: "Version bump"
14+
type: choice
15+
options: [ major, minor, patch ]
16+
default: patch
1417
required: true
15-
default: false
1618

1719
permissions:
18-
contents: write
19-
20-
env:
21-
ALLOW_PRERELEASE: ${{ startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/hotfix/') }}
20+
contents: write
21+
pull-requests: write
22+
packages: write
2223

2324
jobs:
24-
create-release:
25+
validate_branch:
2526
runs-on: ubuntu-latest
2627

28+
29+
outputs:
30+
version_json_path: ${{ steps.locate_version.outputs.file }}
31+
2732
steps:
28-
- name: Check For Valid Prerelease
29-
if: ${{ ( env.ALLOW_PRERELEASE == 'true' && github.event.inputs.is_prerelease == 'false' ) || ( github.ref == 'refs/heads/main' && github.event.inputs.is_prerelease == 'true' ) }}
30-
run: |
31-
echo "Prereleases should not be triggered on the main branch, please use development or hotfix"
32-
exit 1
33-
34-
- name: Checkout Code
35-
uses: actions/checkout@v4
36-
37-
- name: Get Current Version
38-
id: get_version
39-
shell: pwsh
40-
run: |
41-
Import-Module ./solution-helper.psm1 -Force
42-
$version = Get-Version
43-
if ("${{ github.event.inputs.is_prerelease }}" -eq "true") {
44-
$version_tag = "$version-develop.$(date +'%y%m%d%H%M%S')"
45-
} else {
46-
$version_tag = $version
47-
}
48-
echo "version_tag=$version_tag" | Out-File -FilePath $env:GITHUB_ENV -Append
49-
50-
- name: Create Release
51-
run: |
52-
echo "🎁 Creating release ${{ env.version_tag }}"
53-
gh release create ${{ env.version_tag }} \
54-
--target ${{ github.ref_name }} \
55-
--title ${{ env.version_tag }} \
56-
--generate-notes \
57-
$(if [[ "${{ github.event.inputs.is_draft }}" == "true" ]]; then echo "--draft"; fi) \
58-
$(if [[ "${{ github.event.inputs.is_prerelease }}" == "true" ]]; then echo "--prerelease"; fi) \
59-
$(if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then echo "--latest"; fi)
60-
env:
61-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
- name: Checkout target branch
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 1
37+
ref: ${{ inputs.target_branch }}
38+
39+
# Optional sanity check (keeps the job obvious when the ref is wrong)
40+
- name: Ensure target branch exists
41+
run: |
42+
if ! git rev-parse --verify --quiet "refs/heads/${{ inputs.target_branch }}"; then
43+
echo "::error::Ref '${{ inputs.target_branch }}' not found."
44+
exit 1
45+
fi
46+
47+
# Find version.json and emit its absolute path
48+
- name: Locate version.json
49+
id: locate_version
50+
shell: bash
51+
run: |
52+
# Search Git-tracked files first …
53+
REL_PATH=$(git ls-files --full-name '*version.json' | head -n1)
54+
55+
# … fall back to a filesystem search for untracked files (optional)
56+
if [[ -z "$REL_PATH" ]]; then
57+
REL_PATH=$(find . -type f -name version.json | head -n1 | sed 's|^\./||')
58+
fi
59+
60+
if [[ -z "$REL_PATH" ]]; then
61+
echo "::error::version.json not found on branch '${{ inputs.target_branch }}'."
62+
tree -L 2 -C || true
63+
exit 1
64+
fi
65+
66+
ABS_PATH="$GITHUB_WORKSPACE/$REL_PATH"
67+
echo "Found version.json at: $ABS_PATH"
68+
69+
# Pass the path to other jobs
70+
echo "file=$ABS_PATH" >> "$GITHUB_OUTPUT"
71+
72+
prepare:
73+
needs: validate_branch
74+
uses: Stillpoint-Software/shared-workflows/.github/workflows/nbgv_prepare_release.yml@main
75+
with:
76+
target_branch: ${{ inputs.target_branch }}
77+
increment: ${{ inputs.increment }}
78+
version_file_path: ${{ needs.validate_branch.outputs.version_json_path }}
79+
secrets: inherit
80+
81+
publish:
82+
needs: prepare
83+
uses: Stillpoint-Software/shared-workflows/.github/workflows/nbgv_dotnet_pack.yml@main
84+
with:
85+
checkout_ref: ${{ needs.prepare.outputs.release_branch }}
86+
build_configuration: ${{ inputs.target_branch == 'develop' && 'Develop' || 'Release' }}
87+
push_after_pack: true
88+
force_dev_prerelease: ${{ inputs.target_branch == 'develop' }}
89+
secrets:
90+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

.github/workflows/format.yml

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Format
22

3-
on:
3+
on:
44
push:
5-
workflow_run:
6-
workflows:
5+
workflow_run:
6+
workflows:
77
- Create Prerelease
88
- Create Release
99
types: [requested]
@@ -15,31 +15,15 @@ on:
1515
- develop
1616

1717
permissions:
18-
contents: write
19-
20-
env:
21-
DOTNET_VERSION: "9.0.x"
18+
contents: read
2219

2320
jobs:
2421
format:
25-
runs-on: ubuntu-latest
26-
27-
steps:
28-
- name: Checkout Code
29-
uses: actions/checkout@v4
22+
uses: Stillpoint-Software/shared-workflows/.github/workflows/format.yml@main
23+
with:
24+
dotnet_version: "9.0.x"
25+
secrets:
26+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
3027

31-
- name: Setup .NET
32-
uses: actions/setup-dotnet@v4
33-
with:
34-
dotnet-version: ${{ env.DOTNET_VERSION }}
3528

36-
- name: Format
37-
run: dotnet format
3829

39-
- name: Update Styles
40-
continue-on-error: true
41-
run: |
42-
git config --global user.name 'github-actions'
43-
git config --global user.email 'github-actions@github.com'
44-
git commit -am "Updated code formatting to match rules in .editorconfig"
45-
git push

.github/workflows/issue-branch.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,17 @@ on:
88
# The issue_comment.created event below is only needed for the ChatOps mode.
99
issue_comment:
1010
types: [ created ]
11-
# The pull_request events below are only needed for pull-request related features.
11+
# The pull_request events below are only needed for pull-request related features.
1212
pull_request:
1313
types: [ opened, closed ]
1414

1515
permissions:
16-
contents: write
17-
issues: write
16+
contents: read
17+
issues: write
1818
pull-requests: write
1919

2020
jobs:
2121
create_issue_branch_job:
22-
runs-on: ubuntu-latest
23-
steps:
24-
- name: Create Issue Branch
25-
id: Create_Issue_Branch
26-
uses: robvanderleek/create-issue-branch@main
27-
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
uses: Stillpoint-Software/shared-workflows/.github/workflows/create-issue-branch.yml@main
23+
secrets:
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test-report.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
name: Test Report
22
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
63

74
on:
85
workflow_run:
96
workflows: [ "Test" ]
10-
types:
7+
types:
118
- completed
129

1310
permissions:
@@ -17,13 +14,8 @@ permissions:
1714

1815
jobs:
1916
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
17+
uses: Stillpoint-Software/shared-workflows/.github/workflows/test-report.yml@main
18+
with:
19+
artifact_name: "test-results"
20+
test_report_name: "Unit Tests"
21+
path: "*.trx"

.github/workflows/test.yml

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,27 @@
11
name: Test
22

3-
on:
4-
workflow_run:
5-
workflows:
3+
on:
4+
workflow_run:
5+
workflows:
66
- Create Prerelease
77
- Create Release
8-
# - Publish
98
types: [requested]
109
workflow_dispatch:
1110
pull_request:
1211
types: [opened, edited, synchronize, reopened]
1312
branches:
1413
- main
1514
- develop
16-
15+
1716
permissions:
18-
contents: read
19-
actions: read
20-
21-
env:
22-
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
23-
SOLUTION_NAME: ${{ vars.SOLUTION_NAME }}
24-
DOTNET_VERSION: "9.0.x"
17+
contents: read
2518

2619
jobs:
2720
test:
28-
runs-on: ubuntu-latest
29-
30-
steps:
31-
- name: Release Configuration
32-
if: ${{ env.BRANCH_NAME == 'main' }}
33-
run: |
34-
echo "BUILD_CONFIGURATION=Release" >> $GITHUB_ENV
35-
36-
- name: Debug Configuration
37-
if: ${{ env.BRANCH_NAME != 'main' }}
38-
run: |
39-
echo "BUILD_CONFIGURATION=Debug" >> $GITHUB_ENV
40-
41-
- name: Checkout Code
42-
uses: actions/checkout@v4
43-
44-
- name: Setup .NET
45-
uses: actions/setup-dotnet@v4
46-
with:
47-
dotnet-version: ${{ env.DOTNET_VERSION }}
48-
49-
- name: Restore Dependencies
50-
run: dotnet restore ${{ env.SOLUTION_NAME }}
51-
52-
- name: Build
53-
run: dotnet build --no-restore --configuration ${{ env.BUILD_CONFIGURATION }} ${{ env.SOLUTION_NAME }}
54-
55-
- name: Tests
56-
run: |
57-
dotnet test --no-build --configuration ${{ env.BUILD_CONFIGURATION }} --logger:trx --results-directory:./TestResults ${{ env.SOLUTION_NAME }}
21+
uses: Stillpoint-Software/shared-workflows/.github/workflows/test.yml@main
22+
with:
23+
dotnet_version: "9.0.x"
24+
solution_name: ${{ vars.SOLUTION_NAME }}
25+
secrets:
26+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
5827

59-
- name: Upload Test Results
60-
uses: actions/upload-artifact@v4 # upload test results
61-
if: success() || failure() # run this step even if previous step failed
62-
with:
63-
name: test-results
64-
path: ./TestResults/**/*.trx

0 commit comments

Comments
 (0)