-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (73 loc) · 2.98 KB
/
Release-Applications.yml
File metadata and controls
91 lines (73 loc) · 2.98 KB
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
name: Release Applications
on:
push:
tags:
- "v*"
env:
# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNETVERSION: "6.0.x"
PACK_OUTPUT_DIR: "NuGetPackageStagingArea"
jobs:
Build_and_Publish:
name: Build, Test, Publish NuGet Packages
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v2
- name: Setup NuGet Cache
uses: actions/cache@v2
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-v0-${{ hashFiles('**/*.csproj') }}
- name: Setup .NET Core SDK ${{ env.DOTNETVERSION }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNETVERSION }}
# Those projects are only needed at development time and NET48 can't build on Linux.
- name: Remove development project from solution
run: dotnet sln PDFinch.Client.sln remove TestClients/PDFinch.TestClient.NET48 TestClients/PDFinch.TestClient.NET50 TestClients/PDFinch.TestClient.Shared
# Versioning: semver
- name: Get version
id: battila7Version
uses: battila7/get-version-action@v2.3.0
- name: Get SHA
uses: benjlevesque/short-sha@v1.2
id: benShortSha
with:
length: 7
# Package version: "v0.7.0-beta07", "v1.0.0" and so on.
- name: Set Package Version
run: echo "PACKAGE_VERSION=${{ steps.battila7Version.outputs.version-without-v }}" >> $GITHUB_ENV
# Assembly version: "v1.0.2-alpha03+4acdfc0" or "v1.0.2+abc1234".
- name: Set Assembly Version
run: echo "ASSEMBLY_VERSION=${{ env.PACKAGE_VERSION }}+${{ steps.benShortSha.outputs.sha }}" >> $GITHUB_ENV
# Restore, build, test...
- name: Restore dependencies
run: dotnet restore
- name: Build Release
run: dotnet build --configuration Release --no-restore -p:Version=$ASSEMBLY_VERSION
- name: Run Unit Tests
run: dotnet test --configuration Release --no-build --verbosity normal
# Pack the build output
- name: Pack NuGet packages
uses: EasyDesk/action-dotnet-pack@v1
with:
project-names: |
src/PDFinch.Client.Common
src/PDFinch.Client
src/PDFinch.Client.Extensions
package-version: ${{ env.PACKAGE_VERSION }}
output-dir: ${{ env.PACK_OUTPUT_DIR }}
skip-build: true
# Create release, attach package files
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ env.ASSEMBLY_VERSION }}
generate_release_notes: true
prerelease: ${{ steps.battila7Version.outputs.is-prerelease }}
files: ${{ env.PACK_OUTPUT_DIR }}/*.*nupkg
# Release to NuGet!
- name: Release to NuGet.org
run: dotnet nuget push ${{ env.PACK_OUTPUT_DIR }}/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json