Skip to content

Commit d5f750b

Browse files
Merge pull request #87 from Stillpoint-Software/develop
Updated versioning strategy
2 parents a4fc225 + 13e182e commit d5f750b

File tree

13 files changed

+147
-575
lines changed

13 files changed

+147
-575
lines changed
Lines changed: 75 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,86 @@
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
16-
17-
env:
18-
ALLOW_PRERELEASE: ${{ startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/hotfix/') }}
1918

2019
jobs:
21-
create-release:
20+
validate_branch:
2221
runs-on: ubuntu-latest
2322

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

.github/workflows/format.yml

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,18 @@ on:
99
types: [requested]
1010
workflow_dispatch:
1111
pull_request:
12-
types: [opened,edited,synchronize,reopened]
12+
types: [opened, edited, synchronize, reopened]
1313
branches:
14-
- main
15-
- develop
14+
- main
15+
- develop
1616

17-
env:
18-
DOTNET_VERSION: '9.0.x'
19-
2017
jobs:
2118
format:
22-
runs-on: ubuntu-latest
19+
uses: Stillpoint-Software/shared-workflows/.github/workflows/format.yml@main
20+
with:
21+
dotnet_version: "9.0.x"
22+
secrets:
23+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
2324

24-
steps:
25-
- name: Checkout Code
26-
uses: actions/checkout@v4
2725

28-
- name: Setup .NET
29-
uses: actions/setup-dotnet@v4
30-
with:
31-
dotnet-version: ${{ env.DOTNET_VERSION }}
32-
33-
- name: Format
34-
run: dotnet format
35-
36-
- name: Update Styles
37-
continue-on-error: true
38-
run: |
39-
git config --global user.name 'github-actions'
40-
git config --global user.email 'github-actions@github.com'
41-
git commit -am "Updated code formatting to match rules in .editorconfig"
42-
git push
4326

.github/workflows/issue-branch.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ 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
jobs:
1616
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 }}
17+
uses: Stillpoint-Software/shared-workflows/.github/workflows/create-issue-branch.yml@main
18+
secrets:
19+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/publish.yml

Lines changed: 0 additions & 83 deletions
This file was deleted.

.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: 9 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,20 @@ on:
55
workflows:
66
- Create Prerelease
77
- Create Release
8-
# - Publish
98
types: [requested]
109
workflow_dispatch:
1110
pull_request:
12-
types: [opened,edited,synchronize,reopened]
11+
types: [opened, edited, synchronize, reopened]
1312
branches:
14-
- main
15-
- develop
13+
- main
14+
- develop
1615

17-
env:
18-
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
19-
SOLUTION_NAME: ${{ vars.SOLUTION_NAME }}
20-
DOTNET_VERSION: '9.0.x'
21-
2216
jobs:
2317
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@v4
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@v4 # 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
18+
uses: Stillpoint-Software/shared-workflows/.github/workflows/test.yml@main
19+
with:
20+
dotnet_version: "9.0.x"
21+
solution_name: ${{ vars.SOLUTION_NAME }}
22+
secrets:
23+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
6124

0 commit comments

Comments
 (0)