Skip to content

Commit 06e4f13

Browse files
committed
add auto release
1 parent 8c39708 commit 06e4f13

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/release.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
environment: deployment
12+
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Get tag
16+
id: vars
17+
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
18+
- name: Setup .NET Core SDK
19+
uses: actions/setup-dotnet@v2
20+
with:
21+
dotnet-version: |
22+
3.1.x
23+
5.0.x
24+
6.0.x
25+
- name: Restore cache
26+
uses: actions/cache@v3
27+
with:
28+
path: ~/.nuget/packages
29+
# Look to see if there is a cache hit for the corresponding requirements file
30+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
31+
restore-keys: |
32+
${{ runner.os }}-nuget
33+
- name: Pack
34+
run: dotnet pack
35+
36+
- name: Publish
37+
run: dotnet nuget push **/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
38+
39+
- name: Create release
40+
run: |
41+
curl \
42+
-X POST \
43+
-H "Authorization: token $GITHUB_TOKEN" \
44+
https://api.github.com/repos/${{github.repository}}/releases \
45+
-d '{"tag_name": "${{ env.RELEASE_VERSION }}", "name": "${{ env.RELEASE_VERSION }}", "body": "Release of version ${{ env.RELEASE_VERSION }}", "draft": false, "prerelease": false, "generate_release_notes": true}'
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}

0 commit comments

Comments
 (0)