Skip to content

Commit 45d9a6c

Browse files
authored
Update build.yml
1 parent e2a554f commit 45d9a6c

File tree

1 file changed

+51
-28
lines changed

1 file changed

+51
-28
lines changed

.github/workflows/build.yml

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,68 @@
1-
name: Build and Publish Executable
1+
name: Build & Publish Executables
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches:
6+
- master
7+
tags:
8+
- 'v*.*.*'
69
workflow_dispatch:
710

11+
env:
12+
CONFIGURATION: Release
13+
PROJECT_PATH: src/PrintZPL.Host/PrintZPL.Host.csproj
14+
FRAMEWORK: net6.0
15+
816
jobs:
9-
build:
17+
publish:
1018
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
runtime:
23+
- win-x64
24+
- linux-x64
25+
- osx-x64
1126

1227
steps:
13-
- uses: actions/checkout@v2
28+
- name: Checkout repo
29+
uses: actions/checkout@v3
1430

15-
- name: Set up .NET
16-
uses: actions/setup-dotnet@v1
31+
- name: Setup .NET SDK
32+
uses: actions/setup-dotnet@v3
1733
with:
18-
dotnet-version: '6.0'
34+
dotnet-version: '6.0.x'
1935

20-
- name: Publish Windows Executable
21-
run: dotnet publish ./src/PrintZPL.Host/PrintZPL.Host.csproj -r win-x64 -c Release /p:PublishSingleFile=true --self-contained true
36+
- name: Cache NuGet packages
37+
uses: actions/cache@v3
38+
with:
39+
path: ~/.nuget/packages
40+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
41+
restore-keys: |
42+
${{ runner.os }}-nuget-
2243
23-
- name: Publish Linux Executable
24-
run: dotnet publish ./src/PrintZPL.Host/PrintZPL.Host.csproj -r linux-x64 -c Release /p:PublishSingleFile=true --self-contained true
44+
- name: Restore dependencies
45+
run: dotnet restore ${{ env.PROJECT_PATH }}
2546

26-
- name: Publish macOS Executable
27-
run: dotnet publish ./src/PrintZPL.Host/PrintZPL.Host.csproj -r osx-x64 -c Release /p:PublishSingleFile=true --self-contained true
47+
- name: Publish single-file executable (${ { matrix.runtime } })
48+
run: |
49+
dotnet publish ${{ env.PROJECT_PATH }} \
50+
-c ${{ env.CONFIGURATION }} \
51+
-r ${{ matrix.runtime }} \
52+
--self-contained true \
53+
/p:PublishSingleFile=true \
54+
/p:PublishTrimmed=true \
55+
/p:TrimMode=Link
2856
29-
- name: Upload Windows Executable
30-
uses: actions/upload-artifact@v2
31-
with:
32-
name: PrintZPL-win-x64
33-
path: src/PrintZPL.Host/bin/Release/net6.0/win-x64/publish/
57+
- name: Zip published output (${ { matrix.runtime } })
58+
run: |
59+
RUNTIME_DIR=src/PrintZPL.Host/bin/${{ env.CONFIGURATION }}/${{ env.FRAMEWORK }}/${{ matrix.runtime }}/publish
60+
ZIP_NAME=PrintZPL-${{ matrix.runtime }}.zip
61+
cd $RUNTIME_DIR
62+
zip -r ${{ github.workspace }}/$ZIP_NAME .
3463
35-
- name: Upload Linux Executable
36-
uses: actions/upload-artifact@v2
37-
with:
38-
name: PrintZPL-linux-x64
39-
path: src/PrintZPL.Host/bin/Release/net6.0/linux-x64/publish/
40-
41-
- name: Upload macOS Executable
42-
uses: actions/upload-artifact@v2
64+
- name: Upload artifact for ${{ matrix.runtime }}
65+
uses: actions/upload-artifact@v3
4366
with:
44-
name: PrintZPL-osx-x64
45-
path: src/PrintZPL.Host/bin/Release/net6.0/osx-x64/publish/
67+
name: PrintZPL-${{ matrix.runtime }}
68+
path: PrintZPL-${{ matrix.runtime }}.zip

0 commit comments

Comments
 (0)