|
5 | 5 | - master |
6 | 6 | - 'release/**' |
7 | 7 | - 'releases/**' |
8 | | - tags: |
9 | | - - v* |
10 | | - - V* |
| 8 | + |
11 | 9 | env: |
| 10 | + DOTNET_NOLOGO: true |
12 | 11 | DOTNET_CLI_TELEMETRY_OPTOUT: true |
13 | 12 | MSBUILDSINGLELOADCONTEXT: 1 |
14 | 13 |
|
15 | 14 | jobs: |
16 | | - generateVersionInfo: |
17 | | - name: GenerateVersionInfo |
| 15 | + build: |
| 16 | + name: Build and Test |
18 | 17 | runs-on: ubuntu-latest |
19 | 18 | steps: |
20 | 19 | - name: Checkout |
21 | 20 | uses: actions/checkout@v3 |
22 | 21 | with: |
23 | 22 | 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}} |
24 | 30 | - name: Restore dotnet tools |
25 | 31 | run: dotnet tool restore |
26 | 32 | - name: Fetch complete repository including tags |
27 | 33 | run: git fetch --tags --force --prune && git describe |
28 | 34 | - 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 |
50 | 45 | - 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 |
52 | 49 | - 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 |
55 | 52 | uses: actions/upload-artifact@v3 |
56 | 53 | with: |
57 | 54 | name: nupkg |
58 | 55 | 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