Skip to content

Commit 0022e39

Browse files
committed
update master workflow
1 parent 6b0236a commit 0022e39

File tree

2 files changed

+29
-67
lines changed

2 files changed

+29
-67
lines changed

.github/workflows/branches.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
run: git fetch --tags --force --prune && git describe
3333
- name: Generate version info from git history
3434
run: dotnet gitversion /output json | jq -r 'to_entries|map("GitVersion_\(.key)=\(.value|tostring)")|.[]' >> $GITHUB_ENV
35-
- name: Check that the version number has been resolved
35+
- name: Fail if the version number has not been resolved
3636
if: ${{ !env.GitVersion_SemVer }}
3737
run: |
3838
echo Error! Version number not resolved!

.github/workflows/master.yml

Lines changed: 28 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,91 +5,53 @@ on:
55
- master
66
- 'release/**'
77
- 'releases/**'
8-
tags:
9-
- v*
10-
- V*
8+
119
env:
10+
DOTNET_NOLOGO: true
1211
DOTNET_CLI_TELEMETRY_OPTOUT: true
1312
MSBUILDSINGLELOADCONTEXT: 1
1413

1514
jobs:
16-
generateVersionInfo:
17-
name: GenerateVersionInfo
15+
build:
16+
name: Build and Test
1817
runs-on: ubuntu-latest
1918
steps:
2019
- name: Checkout
2120
uses: actions/checkout@v3
2221
with:
2322
fetch-depth: 0
23+
- name: Setup .NET Core SDK
24+
uses: actions/setup-dotnet@v2
25+
with:
26+
dotnet-version: "6.0.x"
27+
source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json
28+
env:
29+
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
2430
- name: Restore dotnet tools
2531
run: dotnet tool restore
2632
- name: Fetch complete repository including tags
2733
run: git fetch --tags --force --prune && git describe
2834
- name: Generate version info from git history
29-
run: dotnet gitversion /output json | jq -r 'to_entries|map("GitVersion_\(.key)=\(.value|tostring)")|.[]' >> gitversion.env && cat gitversion.env
30-
- name: Upload version info file
31-
uses: actions/upload-artifact@v3
32-
with:
33-
name: gitversion
34-
path: gitversion.env
35-
36-
build:
37-
name: Build
38-
needs: generateVersionInfo
39-
runs-on: ubuntu-latest
40-
steps:
41-
- name: Checkout
42-
uses: actions/checkout@v3
43-
- name: Download version info file
44-
uses: actions/download-artifact@v3
45-
with:
46-
name: gitversion
47-
path: ./
48-
- name: Inject version info into environment
49-
run: cat ./gitversion.env >> $GITHUB_ENV
35+
run: dotnet gitversion /output json | jq -r 'to_entries|map("GitVersion_\(.key)=\(.value|tostring)")|.[]' >> $GITHUB_ENV
36+
- name: Fail if the version number has not been resolved
37+
if: ${{ !env.GitVersion_SemVer }}
38+
run: |
39+
echo Error! Version number not resolved!
40+
exit 1
41+
- name: Print current version
42+
run: echo "Current version is \"$GitVersion_SemVer\""
43+
- name: Install dependencies
44+
run: dotnet restore
5045
- name: Build solution
51-
run: echo "Current version is \"$GitVersion_SemVer\"" && dotnet build -c Release
46+
run: dotnet build --no-restore -c Release
47+
- name: Run Tests
48+
run: dotnet test -c Release --no-restore --no-build
5249
- name: Create NuGet packages
53-
run: dotnet pack -c Release --no-build -o nupkg
54-
- name: Upload nuget packages
50+
run: dotnet pack -c Release --no-restore --no-build -o nupkg
51+
- name: Upload nuget packages as artifacts
5552
uses: actions/upload-artifact@v3
5653
with:
5754
name: nupkg
5855
path: nupkg
59-
60-
test:
61-
name: Test
62-
needs: [build, generateVersionInfo]
63-
runs-on: ubuntu-latest
64-
steps:
65-
- name: Checkout
66-
uses: actions/checkout@v3
67-
- name: Download version info file
68-
uses: actions/download-artifact@v3
69-
with:
70-
name: gitversion
71-
path: ./
72-
- name: Inject version info into environment
73-
run: cat ./gitversion.env >> $GITHUB_ENV
74-
- name: Run tests
75-
run: echo "Current version is \"$GitVersion_SemVer\"" && dotnet test -c Release
76-
77-
publish:
78-
name: Publish
79-
needs: [test]
80-
runs-on: ubuntu-latest
81-
steps:
82-
- name: Checkout
83-
uses: actions/checkout@v3
84-
- name: Download nuget packages
85-
uses: actions/download-artifact@v3
86-
with:
87-
name: nupkg
88-
path: nupkg
89-
- name: Publish the package to GPR
90-
# using workaround with CURL because of non-functioning upload via dotnet nuget (https://stackoverflow.com/a/58943251)
91-
run: |
92-
for f in ./nupkg/*.nupkg
93-
do
94-
curl -vX PUT -u "graphql-dotnet:${{secrets.GITHUB_TOKEN}}" -F package=@$f https://nuget.pkg.github.com/graphql-dotnet/
95-
done
56+
- name: Publish Nuget packages to GitHub registry
57+
run: dotnet nuget push "nupkg/*" -k ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)