|
| 1 | +name: build and deploy |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + pull_request: |
| 7 | + branches: [ master ] |
| 8 | + release: |
| 9 | + types: |
| 10 | + - published |
| 11 | + |
| 12 | +env: |
| 13 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 14 | + DOTNET_VERSION: 5.0.100-rc.1.20452.10 |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + - name: Setup .NET Core |
| 22 | + uses: actions/setup-dotnet@v1 |
| 23 | + with: |
| 24 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 25 | + - name: Install dependencies |
| 26 | + run: dotnet restore |
| 27 | + - name: Build |
| 28 | + run: dotnet build -c Release --no-restore |
| 29 | + - name: Test |
| 30 | + run: dotnet test --no-restore --verbosity normal |
| 31 | + |
| 32 | + pack: |
| 33 | + needs: build |
| 34 | + if: github.event_name == 'release' |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v2 |
| 38 | + - name: Setup .NET Core |
| 39 | + uses: actions/setup-dotnet@v1 |
| 40 | + with: |
| 41 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 42 | + - name: Pack |
| 43 | + run: | |
| 44 | + arrTag=(${GITHUB_REF//\// }) |
| 45 | + VERSION="${arrTag[2]}" |
| 46 | + echo Version: $VERSION |
| 47 | + VERSION="${VERSION//v}" |
| 48 | + dotnet pack -c Release -p:PackageVersion=$VERSION src/StringLiteralGenerator |
| 49 | + - name: Upload Artifact |
| 50 | + uses: actions/upload-artifact@v2 |
| 51 | + with: |
| 52 | + name: nupkg |
| 53 | + path: | |
| 54 | + ./**/bin/Release/*.nupkg |
| 55 | +
|
| 56 | + push: |
| 57 | + needs: pack |
| 58 | + runs-on: ubuntu-latest |
| 59 | + steps: |
| 60 | + - name: Setup .NET Core |
| 61 | + uses: actions/setup-dotnet@v1 |
| 62 | + with: |
| 63 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 64 | + - name: Download Artifact |
| 65 | + uses: actions/download-artifact@v1 |
| 66 | + with: |
| 67 | + name: nupkg |
| 68 | + - name: Push to nuget.org |
| 69 | + run: dotnet nuget push ./nupkg/**/*.* --skip-duplicate --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NugetApiKey }} |
0 commit comments