From bae25e5c68f37e86a7dc6f5985c409f7c631fdae Mon Sep 17 00:00:00 2001 From: Matt Hunt Date: Fri, 12 Jul 2024 08:51:46 +0100 Subject: [PATCH] Adding release action --- .github/workflows/release.yml | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e1aa176 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,55 @@ +name: 'Release' + +on: + release: + types: + - published + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + + # Project name to pack and publish + PROJECT_NAME: GeoJSON.Net + + # Official NuGet Feed settings + NUGET_FEED: https://api.nuget.org/v3/index.json + NUGET_KEY: ${{ secrets.NUGET_KEY }} + NUGET_VERSIONING_REGEX: "[0-9]+\\.[0-9]+\\.[0-9]+(-[a-zA-Z]+)?" + +jobs: + deploy: + name: 'Deploy to Nuget' + if: github.event_name == 'release' + runs-on: windows-2019 + + steps: + - name: Validate release version + run: | + $VERSION=${env:GITHUB_REF_NAME} + if($VERSION[0] -eq "v"){ + $VERSION=$VERSION.substring(1) + } + if(!($VERSION -match ${env:NUGET_VERSIONING_REGEX})) { + throw "Release tag did not contain a valid NUGET version. TAG was : ${env:GITHUB_REF_NAME}" + } + echo "Version to use is - $VERSION" + echo "RELEASE_VERSION=$VERSION" | Out-File -FilePath ${env:GITHUB_ENV} -Append + - uses: actions/checkout@v2 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: | + 3.1.x + 5.0.x + 6.0.x + 7.0.x + 8.0.x + - name: Install dependencies + run: dotnet restore src/${{ env.PROJECT_NAME }}.sln + - name: Build solution + run: dotnet build src/${{ env.PROJECT_NAME }}.sln -c Release --no-restore + - name: Create Release NuGet package + run: dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=${{ env.RELEASE_VERSION }} -o nupkg src/${{ env.PROJECT_NAME }}/${{ env.PROJECT_NAME }}.csproj + - name: Push to Nuget + run: dotnet nuget push "./nupkg/${{ env.PROJECT_NAME }}.${{ env.RELEASE_VERSION }}.nupkg" --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_KEY}} --skip-duplicate