1- name : Build and Publish Executable
1+ name : Build & Publish Executables
22
33on :
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 : net8.0
15+
816jobs :
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
14-
15- - name : Set up .NET
16- uses : actions/setup-dotnet@v1
17- with :
18- dotnet-version : ' 6.0'
19-
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
22-
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
25-
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
28-
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/
34-
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
43- with :
44- name : PrintZPL-osx-x64
45- path : src/PrintZPL.Host/bin/Release/net6.0/osx-x64/publish/
28+ - name : Checkout repository
29+ uses : actions/checkout@v3
30+
31+ - name : Setup .NET 6 SDK
32+ uses : actions/setup-dotnet@v4
33+ with :
34+ dotnet-version : ' 8.0.x'
35+
36+ - name : Cache NuGet packages
37+ uses : actions/cache@v4
38+ with :
39+ path : ~/.nuget/packages
40+ key : ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
41+ restore-keys : ${{ runner.os }}-nuget-
42+
43+ - name : Restore dependencies
44+ run : dotnet restore "${{ env.PROJECT_PATH }}"
45+
46+ - name : Publish single-file executable (${{ matrix.runtime }})
47+ run : |
48+ dotnet publish "${{ env.PROJECT_PATH }}" \
49+ -c ${{ env.CONFIGURATION }} \
50+ -r ${{ matrix.runtime }} \
51+ --self-contained true \
52+ /p:PublishSingleFile=true \
53+ /p:PublishTrimmed=true \
54+ /p:TrimMode=Link
55+
56+ - name : Zip published output (${{ matrix.runtime }})
57+ run : |
58+ PUBLISH_DIR="src/PrintZPL.Host/bin/${{ env.CONFIGURATION }}/${{ env.FRAMEWORK }}/${{ matrix.runtime }}/publish"
59+ ZIP_NAME="PrintZPL-${{ matrix.runtime }}.zip"
60+ cd "$PUBLISH_DIR"
61+ zip -r "${{ github.workspace }}/$ZIP_NAME" .
62+
63+ - name : Upload artifact for ${{ matrix.runtime }}
64+ uses : actions/upload-artifact@v4
65+ with :
66+ name : PrintZPL-${{ matrix.runtime }}
67+ path : PrintZPL-${{ matrix.runtime }}.zip
0 commit comments