Skip to content

Commit b1bd339

Browse files
committed
refactor the release-nuget action workflow
#8
1 parent 057b068 commit b1bd339

2 files changed

Lines changed: 67 additions & 71 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: release-nuget
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
rel_version:
7+
description: 'Release version (e.g., 1.9.0-rc.1, 1.9.1)'
8+
required: true
9+
type: string
10+
11+
env:
12+
DOTNET_VERSION: '9.0.x'
13+
PACKAGE_OUTPUT_PATH: src/
14+
BRANCH_NAME: release-${{ inputs.rel_version }}
15+
PACKAGE_VERSION: ${{ inputs.rel_version }}
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v2
24+
with:
25+
fetch-depth: 0 # Needed for GitVersion or full history
26+
27+
- name: Create release branch
28+
uses: peterjgrainger/action-create-branch@v2.2.0
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
31+
with:
32+
branch: ${{ env.BRANCH_NAME }}
33+
sha: ${{ github.sha }}
34+
35+
- name: Setup .NET SDK
36+
uses: actions/setup-dotnet@v3.2.0
37+
with:
38+
dotnet-version: ${{ env.DOTNET_VERSION }}
39+
40+
- name: Build project
41+
run: dotnet build --configuration Release /p:Version=${{ env.PACKAGE_VERSION }}
42+
43+
- name: Run tests
44+
run: dotnet test --configuration Release /p:Version=${{ env.PACKAGE_VERSION }} --no-build
45+
46+
- name: Create NuGet package
47+
run: dotnet pack --configuration Release /p:Version=${{ env.PACKAGE_VERSION }} --no-build
48+
49+
- name: Upload NuGet package artifact
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: nugetPackage
53+
path: ${{ env.PACKAGE_OUTPUT_PATH }}
54+
55+
release:
56+
runs-on: ubuntu-latest
57+
needs: build
58+
if: github.ref == 'refs/heads/master'
59+
60+
steps:
61+
- name: Download NuGet package artifact
62+
uses: actions/download-artifact@v4
63+
with:
64+
name: nugetPackage
65+
66+
- name: Push package to NuGet.org
67+
run: dotnet nuget push **/*.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json

.github/workflows/release.yml

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)