Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 75 additions & 47 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,86 @@
name: Create Release
name: Prepare Release & Publish Package

on:
workflow_dispatch:
inputs:
is_prerelease:
description: 'Create a prerelease:'
type: boolean
target_branch:
description: "Branch or tag to release from"
type: choice
options: [ main, master, develop ]
default: main
required: true
default: false
is_draft:
description: 'Set as a draft:'
type: boolean
increment:
description: "Version bump"
type: choice
options: [ major, minor, patch ]
default: patch
required: true
default: false

env:
ALLOW_PRERELEASE: ${{ startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/hotfix/') }}

jobs:
create-release:
validate_branch:
runs-on: ubuntu-latest

# Expose the file path to downstream jobs
outputs:
version_json_path: ${{ steps.locate_version.outputs.file }}

steps:
- name: Check For Valid Prerelease
if: ${{ ( env.ALLOW_PRERELEASE == 'true' && github.event.inputs.is_prerelease == 'false' ) || ( github.ref == 'refs/heads/main' && github.event.inputs.is_prerelease == 'true' ) }}
run: |
echo "Prereleases should not be triggered on the main branch, please use development or hotfix"
exit 1

- name: Checkout Code
uses: actions/checkout@v4

- name: Get Current Version
id: get_version
shell: pwsh
run: |
Import-Module ./solution-helper.psm1 -Force
$version = Get-Version
if ("${{ github.event.inputs.is_prerelease }}" -eq "true") {
$version_tag = "$version-develop.$(date +'%y%m%d%H%M%S')"
} else {
$version_tag = $version
}
echo "version_tag=$version_tag" | Out-File -FilePath $env:GITHUB_ENV -Append

- name: Create Release
run: |
echo "🎁 Creating release ${{ env.version_tag }}"
gh release create ${{ env.version_tag }} \
--target ${{ github.ref_name }} \
--title ${{ env.version_tag }} \
--generate-notes \
$(if [[ "${{ github.event.inputs.is_draft }}" == "true" ]]; then echo "--draft"; fi) \
$(if [[ "${{ github.event.inputs.is_prerelease }}" == "true" ]]; then echo "--prerelease"; fi) \
$(if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then echo "--latest"; fi)
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Checkout the branch we’re releasing *from*
- name: Checkout target branch
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: ${{ inputs.target_branch }}

# Optional sanity check (keeps the job obvious when the ref is wrong)
- name: Ensure target branch exists
run: |
if ! git rev-parse --verify --quiet "refs/heads/${{ inputs.target_branch }}"; then
echo "::error::Ref '${{ inputs.target_branch }}' not found."
exit 1
fi

# Find version.json and emit its absolute path
- name: Locate version.json
id: locate_version
shell: bash
run: |
# Search Git-tracked files first …
REL_PATH=$(git ls-files --full-name '*version.json' | head -n1)

# … fall back to a filesystem search for untracked files (optional)
if [[ -z "$REL_PATH" ]]; then
REL_PATH=$(find . -type f -name version.json | head -n1 | sed 's|^\./||')
fi

if [[ -z "$REL_PATH" ]]; then
echo "::error::version.json not found on branch '${{ inputs.target_branch }}'."
tree -L 2 -C || true
exit 1
fi

ABS_PATH="$GITHUB_WORKSPACE/$REL_PATH"
echo "Found version.json at: $ABS_PATH"

# Pass the path to other jobs
echo "file=$ABS_PATH" >> "$GITHUB_OUTPUT"

prepare:
needs: validate_branch
uses: Stillpoint-Software/shared-workflows/.github/workflows/nbgv_prepare_release.yml@main
with:
target_branch: ${{ inputs.target_branch }}
increment: ${{ inputs.increment }}
version_file_path: ${{ needs.validate_branch.outputs.version_json_path }}
secrets: inherit

publish:
needs: prepare
uses: Stillpoint-Software/shared-workflows/.github/workflows/nbgv_dotnet_pack.yml@main
with:
checkout_ref: ${{ needs.prepare.outputs.release_branch }}
build_configuration: ${{ inputs.target_branch == 'develop' && 'Develop' || 'Release' }}
push_after_pack: true
force_dev_prerelease: ${{ inputs.target_branch == 'develop' }}
secrets:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
33 changes: 8 additions & 25 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,18 @@ on:
types: [requested]
workflow_dispatch:
pull_request:
types: [opened,edited,synchronize,reopened]
types: [opened, edited, synchronize, reopened]
branches:
- main
- develop
- main
- develop

env:
DOTNET_VERSION: '9.0.x'

jobs:
format:
runs-on: ubuntu-latest
uses: Stillpoint-Software/shared-workflows/.github/workflows/format.yml@main
with:
dotnet_version: "9.0.x"
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

steps:
- name: Checkout Code
uses: actions/checkout@v4

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

- name: Format
run: dotnet format

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

12 changes: 4 additions & 8 deletions .github/workflows/issue-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ on:
# The issue_comment.created event below is only needed for the ChatOps mode.
issue_comment:
types: [ created ]
# The pull_request events below are only needed for pull-request related features.
# The pull_request events below are only needed for pull-request related features.
pull_request:
types: [ opened, closed ]

jobs:
create_issue_branch_job:
runs-on: ubuntu-latest
steps:
- name: Create Issue Branch
id: Create_Issue_Branch
uses: robvanderleek/create-issue-branch@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: Stillpoint-Software/shared-workflows/.github/workflows/create-issue-branch.yml@main
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83 changes: 0 additions & 83 deletions .github/workflows/publish.yml

This file was deleted.

20 changes: 6 additions & 14 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: Test Report
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 }}

