-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (69 loc) · 2.7 KB
/
publish.yml
File metadata and controls
80 lines (69 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: Publish to NuGet.org
# Publishes ANcpLua.OpenTelemetry.Conventions.Nuke (formerly Nuke.OpenTelemetry.Conventions —
# renamed away from the nukebuild-reserved `Nuke.*` prefix on nuget.org).
# Pushes to https://api.nuget.org/v3/index.json using a glob-scoped API key.
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Override package version (semver, e.g. 0.1.0). Leave blank to use the release tag.'
required: false
default: ''
permissions:
contents: read
id-token: write # reserved for future NuGet provenance attestations
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Resolve package version
shell: bash
env:
DISPATCH_VERSION: ${{ inputs.version }}
EVENT_NAME: ${{ github.event_name }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
set -euo pipefail
if [ "$EVENT_NAME" = "workflow_dispatch" ] && [ -n "$DISPATCH_VERSION" ]; then
version="$DISPATCH_VERSION"
elif [ "$EVENT_NAME" = "release" ] && [ -n "$RELEASE_TAG" ]; then
# Strip leading 'v' from tags like 'v0.1.0' → '0.1.0'.
version="${RELEASE_TAG#v}"
else
echo "::error::Cannot resolve package version (no inputs.version and no release tag)."
exit 1
fi
if ! [[ "$version" =~ ^[A-Za-z0-9._+-]+$ ]]; then
echo "::error::Invalid NuGet version: $version (must match ^[A-Za-z0-9._+-]+$)"
exit 1
fi
echo "PKG_VERSION=$version" >> "$GITHUB_ENV"
echo "Resolved version: $version"
- name: Restore
run: dotnet restore ANcpLua.OpenTelemetry.Conventions.Nuke.slnx
- name: Build (Release)
run: dotnet build ANcpLua.OpenTelemetry.Conventions.Nuke.slnx -c Release --no-restore /p:Version=$PKG_VERSION
- name: Pack (Release)
run: |
dotnet pack src/ANcpLua.OpenTelemetry.Conventions.Nuke/ANcpLua.OpenTelemetry.Conventions.Nuke.csproj \
-c Release --no-build \
-o artifacts \
/p:Version=$PKG_VERSION \
/p:ContinuousIntegrationBuild=true
- name: Push .nupkg + .snupkg to nuget.org
env:
NUGET_ORG_API_KEY: ${{ secrets.NUGET_ORG_API_KEY }}
run: |
dotnet nuget push "artifacts/*.nupkg" \
--source https://api.nuget.org/v3/index.json \
--api-key "$NUGET_ORG_API_KEY" \
--skip-duplicate