Skip to content

Commit c31e176

Browse files
committed
Unify build/publish workflows in a single file
Since the only difference is the publish job.
1 parent d9fd04e commit c31e176

File tree

2 files changed

+43
-46
lines changed

2 files changed

+43
-46
lines changed

.github/workflows/build.yml

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ on:
1414
- readme.md
1515
pull_request:
1616
types: [opened, synchronize, reopened]
17+
release:
18+
types: [released]
1719

1820
env:
1921
DOTNET_NOLOGO: true
@@ -24,13 +26,34 @@ defaults:
2426
shell: bash
2527

2628
jobs:
29+
version:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
version: ${{ steps.release.outputs.version }}
33+
label: ${{ steps.dev.outputs.label }}
34+
steps:
35+
- name: release
36+
id: release
37+
if: github.event_name == 'release'
38+
run: |
39+
echo "version=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT
40+
41+
- name: dev
42+
id: dev
43+
if: github.event_name != 'release'
44+
run: |
45+
echo "label=$GITHUB_REF.$GITHUB_RUN_NUMBER" >> $GITHUB_OUTPUT
2746
2847
build:
2948
name: build-${{ matrix.os }}
49+
needs: version
3050
runs-on: ${{ matrix.os }}
3151
strategy:
3252
matrix:
3353
os: [ 'macOS-latest', 'ubuntu-latest', 'windows-latest' ]
54+
env:
55+
Version: ${{ needs.version.outputs.version }}
56+
VersionLabel: ${{ needs.version.outputs.label }}
3457
steps:
3558
- name: 🤘 checkout
3659
uses: actions/checkout@v2
@@ -39,10 +62,10 @@ jobs:
3962
fetch-depth: 0
4063

4164
- name: 🙏 build
42-
run: dotnet build -m:1 -p:VersionLabel="$GITHUB_REF.$GITHUB_RUN_NUMBER"
65+
run: dotnet build
4366

4467
- name: 📦 pack
45-
run: dotnet pack -m:1 -p:VersionLabel="$GITHUB_REF.$GITHUB_RUN_NUMBER"
68+
run: dotnet pack
4669

4770
- name: ⬆️ upload
4871
# Only upload package from windows (can't run ILRepack on linux/macOS)
@@ -53,12 +76,15 @@ jobs:
5376
path: bin/*
5477

5578
test:
56-
needs: build
79+
needs: [version, build]
5780
name: test-${{ matrix.os }}
5881
runs-on: ${{ matrix.os }}
5982
strategy:
6083
matrix:
6184
os: [ 'macOS-latest', 'ubuntu-latest', 'windows-latest' ]
85+
env:
86+
Version: ${{ needs.version.outputs.version }}
87+
VersionLabel: ${{ needs.version.outputs.label }}
6288
steps:
6389
- name: 🤘 checkout
6490
uses: actions/checkout@v2
@@ -73,7 +99,7 @@ jobs:
7399
path: bin
74100

75101
- name: 🧪 test
76-
run: dotnet test -p:VersionLabel="$GITHUB_REF.$GITHUB_RUN_NUMBER" --nologo -bl -l:"console;verbosity=normal"
102+
run: dotnet test --nologo -bl --logger:"console;verbosity=normal"
77103

78104
- name: 🐛 logs
79105
uses: actions/upload-artifact@v3
@@ -101,6 +127,19 @@ jobs:
101127
dotnet tool install -g --version 4.0.18 sleet
102128
sleet push ./bin/**/*.nupkg --config none -f --verbose -p "SLEET_FEED_CONTAINER=nuget" -p "SLEET_FEED_CONNECTIONSTRING=${{ secrets.SLEET_CONNECTION }}" -p "SLEET_FEED_TYPE=azure" || echo "No packages found"
103129
130+
publish:
131+
needs: test
132+
if: github.event_name == 'release'
133+
runs-on: ubuntu-latest
134+
steps:
135+
- name: ⬇️ artifacts
136+
uses: actions/download-artifact@v3
137+
with:
138+
name: pkg
139+
path: bin
140+
- name: 🚀 nuget
141+
run: dotnet nuget push ./bin/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{secrets.NUGET_API_KEY}} --skip-duplicate
142+
104143
dotnet-format:
105144
runs-on: ubuntu-latest
106145
steps:

.github/workflows/publish.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)