Skip to content

Commit

Permalink
Add release action (#2)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Butler <andrew.butler@boomin.com>
  • Loading branch information
AButler and Andrew Butler authored Jul 29, 2022
1 parent 51b3733 commit c67366a
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 19 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/commit.yml
Original file line number Diff line number Diff line change
@@ -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
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
19 changes: 19 additions & 0 deletions HttpPatch.Schema/HttpPatch.Schema.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Boomin</Authors>
<Company>Boomin</Company>
<PackageProjectUrl>https://github.com/boomin-engineering/http-patch</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions HttpPatch/HttpPatch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,25 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>Boomin</Authors>
<Company>Boomin</Company>
<PackageProjectUrl>https://github.com/boomin-engineering/http-patch</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

Expand Down
38 changes: 38 additions & 0 deletions build/Get-Version.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
param(
[Parameter(Mandatory = $true)]
[string]$Ref
)

$ErrorActionPreference = 'Stop'

$tagNameRegex = '^refs/tags/(?<TagName>\S+)$'
$versionRegex = '^v?(?<Major>\d+)\.(?<Minor>\d+)\.(?<Patch>\d+)(?<Suffix>-[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"

0 comments on commit c67366a

Please sign in to comment.