Skip to content

Commit 447a3b0

Browse files
Copilotjaredpar
andauthored
Publish on merge
* Update publish workflow to trigger on merge to main with auto-incremented patch version Agent-Logs-Url: https://github.com/jaredpar/basic-reference-assemblies/sessions/6685f415-fc2d-4fba-9289-91358b1d10b7 Co-authored-by: jaredpar <146967+jaredpar@users.noreply.github.com> * Restore workflow_dispatch trigger with optional version override Agent-Logs-Url: https://github.com/jaredpar/basic-reference-assemblies/sessions/19a39b49-846f-4b2d-a18a-a157074fe47e Co-authored-by: jaredpar <146967+jaredpar@users.noreply.github.com> * Match complog publish pattern: workflow_run + workflow_dispatch triggers Agent-Logs-Url: https://github.com/jaredpar/basic-reference-assemblies/sessions/3a3bd19d-3b24-4a5e-ad3a-9f28d7934700 Co-authored-by: jaredpar <146967+jaredpar@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jaredpar <146967+jaredpar@users.noreply.github.com>
1 parent 550c2ff commit 447a3b0

File tree

1 file changed

+39
-23
lines changed

1 file changed

+39
-23
lines changed

.github/workflows/publish.yml

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,62 @@
11
name: Publish NuGet Packages
2-
on:
2+
on:
33
workflow_dispatch:
44
inputs:
55
version:
6-
description: 'Package Version'
6+
description: 'Package Version'
77
required: true
8-
type: string
98
default: ''
10-
publish:
11-
description: 'Publish Packages'
12-
required: true
13-
type: boolean
14-
default: true
9+
workflow_run:
10+
workflows: ["Code Validation"]
11+
branches: [main]
12+
types: [completed]
1513

1614
jobs:
1715
publish:
1816
name: Publish NuGet
1917
runs-on: ubuntu-latest
18+
if: >-
19+
github.event_name == 'workflow_dispatch' ||
20+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
2021
steps:
21-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Compute Next Version
27+
id: version
28+
run: |
29+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
30+
echo "version=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
31+
else
32+
latest=$(git tag --list 'v*' --sort=-version:refname | head -n 1)
33+
if [ -z "$latest" ]; then
34+
next="1.0.0"
35+
else
36+
version="${latest#v}"
37+
major=$(echo "$version" | cut -d. -f1)
38+
minor=$(echo "$version" | cut -d. -f2)
39+
patch=$(echo "$version" | cut -d. -f3)
40+
next="${major}.${minor}.$((patch + 1))"
41+
fi
42+
echo "version=${next}" >> "$GITHUB_OUTPUT"
43+
fi
44+
2245
- name: Setup .NET
23-
uses: actions/setup-dotnet@v1
46+
uses: actions/setup-dotnet@v4
2447
with:
2548
dotnet-version: 9.0.x
2649

2750
- name: Pack Solution
28-
run: dotnet pack -p:PackageOutputPath="${GITHUB_WORKSPACE}/packages" -p:IncludeSymbols=false -p:RepositoryCommit=${GITHUB_SHA} -p:PackageVersion="${{ github.event.inputs.version }}" -c Release
51+
run: dotnet pack -p:PackageOutputPath="${GITHUB_WORKSPACE}/packages" -p:IncludeSymbols=false -p:RepositoryCommit=${GITHUB_SHA} -p:PackageVersion="${{ steps.version.outputs.version }}" -c Release
2952

3053
- name: Publish NuPkg Files
31-
if: ${{ github.event.inputs.publish }}
3254
run: dotnet nuget push "$GITHUB_WORKSPACE/packages/*.nupkg" -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
3355

3456
- name: Create Tag and Release
35-
if: ${{ github.event.inputs.publish }}
36-
id: create_release
37-
uses: actions/create-release@v1
3857
env:
39-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
with:
41-
tag_name: v${{ github.event.inputs.version }}
42-
release_name: Release v${{ github.event.inputs.version }}
43-
body: |
44-
Create release ${{ github.event.inputs.version }}
45-
draft: false
46-
prerelease: false
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: |
60+
gh release create "v${{ steps.version.outputs.version }}" \
61+
--title "Release v${{ steps.version.outputs.version }}" \
62+
--notes "Create release ${{ steps.version.outputs.version }}"

0 commit comments

Comments
 (0)