Skip to content

Commit 7fdc68f

Browse files
workflow updated
1 parent e31d8a6 commit 7fdc68f

File tree

1 file changed

+58
-31
lines changed

1 file changed

+58
-31
lines changed
Lines changed: 58 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
name: Build & Publish Release
22

33
on:
4-
# only when you push a *git tag* like “v1.2.3”
54
push:
65
tags:
76
- 'v*'
87
workflow_dispatch:
98

10-
# grant write access so create-release/upload-release-asset can actually do its job
119
permissions:
1210
contents: write
1311

1412
jobs:
15-
release:
16-
# matrix: build on Ubuntu and Windows
13+
build:
1714
runs-on: ${{ matrix.os }}
1815
strategy:
1916
matrix:
@@ -30,55 +27,85 @@ jobs:
3027
- name: Setup .NET SDK
3128
uses: actions/setup-dotnet@v3
3229
with:
33-
dotnet-version: '8.0.x' # or your target SDK
30+
dotnet-version: '8.0.x'
3431

3532
- name: Restore dependencies
3633
run: dotnet restore
3734

3835
- 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 }}
4043

4144
- 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
4851
49-
- name: Zip artifact (Linux)
50-
if: runner.os == 'Linux'
52+
- name: Zip artifact
5153
run: |
5254
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
5460
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
6184

6285
- name: Create GitHub Release
6386
id: create_release
64-
if: startsWith(github.ref, 'refs/tags/') # ← only on tags
6587
uses: actions/create-release@v1
6688
env:
6789
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6890
with:
69-
tag_name: ${{ github.ref_name }}
91+
tag_name: ${{ github.ref_name }}
7092
release_name: Release ${{ github.ref_name }}
7193
body_path: CHANGELOG.md
7294
draft: false
7395
prerelease: false
7496

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
77106
uses: actions/upload-release-asset@v1
78-
env:
79-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80107
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

Comments
 (0)