-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (75 loc) · 2.35 KB
/
release.yml
File metadata and controls
90 lines (75 loc) · 2.35 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
81
82
83
84
85
86
87
88
89
90
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Package version (e.g. 1.0.0, 1.1.0-beta.1)'
required: true
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
env:
# For tag pushes: strip the 'v' prefix (v1.0.0 -> 1.0.0)
# For manual dispatch: use the input directly
PACKAGE_VERSION: ${{ github.event.inputs.version || '' }}
steps:
- uses: actions/checkout@v4
- name: Determine version
run: |
if [ -n "$PACKAGE_VERSION" ]; then
echo "VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
else
TAG="${GITHUB_REF#refs/tags/v}"
echo "VERSION=$TAG" >> $GITHUB_ENV
fi
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release /p:Version=${{ env.VERSION }}
- name: Pack library
run: >
dotnet pack src/SwaggerDiff.AspNetCore/SwaggerDiff.AspNetCore.csproj
--no-build
--configuration Release
/p:Version=${{ env.VERSION }}
--output ./artifacts
- name: Pack CLI tool
run: >
dotnet pack src/SwaggerDiff.Tool/SwaggerDiff.Tool.csproj
--no-build
--configuration Release
/p:Version=${{ env.VERSION }}
--output ./artifacts
- name: Nuget Login (OIDC)
id: login
uses: NuGet/login@v1
with:
user: OluwaVader
- name: Push to NuGet.org
run: >
dotnet nuget push "./artifacts/*.nupkg"
--source https://api.nuget.org/v3/index.json
--skip-duplicate
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}"
- name: Create tag if not exists
if: github.event_name == 'workflow_dispatch'
run: |
git tag "v${{ env.VERSION }}" || true
git push origin "v${{ env.VERSION }}" || true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: "v${{ env.VERSION }}"
generate_release_notes: true
files: ./artifacts/*.nupkg