Skip to content

Commit 3b3d65f

Browse files
authored
Create build.yml
push to nuget.org on release
1 parent b02f554 commit 3b3d65f

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

.github/workflows/build.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: build and deploy
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
release:
9+
types:
10+
- published
11+
12+
env:
13+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
14+
DOTNET_VERSION: 5.0.100-rc.1.20452.10
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Setup .NET Core
22+
uses: actions/setup-dotnet@v1
23+
with:
24+
dotnet-version: ${{ env.DOTNET_VERSION }}
25+
- name: Install dependencies
26+
run: dotnet restore
27+
- name: Build
28+
run: dotnet build -c Release --no-restore
29+
- name: Test
30+
run: dotnet test --no-restore --verbosity normal
31+
32+
pack:
33+
needs: build
34+
if: github.event_name == 'release'
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v2
38+
- name: Setup .NET Core
39+
uses: actions/setup-dotnet@v1
40+
with:
41+
dotnet-version: ${{ env.DOTNET_VERSION }}
42+
- name: Pack
43+
run: |
44+
arrTag=(${GITHUB_REF//\// })
45+
VERSION="${arrTag[2]}"
46+
echo Version: $VERSION
47+
VERSION="${VERSION//v}"
48+
dotnet pack -c Release -p:PackageVersion=$VERSION src/StringLiteralGenerator
49+
- name: Upload Artifact
50+
- uses: actions/upload-artifact@v2
51+
with:
52+
name: nupkg
53+
path: |
54+
./**/bin/Release/*.nupkg
55+
56+
push:
57+
needs: pack
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v2
62+
- name: Setup .NET Core
63+
uses: actions/setup-dotnet@v1
64+
with:
65+
dotnet-version: ${{ env.DOTNET_VERSION }}
66+
- name: Download Artifact
67+
uses: actions/download-artifact@v1
68+
with:
69+
name: nupkg
70+
- name: Push to nuget.org
71+
run: dotnet nuget push ./nupkg/**/*.* --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key $NugetApiKey

0 commit comments

Comments
 (0)