|
| 1 | +name: .NET |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + create: |
| 7 | + tags: |
| 8 | + - '*.*.*' |
| 9 | + pull_request: |
| 10 | + branches: [ master ] |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + - name: Setup .NET |
| 17 | + uses: actions/setup-dotnet@v1 |
| 18 | + with: |
| 19 | + dotnet-version: 5.0.x |
| 20 | + |
| 21 | + - name: Check Tag |
| 22 | + id: check-tag |
| 23 | + run: | |
| 24 | + if [[ ${{ github.event.ref }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 25 | + echo ::set-output name=match::true |
| 26 | + fi |
| 27 | + |
| 28 | + - name: Run Unit Tests |
| 29 | + run: | |
| 30 | + dotnet restore |
| 31 | + dotnet build |
| 32 | + dotnet test test/NosCore.ParserInputGenerator.Tests -v m |
| 33 | + |
| 34 | + - name: Build Artifact |
| 35 | + if: steps.check-tag.outputs.match == 'true' |
| 36 | + id: build_artifact |
| 37 | + run: | |
| 38 | + dotnet restore |
| 39 | + dotnet build -c Release |
| 40 | + dotnet pack -c Release -o /tmp/nupkgs -v m -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg |
| 41 | + dotnet nuget push /tmp/nupkgs/NosCore.ParserInputGenerator.${{github.event.ref}}.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json |
| 42 | + cd /tmp/ |
| 43 | + zip -r NosCore.ParserInputGenerator.${GITHUB_RUN_NUMBER}.zip NosCore.ParserInputGenerator.${GITHUB_RUN_NUMBER} |
| 44 | + echo ::set-output name=ARTIFACT_PATH::/tmp/NosCore.ParserInputGenerator.${GITHUB_RUN_NUMBER}.zip |
| 45 | + echo ::set-output name=ARTIFACT_NAME::NosCore.ParserInputGenerator.${GITHUB_RUN_NUMBER}.zip |
| 46 | + |
| 47 | + - name: Gets Latest Release |
| 48 | + if: steps.check-tag.outputs.match == 'true' |
| 49 | + id: latest_release_info |
| 50 | + |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} |
| 53 | + |
| 54 | + - name: Upload Release Asset |
| 55 | + if: steps.check-tag.outputs.match == 'true' |
| 56 | + uses: actions/upload-release-asset@v1 |
| 57 | + env: |
| 58 | + GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }} |
| 59 | + with: |
| 60 | + upload_url: ${{ steps.latest_release_info.outputs.upload_url }} |
| 61 | + asset_path: ${{ steps.build_artifact.outputs.ARTIFACT_PATH }} |
| 62 | + asset_name: ${{ steps.build_artifact.outputs.ARTIFACT_NAME }} |
| 63 | + asset_content_type: application/zip |
| 64 | + |
0 commit comments