1
1
name : Build & Publish Release
2
2
3
3
on :
4
- # only when you push a *git tag* like “v1.2.3”
5
4
push :
6
5
tags :
7
6
- ' v*'
8
7
workflow_dispatch :
9
8
10
- # grant write access so create-release/upload-release-asset can actually do its job
11
9
permissions :
12
10
contents : write
13
11
14
12
jobs :
15
- release :
16
- # matrix: build on Ubuntu and Windows
13
+ build :
17
14
runs-on : ${{ matrix.os }}
18
15
strategy :
19
16
matrix :
@@ -30,55 +27,85 @@ jobs:
30
27
- name : Setup .NET SDK
31
28
uses : actions/setup-dotnet@v3
32
29
with :
33
- dotnet-version : ' 8.0.x' # or your target SDK
30
+ dotnet-version : ' 8.0.x'
34
31
35
32
- name : Restore dependencies
36
33
run : dotnet restore
37
34
38
35
- name : Publish single-file executable
39
- run : dotnet publish SlipperyPete.sln --configuration Release --runtime ${{ matrix.rid }} --self-contained true /p:PublishSingleFile=true /p:PublishTrimmed=true --output artifacts/${{ matrix.rid }}
36
+ run : dotnet publish SlipperyPete.sln \
37
+ --configuration Release \
38
+ --runtime ${{ matrix.rid }} \
39
+ --self-contained true \
40
+ /p:PublishSingleFile=true \
41
+ /p:PublishTrimmed=true \
42
+ --output artifacts/${{ matrix.rid }}
40
43
41
44
- name : Remove PDB files
42
- if : runner.os == 'Linux'
43
- run : find artifacts/ ${{ matrix.rid }} -type f -name '*.pdb' -delete
44
-
45
- - name : Remove PDB files (Windows)
46
- if : runner.os == 'Windows'
47
- run : Remove-Item artifacts\${{ matrix.rid }}\*.pdb -Force
45
+ run : |
46
+ if [[ " ${{ runner.os }}" == "Linux" ]]; then
47
+ find artifacts/${{ matrix.rid }} -type f -name '*.pdb' -delete
48
+ else
49
+ Remove-Item artifacts\${{ matrix.rid }}\*.pdb -Force
50
+ fi
48
51
49
- - name : Zip artifact (Linux)
50
- if : runner.os == 'Linux'
52
+ - name : Zip artifact
51
53
run : |
52
54
cd artifacts
53
- zip -r ${{ matrix.rid }}.zip ${{ matrix.rid }}
55
+ if [[ "${{ runner.os }}" == "Linux" ]]; then
56
+ zip -r ${{ matrix.rid }}.zip ${{ matrix.rid }}
57
+ else
58
+ Compress-Archive -Path ${{ matrix.rid }}\* -DestinationPath ${{ matrix.rid }}.zip
59
+ fi
54
60
55
- - name : Zip artifact (Windows)
56
- if : runner.os == 'Windows'
57
- shell : powershell
58
- run : |
59
- Compress-Archive -Path artifacts\${{ matrix.rid }}\* `
60
- -DestinationPath artifacts\${{ matrix.rid }}.zip
61
+ - name : Upload Build Artifact
62
+ uses : actions/upload-artifact@v3
63
+ with :
64
+ name : ${{ matrix.rid }}
65
+ path : artifacts/${{ matrix.rid }}.zip
66
+
67
+ release :
68
+ needs : build
69
+ runs-on : ubuntu-latest
70
+
71
+ steps :
72
+ - name : Checkout repo
73
+ uses : actions/checkout@v3
74
+
75
+ - name : Download Linux artifact
76
+ uses : actions/download-artifact@v3
77
+ with :
78
+ name : linux-x64
79
+
80
+ - name : Download Windows artifact
81
+ uses : actions/download-artifact@v3
82
+ with :
83
+ name : win-x64
61
84
62
85
- name : Create GitHub Release
63
86
id : create_release
64
- if : startsWith(github.ref, 'refs/tags/') # ← only on tags
65
87
uses : actions/create-release@v1
66
88
env :
67
89
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
68
90
with :
69
- tag_name : ${{ github.ref_name }}
91
+ tag_name : ${{ github.ref_name }}
70
92
release_name : Release ${{ github.ref_name }}
71
93
body_path : CHANGELOG.md
72
94
draft : false
73
95
prerelease : false
74
96
75
- - name : Upload Release Asset
76
- if : startsWith(github.ref, 'refs/tags/')
97
+ - name : Upload Linux Release Asset
98
+ uses : actions/upload-release-asset@v1
99
+ with :
100
+ upload_url : ${{ steps.create_release.outputs.upload_url }}
101
+ asset_path : linux-x64.zip
102
+ asset_name : linux-x64.zip
103
+ asset_content_type : application/zip
104
+
105
+ - name : Upload Windows Release Asset
77
106
uses : actions/upload-release-asset@v1
78
- env :
79
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
80
107
with :
81
- upload_url : ${{ steps.create_release.outputs.upload_url }}
82
- asset_path : ' artifacts/${{ matrix.rid }}. zip'
83
- asset_name : ${{ matrix.rid }}-build .zip
84
- asset_content_type : application/zip
108
+ upload_url : ${{ steps.create_release.outputs.upload_url }}
109
+ asset_path : win-x64. zip
110
+ asset_name : win-x64 .zip
111
+ asset_content_type : application/zip
0 commit comments