-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (52 loc) · 2.09 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
61
62
63
64
name: Main Workflow
on:
push:
pull_request:
jobs:
all:
name: Build, Test, Deploy, Tag
runs-on: ubuntu-latest
steps:
- uses: rlespinasse/[email protected]
- name: Set up dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Check out code
uses: actions/checkout@v3
- name: Build
run: dotnet build -c Release TwoMQTT
- name: Test
run: dotnet test --collect:"XPlat Code Coverage" TwoMQTTTest
- name: Upload coverage
run: bash <(curl -s https://codecov.io/bash)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
- name: Package (Non-Main)
run: dotnet pack -c Debug -o output --version-suffix="${{ env.GITHUB_REF_SLUG }}" TwoMQTT
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
- name: Package (Main)
run: dotnet pack -c Release -o output TwoMQTT
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
- name: Setup outputs for later
id: var
run: |
PACKAGE_FILE=$(ls output/*.nupkg)
BUILD_VERSION=${PACKAGE_FILE/output\/TwoMQTT./}
BUILD_VERSION=${BUILD_VERSION/.nupkg/}
echo "package=$PACKAGE_FILE" >> $GITHUB_OUTPUT
echo "version=$BUILD_VERSION" >> $GITHUB_OUTPUT
if: github.event_name == 'push'
- name: Upload package
run: dotnet nuget push ${{ steps.var.outputs.package }} -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json
if: github.event_name == 'push'
- name: Unlist package
env:
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
run: |
dotnet nuget delete TwoMQTT ${{ steps.var.outputs.version }} --non-interactive -k ${{ secrets.NUGET_TOKEN }} -s https://api.nuget.org/v3/index.json
if: github.event_name == 'push'
- name: Tag and push the git release
run: |
git tag -f ${{ steps.var.outputs.version }}
git push --tags
if: github.event_name == 'push' && github.ref == 'refs/heads/main'