-
Notifications
You must be signed in to change notification settings - Fork 2
60 lines (52 loc) · 1.95 KB
/
main.yml
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
name: Build and Publish
on:
push:
pull_request:
branches:
- master
defaults:
run:
working-directory: src/Haukcode.sACN
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get main version
id: version
uses: notiz-dev/github-action-json-property@release
with:
path: version.json
prop_path: 'version'
- name: Get branch name from branch
run: echo "BRANCH_NAME=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }' | sed "s/[[:space:]_]/-/g")" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/heads/')
- name: Get branch name from PR
run: echo "BRANCH_NAME=PR-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/pull/')
- run: echo Version ${BRANCH_NAME}
- run: echo "PACKAGE_VERSION=${{steps.version.outputs.prop}}.${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
if: github.ref == 'refs/heads/master'
- run: echo "PACKAGE_VERSION=${{steps.version.outputs.prop}}.${GITHUB_RUN_NUMBER}-${BRANCH_NAME}-${GITHUB_SHA::8}" >> $GITHUB_ENV
if: github.ref != 'refs/heads/master'
- run: echo Version is ${PACKAGE_VERSION}
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.306
- name: Install dependencies
run: dotnet restore
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
- name: Build
run: dotnet build --configuration Release --no-restore /p:Version="${PACKAGE_VERSION}"
- name: Test
run: dotnet test --no-restore --verbosity normal
## Publish and Tag
- name: Publish NuGet
run: dotnet nuget push bin/Release/*.nupkg --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_KEY }}
- name: Tag
run: |
git tag "v${PACKAGE_VERSION}"
git push origin "v${PACKAGE_VERSION}"
if: github.ref == 'refs/heads/master'