Skip to content

Commit 89b88b5

Browse files
committed
.NET Release Workflow (cross-compatible)
1 parent 6f153ce commit 89b88b5

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

.github/workflows/dotnet_release.yml

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,75 @@ on:
77

88
jobs:
99
build:
10-
runs-on: windows-latest
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
matrix:
14+
os: [windows-latest, ubuntu-latest] # if I add MacOS builds even though I can't test them :skull: -> macos-latest
1115

1216
steps:
17+
# Step 1
1318
- name: Checkout repository
1419
uses: actions/checkout@v2
1520

21+
# Step 2
1622
- name: Setup .NET
1723
uses: actions/setup-dotnet@v2
1824
with:
1925
dotnet-version: '8.0'
2026

27+
# Step 3
2128
- name: Restore dependencies
2229
run: dotnet restore
2330

31+
# Step 4
2432
- name: Build the project
25-
run: dotnet build --configuration Release
33+
run: dotnet build --configuration Release --runtime win-x64 --framework net8.0 -p:Optimize=true
2634

35+
# Step 5
2736
- name: Run tests
2837
run: dotnet test
2938

39+
# Step 6
3040
- name: Publish the project
3141
run: dotnet publish --configuration Release --runtime win-x64 --framework net8.0 -p:Optimize=true --output ./publish
42+
43+
# Step 7
44+
- name: Get version from tag
45+
id: get_version
46+
run: echo "VERSION=$(echo ${GITHUB_REF} | sed 's/refs\/tags\///')" >> $GITHUB_ENV
47+
48+
# Step 8
49+
- name: Create ZIP archives
50+
run: |
51+
if [ $RUNNER_OS == 'Windows' ]; then
52+
cd ./publish
53+
powershell Compress-Archive -Path * -DestinationPath "../WriterSharp_${{ env.VERSION }}.zip"
54+
elif [ $RUNNER_OS == 'Linux' ]; then
55+
cd ./publish
56+
zip -r "../WriterSharp_${{ env.VERSION }}.zip" *
57+
# MacOS down here
58+
#elif [ $RUNNER_OS == 'macOS' ]; then
59+
#cd ./publish
60+
#zip -r "../WriterSharp_${{ env.VERSION }}.zip" *
61+
fi
62+
63+
# Step 9
64+
- name: Create TAR.GZ archives
65+
run: |
66+
if [ $RUNNER_OS == 'Windows' ]; then
67+
cd ./publish
68+
tar -czvf "../WriterSharp_${{ env.VERSION }}.tar.gz" *
69+
elif [ $RUNNER_OS == 'Linux' ]; then
70+
cd ./publish
71+
tar -czvf "../WriterSharp_${{ env.VERSION }}.tar.gz" *
72+
# MacOS down here
73+
#elif [ $RUNNER_OS == 'macOS' ]; then
74+
#cd ./publish
75+
#tar -czvf "../WriterSharp_${{ env.VERSION }}.tar.gz" *
76+
fi # can we talk about how YAML thinks reversing if sounds like ending an if :skull:
3277
78+
# Step 10
3379
- name: Create Release
3480
uses: softprops/action-gh-release@v1
3581

0 commit comments

Comments
 (0)