Skip to content

Commit 9283faa

Browse files
committed
CI/CD Pipeline updates
1 parent 1c53260 commit 9283faa

File tree

5 files changed

+166
-18
lines changed

5 files changed

+166
-18
lines changed

.github/workflows/cicd.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@ on:
1010

1111
jobs:
1212
build:
13-
name: "Build and Publish"
13+
name: "Build (.NET ${{ matrix.dotnet-version }})"
1414

1515
runs-on: ubuntu-latest
1616

17+
strategy:
18+
matrix:
19+
dotnet-version: ['6.0.x', '7.0.x', '8.0.x']
20+
1721
steps:
18-
- uses: actions/checkout@v3
19-
22+
- uses: actions/checkout@v4
23+
2024
- name: "Setup .NET Core"
21-
uses: actions/setup-dotnet@v3
25+
uses: actions/setup-dotnet@v4
2226
with:
23-
dotnet-version: 6.0.x
27+
dotnet-version: ${{ matrix.dotnet-version }}
2428

2529
- name: "Restore"
2630
run: dotnet restore
@@ -32,17 +36,17 @@ jobs:
3236
run: dotnet test -c Release --no-restore --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[*.XUnit]*"
3337

3438
- name: Upload coverage reports to Codecov
35-
uses: codecov/codecov-action@v3
39+
uses: codecov/codecov-action@v4
3640
with:
3741
token: ${{ secrets.CODECOV_TOKEN }}
3842

39-
- name: "Pack"
40-
run: dotnet pack -c Release --no-restore --no-build --verbosity normal --include-symbols --include-source --version-suffix $GITHUB_RUN_ID --output ./nuget
41-
42-
- name: "Push Packages to GitHub Nuget"
43-
run: dotnet nuget push ./nuget/*.nupkg --source https://nuget.pkg.github.com/deveel --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
43+
publish:
44+
name: "Publish Packages"
45+
needs: build
46+
if: github.ref == 'refs/heads/main'
47+
uses: ./.github/workflows/publish-packages.yml
4448

4549
clean:
46-
name: Celaning Old Packages
47-
needs: build
50+
name: Cleaning Old Packages
51+
needs: publish
4852
uses: ./.github/workflows/clean-packages.yml

.github/workflows/clean-packages.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,12 @@ jobs:
3333
package-name: 'Deveel.Filter.MongoBson'
3434
package-type: 'nuget'
3535
min-versions-to-keep: 10
36+
delete-only-pre-release-versions: true
37+
38+
- name: Remove Old Deveel.Filter.DynamicLinq Packages
39+
uses: actions/delete-package-versions@v4
40+
with:
41+
package-name: 'Deveel.Filter.DynamicLinq'
42+
package-type: 'nuget'
43+
min-versions-to-keep: 10
3644
delete-only-pre-release-versions: true

.github/workflows/pr-build.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@ on:
1010

1111
jobs:
1212
build:
13-
name: "Build"
13+
name: "Build (.NET ${{ matrix.dotnet-version }})"
1414

1515
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
dotnet-version: ['6.0.x', '7.0.x', '8.0.x']
1620

1721
steps:
18-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
1923

20-
- name: "Setup .NET Core"
21-
uses: actions/setup-dotnet@v3
24+
- name: "Setup .NET ${{ matrix.dotnet-version }}"
25+
uses: actions/setup-dotnet@v4
2226
with:
23-
dotnet-version: 6.0.x
27+
dotnet-version: ${{ matrix.dotnet-version }}
2428

2529
- name: "Restore"
2630
run: dotnet restore
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Publish Packages"
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
publish:
9+
name: "Publish (.NET ${{ matrix.dotnet-version }})"
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: "Setup .NET ${{ matrix.dotnet-version }}"
16+
uses: actions/setup-dotnet@v4
17+
with:
18+
dotnet-version: 8.0.x
19+
20+
- name: "Pack"
21+
run: dotnet pack -c Release --verbosity normal --include-symbols --include-source --version-suffix $GITHUB_RUN_ID --output ./nuget
22+
23+
- name: "Push Packages to GitHub Nuget"
24+
run: dotnet nuget push ./nuget/*.nupkg --source https://nuget.pkg.github.com/deveel --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate

.github/workflows/release.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: "Release"
2+
3+
permissions:
4+
contents: read
5+
packages: write
6+
7+
on:
8+
push:
9+
tags:
10+
- 'v*.*.*' # Triggers on version tags like v1.0.0, v2.1.3, etc.
11+
12+
jobs:
13+
build:
14+
name: "Builds (.NET ${{ matrix.dotnet-version }})"
15+
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
include:
21+
- dotnet-version: '6.0.x'
22+
framework-moniker: 'net6.0'
23+
- dotnet-version: '7.0.x'
24+
framework-moniker: 'net7.0'
25+
- dotnet-version: '8.0.x'
26+
framework-moniker: 'net8.0'
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: "Extract version from tag"
32+
id: extract_version
33+
run: |
34+
# Remove 'v' prefix from tag and extract version
35+
VERSION=${GITHUB_REF#refs/tags/v}
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
echo "Extracted version: $VERSION"
38+
39+
- name: "Setup .NET ${{ matrix.dotnet-version }}"
40+
uses: actions/setup-dotnet@v4
41+
with:
42+
dotnet-version: ${{ matrix.dotnet-version }}
43+
44+
- name: "Restore"
45+
run: dotnet restore
46+
47+
- name: "Build"
48+
run: dotnet build -c Release --no-restore --framework ${{ matrix.framework-moniker }}
49+
50+
- name: "Test"
51+
run: dotnet test -c Release --no-restore --no-build --framework ${{ matrix.framework-moniker }} --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[*.XUnit]*"
52+
53+
- name: Upload coverage reports to Codecov
54+
uses: codecov/codecov-action@v4
55+
with:
56+
token: ${{ secrets.CODECOV_TOKEN }}
57+
58+
publish:
59+
name: "Publish Packages"
60+
needs: build
61+
if: github.ref == 'refs/heads/main'
62+
runs-on: ubuntu-latest
63+
64+
steps:
65+
- uses: actions/checkout@v4
66+
67+
- name: "Setup .NET .NET 8.0"
68+
uses: actions/setup-dotnet@v4
69+
with:
70+
dotnet-version: 8.0.x
71+
72+
- name: "Pack"
73+
run: dotnet pack -c Release --verbosity normal --include-symbols --include-source --version-suffix $GITHUB_RUN_ID --output ./nuget
74+
75+
- name: "Push Packages to GitHub Nuget"
76+
run: dotnet nuget push ./nuget/*.nupkg --source https://nuget.pkg.github.com/deveel --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate
77+
78+
- name: Publish to NuGet
79+
run: dotnet nuget push ./nuget/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate
80+
81+
clean:
82+
name: "Cleaning Old Packages"
83+
needs: publish
84+
uses: ./.github/workflows/publish-packages.yml
85+
86+
create-release:
87+
name: "Create GitHub Release"
88+
needs: publish
89+
runs-on: ubuntu-latest
90+
91+
steps:
92+
- uses: actions/checkout@v4
93+
94+
- name: "Extract version from tag"
95+
id: extract_version
96+
run: |
97+
VERSION=${GITHUB_REF#refs/tags/v}
98+
echo "version=$VERSION" >> $GITHUB_OUTPUT
99+
100+
- name: "Create Release"
101+
uses: actions/create-release@v1
102+
env:
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
with:
105+
tag_name: ${{ github.ref_name }}
106+
release_name: Release ${{ steps.extract_version.outputs.version }}
107+
draft: false
108+
prerelease: false

0 commit comments

Comments
 (0)