|
| 1 | +name: Main workflow (Ubuntu) |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - develop |
| 6 | + - 'release/**' |
| 7 | + - 'releases/**' |
| 8 | + tags: |
| 9 | + - v* |
| 10 | + - V* |
| 11 | +env: |
| 12 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 13 | +jobs: |
| 14 | + generateVersionInfo: |
| 15 | + name: GenerateVersionInfo |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v2 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + - name: Restore dotnet tools |
| 23 | + run: dotnet tool restore |
| 24 | + - name: Fetch complete repository |
| 25 | + run: git fetch |
| 26 | + - name: Generate version info from git history |
| 27 | + run: dotnet gitversion /output json > gitversion.json |
| 28 | + - name: Upload version info file |
| 29 | + uses: actions/upload-artifact@v1 |
| 30 | + with: |
| 31 | + name: gitversion |
| 32 | + path: gitversion.json |
| 33 | + |
| 34 | + build: |
| 35 | + name: Build |
| 36 | + needs: generateVersionInfo |
| 37 | + runs-on: ubuntu-latest |
| 38 | + steps: |
| 39 | + - name: Checkout |
| 40 | + uses: actions/checkout@v2 |
| 41 | + - name: Download version info file |
| 42 | + uses: actions/download-artifact@v1 |
| 43 | + with: |
| 44 | + name: gitversion |
| 45 | + path: ./ |
| 46 | + - name: Inject version info into environment |
| 47 | + run: jq -r 'to_entries|map("::set-env name=GitVersion_\(.key)::\(.value|tostring)")|.[]' gitversion.json |
| 48 | + - name: Build solution |
| 49 | + run: echo "Current version is \"$GitVersion_SemVer\"" && dotnet build -c Release |
| 50 | + - name: Create NuGet packages |
| 51 | + run: dotnet pack -c Release --no-build -o nupkg |
| 52 | + - name: Upload nuget packages |
| 53 | + uses: actions/upload-artifact@v1 |
| 54 | + with: |
| 55 | + name: nupkg |
| 56 | + path: nupkg |
| 57 | + |
| 58 | + test: |
| 59 | + name: Test |
| 60 | + needs: [build, generateVersionInfo] |
| 61 | + runs-on: ubuntu-latest |
| 62 | + steps: |
| 63 | + - name: Checkout |
| 64 | + uses: actions/checkout@v2 |
| 65 | + - name: Download version info file |
| 66 | + uses: actions/download-artifact@v1 |
| 67 | + with: |
| 68 | + name: gitversion |
| 69 | + path: ./ |
| 70 | + - name: Inject version info into environment |
| 71 | + run: jq -r 'to_entries|map("::set-env name=GitVersion_\(.key)::\(.value|tostring)")|.[]' gitversion.json |
| 72 | + - name: Run tests |
| 73 | + run: echo "Current version is \"$GitVersion_SemVer\"" && dotnet test -c Release |
| 74 | + |
| 75 | + publish: |
| 76 | + name: Publish |
| 77 | + needs: [test] |
| 78 | + runs-on: ubuntu-latest |
| 79 | + steps: |
| 80 | + - name: Checkout |
| 81 | + uses: actions/checkout@v2 |
| 82 | + - name: Download nuget packages |
| 83 | + uses: actions/download-artifact@v1 |
| 84 | + with: |
| 85 | + name: nupkg |
| 86 | + - uses: actions/setup-dotnet@v1 |
| 87 | + with: |
| 88 | + source-url: https://nuget.pkg.github.com/graphql-dotnet/index.json |
| 89 | + env: |
| 90 | + NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
| 91 | + - name: Publish the package to GPR |
| 92 | + run: for p in ./nupkg/*.nupkg; do dotnet nuget push $p -k ${{secrets.GITHUB_TOKEN}} --skip-duplicate; done |
0 commit comments