-
Notifications
You must be signed in to change notification settings - Fork 2
99 lines (85 loc) · 3.67 KB
/
publish.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Publish .NET nuget and create release
on:
push:
branches: [ "main" ]
jobs:
before_publish:
runs-on: ubuntu-latest
outputs:
pr-labels: ${{ steps.pr-labels.outputs.result }}
steps:
# This is getting all the labels sets on the PR
- name: Get PR labels
id: pr-labels
uses: shioyang/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
labels: '["publish"]'
publish:
runs-on: ubuntu-latest
if: needs.before_publish.outputs.pr-labels == 'true'
needs: before_publish
steps:
# Checkout sources. Depth=0 is for using GitVersion
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.x
# Install and Setup GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: Use GitVersion
# Step id is used as reference for the output values
id: gitversion
uses: gittools/actions/gitversion/execute@v0
# Restore, build and test the project
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal
# Create a nuget Release
- name: Pack the NuGet package
run: dotnet pack ./LegoDimensions --configuration Release --output ./artifacts
- name: Build NFC app
run: |
dotnet publish ./LegoDimensionsReadNfc -r linux-arm -c Release --output ./artifacts --self-contained true -p:PublishSingleFile=true
dotnet publish ./LegoDimensionsReadNfc -r win-x64 -c Release --output ./artifacts --self-contained true -p:PublishSingleFile=true
- name: Build Runner app
run: |
dotnet publish ./LegoDimensionsRunner -r linux-arm -c Release --output ./artifacts --self-contained true -p:PublishSingleFile=true
dotnet publish ./LegoDimensionsRunner -r win-x64 -c Release --output ./artifacts --self-contained true -p:PublishSingleFile=true
# Publish all NuGet packages to NuGet.org
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
# If you retry a failed workflow, already published packages will be skipped without error.
- name: Publish separate tools to NuGet
run: dotnet nuget push ./artifacts/LegoDimensions.${{ steps.gitversion.outputs.MajorMinorPatch }}.nupkg --api-key "${{ secrets.NUGET_TOOLS }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
# Create the CHANGELOG for this release
# We'll compile it from last the version
# to the current commit
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v1
with:
configuration: "./changelog-config.json"
fromTag: ${{ steps.gitversion.outputs.VersionSourceSha }}
toTag: ${{ steps.gitversion.outputs.Sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create GitHub release and CHANGELOG for Chocolatey and releases
# NOTE: this is where we prepend "v" before the version in the tag/release
- name: Create release
uses: ncipollo/release-action@v1
with:
# no artifacts: ""
body: ${{steps.github_release.outputs.changelog}}
tag: "v${{ steps.gitversion.outputs.MajorMinorPatch }}"
token: ${{ secrets.GITHUB_TOKEN }}
artifacts: "**/artifacts/*.nupkg,**/artifacts/LegoDimensionsReadNfc,**/artifacts/LegoDimensionsRunner,**/artifacts/*.exe"