Skip to content

Commit 6bb16df

Browse files
authored
GitHub Actions: publish draft release from different containers to allow PublishReadyToRun (#67)
1 parent 3d1a43e commit 6bb16df

File tree

1 file changed

+38
-34
lines changed

1 file changed

+38
-34
lines changed

.github/workflows/dotnet.yml

+38-34
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
test:
1414
strategy:
1515
matrix:
16-
os: [ubuntu-latest, windows-latest, macOS-latest]
17-
16+
os: [ubuntu-latest, windows-latest, macos-latest]
1817
name: Build and test on ${{ matrix.os }}
1918
runs-on: ${{ matrix.os }}
19+
2020
steps:
2121
- uses: actions/checkout@v2
2222

@@ -25,14 +25,26 @@ jobs:
2525
with:
2626
dotnet-version: '5.0.100'
2727

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 }}
3030

31+
- name: Upload debug artifact
32+
uses: actions/[email protected]
33+
with:
34+
name: sayit-${{ matrix.os }}-${{ github.sha }}
35+
path: sayit-${{ matrix.os }}-${{ github.sha }}
3136

3237
publish:
3338
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')
3648

3749
steps:
3850
- uses: actions/checkout@v2
@@ -42,40 +54,32 @@ jobs:
4254
with:
4355
dotnet-version: '5.0.100'
4456

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
5060

51-
- name: Upload debug artifact
52-
uses: actions/[email protected]
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
5664

57-
- name: Publish release artifacts
58-
if: startsWith(github.ref, 'refs/tags/v')
65+
- name: Build release artifacts
5966
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
6269
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
7681
7782
- name: Create draft release
78-
if: startsWith(github.ref, 'refs/tags/v')
7983
uses: softprops/action-gh-release@v1
8084
with:
8185
draft: true

0 commit comments

Comments
 (0)