@@ -13,10 +13,10 @@ jobs:
13
13
test :
14
14
strategy :
15
15
matrix :
16
- os : [ubuntu-latest, windows-latest, macOS-latest]
17
-
16
+ os : [ubuntu-latest, windows-latest, macos-latest]
18
17
name : Build and test on ${{ matrix.os }}
19
18
runs-on : ${{ matrix.os }}
19
+
20
20
steps :
21
21
- uses : actions/checkout@v2
22
22
@@ -25,14 +25,26 @@ jobs:
25
25
with :
26
26
dotnet-version : ' 5.0.100'
27
27
28
- - name : Test
29
- run : dotnet test -p:CollectCoverage=true
28
+ - name : Build and test
29
+ run : dotnet test -p:CollectCoverage=true -c Debug -o sayit-${{ matrix.os }}-${{ github.sha }}
30
30
31
+ - name : Upload debug artifact
32
+
33
+ with :
34
+ name : sayit-${{ matrix.os }}-${{ github.sha }}
35
+ path : sayit-${{ matrix.os }}-${{ github.sha }}
31
36
32
37
publish :
33
38
needs : test
34
- name : Publish artifacts
35
- runs-on : ubuntu-latest
39
+ strategy :
40
+ matrix :
41
+ config :
42
+ - {os: ubuntu-latest, rid: "linux-x64", id: "linux" }
43
+ - {os: windows-latest, rid: "win-x64", id: "win" }
44
+ - {os: macos-latest, rid: "osx-x64", id: "osx" }
45
+ name : Create draft release on ${{ matrix.config.os }}
46
+ runs-on : ${{ matrix.config.os }}
47
+ if : startsWith(github.ref, 'refs/tags/v')
36
48
37
49
steps :
38
50
- uses : actions/checkout@v2
@@ -42,40 +54,32 @@ jobs:
42
54
with :
43
55
dotnet-version : ' 5.0.100'
44
56
45
- - name : Publish debug artifact
46
- run : |
47
- export SHA=${GITHUB_SHA:0:7}
48
- dotnet publish -c Debug -o ./sayit-dev-$SHA
49
- echo SHA=${GITHUB_SHA:0:7} >> $GITHUB_ENV
57
+ - name : Set version variable (Linux and MacOS)
58
+ if : matrix.config.id != 'win'
59
+ run : echo "VER=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
50
60
51
- - name : Upload debug artifact
52
-
53
- with :
54
- name : sayit-dev-${{ env.SHA }}
55
- path : sayit-dev-${{ env.SHA }}
61
+ - name : Set version variable (Windows)
62
+ if : matrix.config.id == 'win'
63
+ run : echo "VER=$(($env:GITHUB_REF -split '/')[-1] -replace ' ','')" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
56
64
57
- - name : Publish release artifacts
58
- if : startsWith(github.ref, 'refs/tags/v')
65
+ - name : Build release artifacts
59
66
run : |
60
- # Strip git ref prefix from version
61
- VERSION=$(echo " ${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
67
+ dotnet publish -c Release -o sayit-${{ env.VER }}-${{ matrix.config.id }}
68
+ dotnet publish -c Release -r ${{ matrix.config.rid }} -p:PublishSingleFile=true -p:PublishReadyToRun=true -o sayit-${{ env.VER }}-${{ matrix.config.id }}-sc
62
69
63
- dotnet publish -c Release -r win-x64 --self-contained false -o ./sayit-$VERSION-win
64
- dotnet publish -c Release -r linux-x64 --self-contained false -o ./sayit-$VERSION-linux
65
- dotnet publish -c Release -r osx-x64 --self-contained false -o ./sayit-$VERSION-osx
66
- dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -p:PublishReadyToRun=true -o ./sayit-$VERSION-win-sc
67
- dotnet publish -c Release -r linux-x64 -p:PublishSingleFile=true -p:PublishReadyToRun=true -o ./sayit-$VERSION-linux-sc
68
- dotnet publish -c Release -r osx-x64 -p:PublishSingleFile=true -p:PublishReadyToRun=true -o ./sayit-$VERSION-osx-sc
69
-
70
- zip -r sayit-$VERSION-win.zip sayit-$VERSION-win
71
- zip -r sayit-$VERSION-linux.zip sayit-$VERSION-linux
72
- zip -r sayit-$VERSION-osx.zip sayit-$VERSION-osx
73
- zip -r sayit-$VERSION-win-sc.zip sayit-$VERSION-win-sc
74
- zip -r sayit-$VERSION-linux-sc.zip sayit-$VERSION-linux-sc
75
- zip -r sayit-$VERSION-osx-sc.zip sayit-$VERSION-osx-sc
70
+ - name : Zip artifacts (Linux and MacOS)
71
+ if : matrix.config.id != 'win'
72
+ run : |
73
+ zip -r sayit-${{ env.VER }}-${{ matrix.config.id }}.zip sayit-${{ env.VER }}-${{ matrix.config.id }}
74
+ zip -r sayit-${{ env.VER }}-${{ matrix.config.id }}-sc.zip sayit-${{ env.VER }}-${{ matrix.config.id }}-sc
75
+
76
+ - name : Zip artifacts (Windows)
77
+ if : matrix.config.id == 'win'
78
+ run : |
79
+ Compress-Archive -Path sayit-${{ env.VER }}-${{ matrix.config.id }} -DestinationPath sayit-${{ env.VER }}-${{ matrix.config.id }}.zip
80
+ Compress-Archive -Path sayit-${{ env.VER }}-${{ matrix.config.id }}-sc -DestinationPath sayit-${{ env.VER }}-${{ matrix.config.id }}-sc.zip
76
81
77
82
- name : Create draft release
78
- if : startsWith(github.ref, 'refs/tags/v')
79
83
uses : softprops/action-gh-release@v1
80
84
with :
81
85
draft : true
0 commit comments