Skip to content

Commit 39df438

Browse files
authored
update workflows (#145)
1 parent cc1f475 commit 39df438

File tree

2 files changed

+55
-37
lines changed

2 files changed

+55
-37
lines changed

.github/workflows/build.yml

+3-28
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ on:
99

1010
jobs:
1111
build:
12-
name: Build, Test & Pack
12+
name: Build & Test
1313
runs-on: ubuntu-24.04
14+
1415
steps:
1516
- name: Checkout
1617
uses: actions/checkout@v4
17-
with:
18-
fetch-depth: 0
1918

2019
- name: Setup .NET
2120
uses: actions/setup-dotnet@v4
@@ -27,35 +26,11 @@ jobs:
2726
- name: Build
2827
run: dotnet build -c Release -p:ContinuousIntegrationBuild=true
2928

30-
- name: Run tests
29+
- name: Run tests with Coverage
3130
run: dotnet test --no-build -c Release -p:CollectCoverage=true -e:CoverletOutputFormat=opencover
3231

3332
- name: Publish to Codecov
3433
uses: codecov/codecov-action@v5
3534
with:
3635
fail_ci_if_error: true
3736
token: ${{ secrets.CODECOV_TOKEN }}
38-
39-
- name: Set Dev version
40-
if: github.ref == 'refs/heads/main'
41-
run: |
42-
version="$(git describe --long --tags | sed 's/^v//;0,/-/s//./')"
43-
if [ -z "${version}" ]; then
44-
version="0.0.0.$(git rev-list --count HEAD)-g$(git rev-parse --short HEAD)"
45-
fi
46-
echo "VERSION=${version}" >> $GITHUB_ENV
47-
48-
- name: Set Release version
49-
if: startsWith(github.ref, 'refs/tags/v')
50-
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
51-
52-
- name: Pack NuGet artifacts
53-
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
54-
run: dotnet pack --no-build -c Release -p:PackageVersion="${{ env.VERSION }}" -o nupkgs
55-
56-
- name: Upload artifacts
57-
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
58-
uses: actions/upload-artifact@v4
59-
with:
60-
name: nupkgs
61-
path: nupkgs/**/*nupkg

.github/workflows/ci.yml

+52-9
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,52 @@ jobs:
1313
uses: ./.github/workflows/build.yml
1414
secrets: inherit
1515

16+
pack:
17+
name: Create NuGet packages
18+
needs: [build]
19+
runs-on: ubuntu-24.04
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
- name: Set Dev version
26+
if: github.ref == 'refs/heads/main'
27+
run: |
28+
version="$(git describe --long --tags | sed 's/^v//;0,/-/s//./')"
29+
if [ -z "${version}" ]; then
30+
version="0.0.0.$(git rev-list --count HEAD)-g$(git rev-parse --short HEAD)"
31+
fi
32+
echo "VERSION=${version}" >> $GITHUB_ENV
33+
34+
- name: Set Release version
35+
if: startsWith(github.ref, 'refs/tags/v')
36+
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
37+
38+
- name: Pack artifacts
39+
run: dotnet pack -p:PackageVersion="${{ env.VERSION }}" -o packages
40+
41+
- name: Upload artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: packages
45+
path: packages/*nupkg
46+
1647
github:
1748
name: Deploy to GitHub
18-
needs: [build]
49+
needs: [pack]
1950
runs-on: ubuntu-24.04
2051
steps:
2152
- name: Download artifacts
2253
uses: actions/download-artifact@v4
2354
with:
24-
name: nupkgs
55+
name: packages
2556
- name: Push to pkg.github.com
26-
run: dotnet nuget push "**/*.nupkg" -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json -k ${{ secrets.GH_FULL_PAT }} --skip-duplicate
57+
run: dotnet nuget push "*.nupkg" -s https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json -k ${{ secrets.GH_FULL_PAT }} --skip-duplicate
2758

28-
nuget:
29-
name: Deploy to NuGet
30-
needs: [build]
59+
release:
60+
name: Create GitHub release
61+
needs: [pack]
3162
if: startsWith(github.ref, 'refs/tags/v')
3263
runs-on: ubuntu-24.04
3364
steps:
@@ -36,10 +67,22 @@ jobs:
3667
- name: Download artifacts
3768
uses: actions/download-artifact@v4
3869
with:
39-
name: nupkgs
70+
name: packages
71+
path: packages
4072
- name: Create GitHub Release
41-
run: gh release create ${{ github.ref_name }} **/*nupkg
73+
run: gh release create ${{ github.ref_name }} packages/*nupkg
4274
env:
4375
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
77+
nuget:
78+
name: Deploy to NuGet
79+
needs: [release]
80+
if: startsWith(github.ref, 'refs/tags/v')
81+
runs-on: ubuntu-24.04
82+
steps:
83+
- name: Download artifacts
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: packages
4487
- name: Push to nuget.org
45-
run: dotnet nuget push "**/*.nupkg" -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_DEPLOY_KEY }}
88+
run: dotnet nuget push "*.nupkg" -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_DEPLOY_KEY }}

0 commit comments

Comments
 (0)