-
Notifications
You must be signed in to change notification settings - Fork 1
77 lines (66 loc) · 2.45 KB
/
Copy pathrelease.yml
File metadata and controls
77 lines (66 loc) · 2.45 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Override package version (e.g. 1.2.3). Leave empty to use the tag.'
required: false
permissions:
contents: write
jobs:
publish:
name: Pack and publish to NuGet
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
10.0.x
- name: Resolve version
id: ver
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ github.event.inputs.version }}" ]; then
echo "version=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
else
ref="${GITHUB_REF#refs/tags/}"
echo "version=${ref#v}" >> "$GITHUB_OUTPUT"
fi
- name: Restore
run: dotnet restore XSpecification.slnx
- name: Build
run: dotnet build XSpecification.slnx -c Release --no-restore -p:Version=${{ steps.ver.outputs.version }}
- name: Test
run: dotnet test XSpecification.slnx -c Release --no-build
- name: Pack
# NOTE: do NOT pass --no-build here. With the .NET 10 SDK,
# `dotnet pack --no-build` on multi-targeting projects
# (net8.0;net10.0) with ProjectReferences triggers
# NETSDK1085 ("'NoBuild' was set to true but the 'Build'
# target was invoked") even though the package is produced.
# See https://github.com/dotnet/fsharp/issues/12320 and
# https://github.com/dotnet/sdk/issues/24943.
run: dotnet pack XSpecification.slnx -c Release -o ./artifacts -p:Version=${{ steps.ver.outputs.version }}
- name: Push to NuGet.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
dotnet nuget push ./artifacts/*.nupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push ./artifacts/*.snupkg --api-key "$NUGET_API_KEY" --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Create GitHub release
uses: softprops/action-gh-release@v3
if: startsWith(github.ref, 'refs/tags/v')
with:
generate_release_notes: true
files: |
./artifacts/*.nupkg
./artifacts/*.snupkg