# https://github.com/dorny/test-reporter#recommended-setup-for-public-repositories
# This workflow is for test report

on:
workflow_run:
workflows: [ "Test" ]
types:
types:
- completed

permissions:
Expand All @@ -17,13 +14,8 @@ permissions:

jobs:
report:
runs-on: ubuntu-latest
steps:
- name: Test Report 🧪
uses: dorny/test-reporter@v1
with:
artifact: test-results
name: Unit Tests
path: "*.trx"
reporter: dotnet-trx
fail-on-error: false
uses: Stillpoint-Software/shared-workflows/.github/workflows/test-report.yml@main
with:
artifact_name: "test-results"
test_report_name: "Unit Tests"
path: "*.trx"
55 changes: 9 additions & 46 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,20 @@ on:
workflows:
- Create Prerelease
- Create Release
# - Publish
types: [requested]
workflow_dispatch:
pull_request:
types: [opened,edited,synchronize,reopened]
types: [opened, edited, synchronize, reopened]
branches:
- main
- develop
- main
- develop

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
SOLUTION_NAME: ${{ vars.SOLUTION_NAME }}
DOTNET_VERSION: '9.0.x'

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Release Configuration
if: ${{ env.BRANCH_NAME == 'main' }}
run: |
echo "BUILD_CONFIGURATION=Release" >> $GITHUB_ENV

- name: Debug Configuration
if: ${{ env.BRANCH_NAME != 'main' }}
run: |
echo "BUILD_CONFIGURATION=Debug" >> $GITHUB_ENV

- name: Checkout Code
uses: actions/checkout@v4

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

- name: Restore Dependencies
run: dotnet restore ${{ env.SOLUTION_NAME }}

- name: Build
run: dotnet build --no-restore --configuration ${{ env.BUILD_CONFIGURATION }} ${{ env.SOLUTION_NAME }}

- name: Tests
run: |
dotnet test --no-build --configuration ${{ env.BUILD_CONFIGURATION }} --logger:trx --results-directory:./TestResults ${{ env.SOLUTION_NAME }}

- name: Upload Test Results
uses: actions/upload-artifact@v4 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
name: test-results
path: ./TestResults/**/*.trx
uses: Stillpoint-Software/shared-workflows/.github/workflows/test.yml@main
with:
dotnet_version: "9.0.x"
solution_name: ${{ vars.SOLUTION_NAME }}
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

Loading