-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (65 loc) · 2.26 KB
/
Copy pathrelease.yml
File metadata and controls
76 lines (65 loc) · 2.26 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
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version (e.g., 1.0.0, 1.0.0-beta.1)'
required: true
type: string
draft:
description: 'Create as draft on GitHub?'
required: true
type: boolean
default: false
# Required permissions to write tags and releases
permissions:
contents: write
jobs:
release:
name: Build, Test & Publish
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Important for automatic release notes
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Build project
run: dotnet build --no-restore --configuration Release
- name: Run tests
run: dotnet test --no-build --configuration Release
- name: Create NuGet package
run: |
dotnet pack cslsqp/cslsqp.csproj \
--configuration Release \
--no-build \
-p:Version=${{ github.event.inputs.version }} \
--output artifacts/
- name: Publish 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
- name: Create and push Git tag
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ github.event.inputs.version }}" -m "Release v${{ github.event.inputs.version }}"
git push origin "v${{ github.event.inputs.version }}"
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ github.event.inputs.version }}"
name: "Release v${{ github.event.inputs.version }}"
draft: ${{ github.event.inputs.draft }}
prerelease: ${{ contains(github.event.inputs.version, '-') }}
generate_release_notes: true
files: artifacts/*.nupkg