|
| 1 | +# Ref: https://github.com/giraffe-fsharp/Giraffe/blob/master/.github/workflows/build.yml |
| 2 | +name: SectionMattr Deploy |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + pull_request: |
| 7 | + release: |
| 8 | + types: |
| 9 | + - published |
| 10 | + |
| 11 | +env: |
| 12 | + # Project name to pack and publish |
| 13 | + PROJECT_NAME: SectionMattr |
| 14 | + # Official NuGet Feed settings |
| 15 | + NUGET_FEED: https://api.nuget.org/v3/index.json |
| 16 | + NUGET_KEY: ${{ secrets.NUGET_KEY }} |
| 17 | + |
| 18 | +# Kill other jobs when we trigger this workflow by sending new commits to the PR. |
| 19 | +# https://stackoverflow.com/a/72408109 |
| 20 | +concurrency: |
| 21 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + test: |
| 26 | + timeout-minutes: 60 |
| 27 | + runs-on: ${{ matrix.os }} |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + os: [ ubuntu-22.04, windows-2022, macos-14 ] |
| 31 | + steps: |
| 32 | + - |
| 33 | + name: Checkout |
| 34 | + uses: actions/checkout@v4 |
| 35 | + - |
| 36 | + name: Setup dotnet |
| 37 | + uses: actions/setup-dotnet@v4 |
| 38 | + with: |
| 39 | + dotnet-version: | |
| 40 | + 6.x |
| 41 | + 7.x |
| 42 | + 8.x |
| 43 | + - |
| 44 | + name: Restore dotnet tool & dependency |
| 45 | + run: | |
| 46 | + dotnet tool restore |
| 47 | + dotnet restore |
| 48 | + - |
| 49 | + name: Build |
| 50 | + run: dotnet build -c Release --no-restore |
| 51 | + - |
| 52 | + name: Run unit test |
| 53 | + run: dotnet test -c Release |
| 54 | + - |
| 55 | + name: Pack |
| 56 | + if: matrix.os == 'ubuntu-latest' |
| 57 | + run: | |
| 58 | + latestTag=$(git describe --tags --abbrev=0 2>/dev/null || echo 0.0.1) |
| 59 | + runId=$GITHUB_RUN_ID |
| 60 | + packageVersion="${latestTag//v}-build.${runId}" |
| 61 | + dotnet pack -v normal -c Release --no-restore --include-symbols --include-source -p:PackageVersion=$packageVersion $PROJECT_NAME/$PROJECT_NAME.*proj |
| 62 | + - |
| 63 | + name: Upload Artifact |
| 64 | + if: matrix.os == 'ubuntu-latest' |
| 65 | + uses: actions/upload-artifact@v4 |
| 66 | + with: |
| 67 | + name: nupkg |
| 68 | + path: ./$PROJECT_NAME/bin/Release/*.nupkg |
| 69 | + |
| 70 | + deploy: |
| 71 | + needs: build |
| 72 | + if: github.event_name == 'release' |
| 73 | + runs-on: ubuntu-latest |
| 74 | + steps: |
| 75 | + - |
| 76 | + name: Checkout |
| 77 | + uses: actions/checkout@v4 |
| 78 | + - |
| 79 | + name: Setup dotnet |
| 80 | + uses: actions/setup-dotnet@v4 |
| 81 | + with: |
| 82 | + dotnet-version: | |
| 83 | + 6.x |
| 84 | + 7.x |
| 85 | + 8.x |
| 86 | + - |
| 87 | + name: Create Release NuGet package |
| 88 | + run: | |
| 89 | + arrTag=(${GITHUB_REF//\// }) |
| 90 | + VERSION="${arrTag[2]}" |
| 91 | + echo Version: $VERSION |
| 92 | + VERSION="${VERSION//v}" |
| 93 | + echo Clean Version: $VERSION |
| 94 | + dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg $PROJECT_NAME/$PROJECT_NAME.*proj |
| 95 | + - |
| 96 | + name: Push to NuGet Feed |
| 97 | + run: dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --skip-duplicate --api-key $NUGET_KEY |
0 commit comments