-
Notifications
You must be signed in to change notification settings - Fork 13
155 lines (129 loc) · 4.69 KB
/
BuildGitHubRelease.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Build and publish release
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Test
test:
name: Test
runs-on: ubuntu-latest
steps:
# Install .NET SDK
# https://github.com/marketplace/actions/setup-net-core-sdk
- name: Setup .NET SDK 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
# Checkout code
# https://github.com/marketplace/actions/checkout
- name: Checkout code
uses: actions/checkout@v3
# Run Unit Tests
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test
- name: Run unit tests
run: dotnet test ./PlexCleanerTests/PlexCleanerTests.csproj
# Get version information
version:
name: Version
runs-on: ubuntu-latest
needs: test
outputs:
SemVer2: ${{ steps.nbgv.outputs.SemVer2 }}
AssemblyVersion: ${{ steps.nbgv.outputs.AssemblyVersion }}
AssemblyFileVersion: ${{ steps.nbgv.outputs.AssemblyFileVersion }}
AssemblyInformationalVersion: ${{ steps.nbgv.outputs.AssemblyInformationalVersion }}
steps:
# Checkout code
# https://github.com/marketplace/actions/checkout
- name: Checkout
uses: actions/checkout@v3
with:
# Get all history for version calculation
fetch-depth: 0
# Run Nerdbank.GitVersioning
# https://github.com/marketplace/actions/nerdbank-gitversioning
- name: Run Nerdbank.GitVersioning tool
id: nbgv
uses: dotnet/nbgv@master
# Build artifacts
build:
name: Build
runs-on: ubuntu-latest
needs: version
strategy:
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
# https://learn.microsoft.com/en-us/dotnet/core/rid-catalog
matrix:
include:
- runtime: win-x64
- runtime: linux-x64
- runtime: linux-musl-x64
- runtime: linux-arm
- runtime: linux-arm64
- runtime: osx-x64
steps:
# Install .NET SDK
# https://github.com/marketplace/actions/setup-net-core-sdk
- name: Setup .NET SDK 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
# Checkout code
# https://github.com/marketplace/actions/checkout
- name: Checkout code
uses: actions/checkout@v3
# Build and publish
# https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish
- name: Build
run: >-
dotnet publish ./PlexCleaner/PlexCleaner.csproj
--runtime ${{ matrix.runtime }}
--self-contained false
--output ${{ runner.temp }}/publish/${{ matrix.runtime }}
--configuration ${{ endsWith(github.ref, 'refs/heads/main') && 'Release' || 'Debug' }}
-property:Version=${{ needs.version.outputs.AssemblyVersion }}
-property:FileVersion=${{ needs.version.outputs.AssemblyFileVersion }}
-property:AssemblyVersion=${{ needs.version.outputs.AssemblyVersion }}
-property:InformationalVersion=${{ needs.version.outputs.AssemblyInformationalVersion }}
-property:PackageVersion=${{ needs.version.outputs.SemVer2 }}
# https://github.com/marketplace/actions/upload-a-build-artifact
- name: Upload build artifacts
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: publish
path: ${{ runner.temp }}/publish
# Publish
publish:
name: Publish
runs-on: ubuntu-latest
needs: [ build, version ]
if: ${{ github.event_name != 'pull_request' }}
steps:
# https://github.com/marketplace/actions/download-a-build-artifact
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: publish
path: ${{ runner.temp }}/publish
# Zip the output
- name: Zip build output
run: 7z a -t7z ${{ runner.temp }}/publish/PlexCleaner.7z ${{ runner.temp }}/publish/*
# Create GitHub release
# https://github.com/marketplace/actions/automatic-releases
# Alternative: https://github.com/marketplace/actions/gh-release
- name: Create GitHub release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
# Create a tag with the version number
automatic_release_tag: ${{ needs.version.outputs.SemVer2 }}
# Only main branch is not a pre-release
prerelease: ${{ !endsWith(github.ref, 'refs/heads/main') }}
files: ${{ runner.temp }}/publish/PlexCleaner.7z