Forge
yamlc88715b7
1name publish
2
3on
4 push:
5 tags:
6 - "v*"
7 - PublishFixedTarget/v*
8 - TomlCheck/v*
9 workflow_dispatch:
10 inputs:
11 package:
12 description: Tool package folder name
13 required: true
14 type: choice
15 options:
16 - PublishFixedTarget
17 - TomlCheck
18 version:
19 description: SemVer (e.g. 0.1.0)
20 required: true
21 type: string
22
23permissions
24 contents: read
25
26jobs
27 pack-and-publish:
28 runs-on: ubuntu-latest
29 permissions:
30 contents: read
31 id-token: write
32 steps:
33 - uses: actions/checkout@v6
34
35 - uses: actions/setup-dotnet@v5
36 with:
37 dotnet-version: 10.0.x
38
39 - name: Resolve package and version
40 id: meta
41 shell: bash
42 run: |
43 set -euo pipefail
44 if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
45 PKG="${{ inputs.package }}"
46 VER="${{ inputs.version }}"
47 else
48 REF="${GITHUB_REF#refs/tags/}"
49 if [[ "$REF" == */* ]]; then
50 PKG="${REF%%/*}"
51 VER="${REF#*/}"
52 VER="${VER#v}"
53 else
54 PKG="PublishFixedTarget"
55 VER="${REF#v}"
56 fi
57 fi
58 case "$PKG" in
59 PublishFixedTarget)
60 PROJECT="AIGuiders.DotnetTools.PublishFixedTarget/AIGuiders.DotnetTools.PublishFixedTarget.csproj"
61 ;;
62 TomlCheck)
63 PROJECT="AIGuiders.DotnetTools.TomlCheck/AIGuiders.DotnetTools.TomlCheck.csproj"
64 ;;
65 *)
66 echo "Unknown tag prefix: $PKG" >&2
67 exit 1
68 ;;
69 esac
70 echo "package=$PKG" >> "$GITHUB_OUTPUT"
71 echo "version=$VER" >> "$GITHUB_OUTPUT"
72 echo "project=$PROJECT" >> "$GITHUB_OUTPUT"
73 echo "Publishing $PKG v$VER"
74
75 - name: NuGet login (OIDC)
76 uses: NuGet/login@v1
77 id: login
78 with:
79 user: LonelySoul
80
81 - name: Pack
82 run: |
83 dotnet pack "${{ steps.meta.outputs.project }}" \
84 -c Release \
85 -o ./artifacts \
86 /p:PackageVersion=${{ steps.meta.outputs.version }} \
87 /p:Version=${{ steps.meta.outputs.version }}
88
89 - name: Push to nuget.org
90 run: |
91 dotnet nuget push artifacts/*.nupkg \
92 --source https://api.nuget.org/v3/index.json \
93 --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" \
94 --skip-duplicate
95
View only · write via MCP/CIDE