diff --git a/.github/workflows/commit.yml b/.github/workflows/commit.yml index 6d2fd5b..51acf06 100644 --- a/.github/workflows/commit.yml +++ b/.github/workflows/commit.yml @@ -1,29 +1,29 @@ -name: .NET +name: Commit on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 6.0.x - - - name: Restore dependencies - run: dotnet restore - - - name: Build - run: dotnet build --no-restore - - - name: Test - run: dotnet test --no-build --verbosity normal + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --no-restore + + - name: Test + run: dotnet test --no-build --verbosity normal diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..dcfd78f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release + +on: + release: + types: ["published"] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - name: Parse version + id: version + run: .\build\Get-Version.ps1 -Ref "${env:GITHUB_REF}" + shell: pwsh + + - name: Restore dependencies + run: dotnet restore + + - name: Build + run: dotnet build --no-restore + + - name: Test + run: dotnet test --no-build --verbosity normal + + - name: Pack + run: dotnet pack --configuration Release --output .nupkgs -p:VersionPrefix="${{ steps.version.outputs.version_3 }}" --version-suffix "${{ steps.version.outputs.version_suffix }}" + + - name: Publish + run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_APIKEY }} --source https://api.nuget.org/v3/index.json + working-directory: .nupkgs + + - name: Upload artifact to action + uses: actions/upload-artifact@v3 + with: + name: nupkgs + path: .nupkgs/ + + - name: Upload artifacts to release + uses: AButler/upload-release-assets@v1.0 + with: + files: ".nupkgs/*.nupkg" + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/HttpPatch.Schema/HttpPatch.Schema.csproj b/HttpPatch.Schema/HttpPatch.Schema.csproj index eb2460e..26c177e 100644 --- a/HttpPatch.Schema/HttpPatch.Schema.csproj +++ b/HttpPatch.Schema/HttpPatch.Schema.csproj @@ -4,6 +4,25 @@ net6.0 enable enable + Boomin + Boomin + https://github.com/boomin-engineering/http-patch + MIT + true + true + snupkg + true + + true + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/HttpPatch/HttpPatch.csproj b/HttpPatch/HttpPatch.csproj index 49b54fa..768ee7c 100644 --- a/HttpPatch/HttpPatch.csproj +++ b/HttpPatch/HttpPatch.csproj @@ -4,9 +4,25 @@ net6.0 enable enable + Boomin + Boomin + https://github.com/boomin-engineering/http-patch + MIT + true + true + snupkg + true + + + + true + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/build/Get-Version.ps1 b/build/Get-Version.ps1 new file mode 100644 index 0000000..f5a021a --- /dev/null +++ b/build/Get-Version.ps1 @@ -0,0 +1,38 @@ +param( + [Parameter(Mandatory = $true)] + [string]$Ref +) + +$ErrorActionPreference = 'Stop' + +$tagNameRegex = '^refs/tags/(?\S+)$' +$versionRegex = '^v?(?\d+)\.(?\d+)\.(?\d+)(?-[A-Za-z0-9-]+)?$' + +if ($Ref -notmatch $tagNameRegex) { + Write-Error 'Ref is not a tag' + return +} + +$tagName = $Matches.TagName + +if ($tagName -notmatch $versionRegex) { + Write-Error 'Tag is not a version' +} + +$major = $Matches.Major +$minor = $Matches.Minor +$patch = $Matches.Patch +$suffix = $Matches.Suffix +$suffixStripped = '' +if (![string]::IsNullOrWhiteSpace($suffix)) { + $suffixStripped = $suffix.Substring(1) +} + +Write-Host "::set-output name=tag_name::$tagName" +Write-Host "::set-output name=version_full::$major.$minor.$patch$suffix" +Write-Host "::set-output name=version_major::$major" +Write-Host "::set-output name=version_minor::$minor" +Write-Host "::set-output name=version_patch::$patch" +Write-Host "::set-output name=version_suffix::$suffixStripped" +Write-Host "::set-output name=version_2::$major.$minor" +Write-Host "::set-output name=version_3::$major.$minor.$patch" \ No newline at end of file