Skip to content

Commit 5683c52

Browse files
authored
Merge pull request #8 from Solcast/test
split cicd
2 parents 931196c + 34f4308 commit 5683c52

File tree

1 file changed

+15
-60
lines changed

1 file changed

+15
-60
lines changed

.github/workflows/build-test-package.yml

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build, Test, and Publish NuGet Package
33
on:
44
push:
55
branches:
6-
- main
6+
- test
77
tags:
88
- 'v*.*.*' # Ensure that NuGet publishing is triggered on version tags like v1.0.0
99

@@ -13,7 +13,7 @@ permissions:
1313

1414
jobs:
1515

16-
build:
16+
build_and_test:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Checkout code
@@ -24,48 +24,19 @@ jobs:
2424
with:
2525
dotnet-version: '8.x'
2626

27-
- name: Copy README.md to the project folder
28-
run: cp README.md src/Solcast/README.md
27+
- name: Set API Key Environment Variable
28+
run: echo "SOLCAST_API_KEY=${{ secrets.SOLCAST_API_KEY }}" >> $GITHUB_ENV
2929

3030
- name: Restore dependencies
3131
run: dotnet restore
3232

33-
- name: Build
34-
run: dotnet build --configuration Release
35-
36-
- name: Upload Build Artifacts
37-
uses: actions/upload-artifact@v3
38-
with:
39-
name: build_artifacts
40-
path: src/Solcast/bin/Release/**
41-
42-
test:
43-
runs-on: ubuntu-latest
44-
needs: build
45-
steps:
46-
- name: Checkout code
47-
uses: actions/checkout@v4
48-
49-
- name: Setup .NET Core
50-
uses: actions/setup-dotnet@v3
51-
with:
52-
dotnet-version: '8.x'
53-
54-
- name: Download Build Artifacts
55-
uses: actions/download-artifact@v3
56-
with:
57-
name: build_artifacts
58-
59-
- name: Set API Key Environment Variable
60-
run: echo "SOLCAST_API_KEY=${{ secrets.SOLCAST_API_KEY }}" >> $GITHUB_ENV
61-
6233
- name: Run tests
63-
run: dotnet test --no-build --configuration Release
34+
run: dotnet test
6435

65-
package:
36+
package_and_publish:
6637
if: startsWith(github.ref, 'refs/tags/')
6738
runs-on: ubuntu-latest
68-
needs: test
39+
needs: build_and_test
6940
steps:
7041
- name: Checkout code
7142
uses: actions/checkout@v4
@@ -75,43 +46,27 @@ jobs:
7546
with:
7647
dotnet-version: '8.x'
7748

49+
- name: Copy README.md to the project folder
50+
run: cp README.md src/Solcast/README.md
51+
52+
- name: Restore dependencies
53+
run: dotnet restore src/Solcast/Solcast.csproj
54+
7855
- name: Extract version from Git tag
7956
run: |
8057
CLEAN_VERSION="${GITHUB_REF##*/}" # Remove 'refs/tags/'
8158
CLEAN_VERSION="${CLEAN_VERSION#v}" # Remove leading 'v'
8259
echo "CLEAN_VERSION=$CLEAN_VERSION" >> $GITHUB_ENV # Set it as env variable
8360
84-
- name: Copy README.md to the project folder
85-
run: cp README.md src/Solcast/README.md
86-
87-
- name: Restore dependencies
88-
run: dotnet restore
89-
9061
- name: Pack NuGet Package with version from tag
9162
run: dotnet pack src/Solcast/Solcast.csproj --configuration Release --output ./nupkg /p:PackageVersion=${{ env.CLEAN_VERSION }}
9263

93-
- name: Upload Package Artifact
94-
uses: actions/upload-artifact@v3
95-
with:
96-
name: nuget_package
97-
path: ./nupkg/*.nupkg
98-
99-
publish:
100-
if: startsWith(github.ref, 'refs/tags/')
101-
runs-on: ubuntu-latest
102-
needs: package
103-
steps:
104-
- name: Download Package Artifact
105-
uses: actions/download-artifact@v3
106-
with:
107-
name: nuget_package
108-
10964
- name: Publish NuGet Package to GitHub Packages
11065
env:
11166
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112-
run: dotnet nuget push ./*.nupkg --source "https://nuget.pkg.github.com/solcast/index.json" --api-key ${{ secrets.GITHUB_TOKEN }}
67+
run: dotnet nuget push ./nupkg/*.nupkg --source "https://nuget.pkg.github.com/solcast/index.json" --api-key ${{ secrets.GITHUB_TOKEN }}
11368

11469
- name: Publish NuGet Package to NuGet.org
11570
env:
11671
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
117-
run: dotnet nuget push ./*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
72+
run: dotnet nuget push ./nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

0 commit comments

Comments
 (0)