forked from imazen/imageflow-server
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (120 loc) · 4.86 KB
/
dotnet-core.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
name: Build
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- name: ubuntu-20.04
os: ubuntu-20.04
uploader: true
cache_dependencies: true
- name: osx_11.0-x86_64
os: macos-11.0
cache_dependencies: true
- name: win-x86_64
os: windows-latest
cache_dependencies: false
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-breaker3-${{ hashFiles('**/packages.lock.json') }}
if: matrix.cache_dependencies
- uses: nowsprinting/check-version-format-action@v3
id: version
with:
prefix: 'v'
- name: Upload planned for Nuget.org?
run: echo "This runner will upload to Nuget.org if tests pass"
if: matrix.uploader && github.event_name == 'release' && steps.version.outputs.is_valid == 'true'
- name: Set the release version (if applicable)
run: |
echo "TAGGED_VERSION=${{ steps.version.outputs.full_without_prefix }}" >> $GITHUB_ENV
echo "ARTIFACT_VERSION=${{ steps.version.outputs.full_without_prefix }}" >> $GITHUB_ENV
echo Set version to ${{ steps.version.outputs.full_without_prefix }}
shell: bash
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
# If ARTIFACT_VERSION is empty, then we're not on a release, so we'll use the commit hash
- name: Set the artifact version if not a release
run: |
echo "ARTIFACT_VERSION=commit-${{ github.sha }}" >> $GITHUB_ENV
echo Set ARTIFACT_VERSION to commit-${{ github.sha }}
shell: bash
if: steps.version.outputs.is_valid == 'false' || github.event_name != 'release'
- name: Set the Imageflow.Server.Host zip file name
run: |
echo "HOST_ZIP_FILE=Imageflow.Server.Host-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}.zip" >> $GITHUB_ENV
echo Set HOST_ZIP_FILE to ${{ env.HOST_ZIP_FILE }}
shell: bash
- name: Check .NET versions available to see if we can skip install
shell: bash
run: |
echo "DOTNET_VERSION_LIST<<EOF" >> $GITHUB_ENV
dotnet --list-sdks >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Setup .NET 6.0.x and 7.0.x
uses: actions/setup-dotnet@v2
if: contains(env.DOTNET_VERSION_LIST, '6.0') == 'false' || contains(env.DOTNET_VERSION_LIST, '7.0.') == 'false'
with:
dotnet-version: |
6
7
- name: Clear & clean on release or cache miss
run: |
dotnet clean --configuration Release
dotnet nuget locals all --clear
if: steps.cache.outputs.cache-hit != 'true' || github.event_name == 'release'
- name: Restore packages
run: dotnet restore --force-evaluate
- name: Build
run: dotnet build --maxcpucount:1 -c Release
- name: Test
run: dotnet test -c Release --blame --no-build
- uses: actions/upload-artifact@v3
if: failure()
with:
name: TestResults-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}
path: TestResults/
- name: Publish Host App
run: dotnet publish -c Release -o host/publish/ src/Imageflow.Server.Host/Imageflow.Server.Host.csproj
# Zip the contents of folder host/publish/ into host/Imageflow.Server.Host-${{matrix.os}}-${{ env.ARTIFACT_VERSION }}.zip
- name: Zip Server.Host
uses: thedoctor0/[email protected]
with:
type: 'zip'
directory: 'host/publish/'
filename: '../${{env.HOST_ZIP_FILE}}'
path: '.'
# Upload the publish folder for src/Imageflow.Server.Host to the release artifacts
- name: Upload Imageflow.Server.Host to artifacts
uses: actions/upload-artifact@v3
if: success()
with:
name: ${{env.HOST_ZIP_FILE}}
path: host/${{env.HOST_ZIP_FILE}}
# If this is a release, upload it to the github release page using the git
- name: Upload Imageflow.Server.Host to release
uses: Shopify/[email protected]
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release'
with:
name: ${{env.HOST_ZIP_FILE}}
path: host/${{env.HOST_ZIP_FILE}}
repo-token: ${{ secrets.GITHUB_TOKEN }}
content-type: application/zip
- name: Pack
run: dotnet pack -c Release --include-source
- name: Publish NuGet packages to Nuget.org
if: steps.version.outputs.is_valid == 'true' && github.event_name == 'release' && matrix.uploader
run: |
dotnet nuget push bin/Release/*.nupkg --skip-duplicate --api-key ${{ secrets.NUGET_API_KEY }} --source nuget.org