Skip to content

Commit c67366a

Browse files
AButlerAndrew Butler
andauthored
Add release action (#2)
Co-authored-by: Andrew Butler <andrew.butler@boomin.com>
1 parent 51b3733 commit c67366a

5 files changed

Lines changed: 143 additions & 19 deletions

File tree

.github/workflows/commit.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
name: .NET
1+
name: Commit
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: ["main"]
66
pull_request:
7-
branches: [ "main" ]
7+
branches: ["main"]
88

99
jobs:
1010
build:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v3
16-
17-
- name: Setup .NET
18-
uses: actions/setup-dotnet@v2
19-
with:
20-
dotnet-version: 6.0.x
21-
22-
- name: Restore dependencies
23-
run: dotnet restore
24-
25-
- name: Build
26-
run: dotnet build --no-restore
27-
28-
- name: Test
29-
run: dotnet test --no-build --verbosity normal
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v2
19+
with:
20+
dotnet-version: 6.0.x
21+
22+
- name: Restore dependencies
23+
run: dotnet restore
24+
25+
- name: Build
26+
run: dotnet build --no-restore
27+
28+
- name: Test
29+
run: dotnet test --no-build --verbosity normal

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: ["published"]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Setup .NET
16+
uses: actions/setup-dotnet@v2
17+
with:
18+
dotnet-version: 6.0.x
19+
20+
- name: Parse version
21+
id: version
22+
run: .\build\Get-Version.ps1 -Ref "${env:GITHUB_REF}"
23+
shell: pwsh
24+
25+
- name: Restore dependencies
26+
run: dotnet restore
27+
28+
- name: Build
29+
run: dotnet build --no-restore
30+
31+
- name: Test
32+
run: dotnet test --no-build --verbosity normal
33+
34+
- name: Pack
35+
run: dotnet pack --configuration Release --output .nupkgs -p:VersionPrefix="${{ steps.version.outputs.version_3 }}" --version-suffix "${{ steps.version.outputs.version_suffix }}"
36+
37+
- name: Publish
38+
run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_APIKEY }} --source https://api.nuget.org/v3/index.json
39+
working-directory: .nupkgs
40+
41+
- name: Upload artifact to action
42+
uses: actions/upload-artifact@v3
43+
with:
44+
name: nupkgs
45+
path: .nupkgs/
46+
47+
- name: Upload artifacts to release
48+
uses: AButler/upload-release-assets@v1.0
49+
with:
50+
files: ".nupkgs/*.nupkg"
51+
repo-token: ${{ secrets.GITHUB_TOKEN }}

HttpPatch.Schema/HttpPatch.Schema.csproj

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44
<TargetFramework>net6.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<Authors>Boomin</Authors>
8+
<Company>Boomin</Company>
9+
<PackageProjectUrl>https://github.com/boomin-engineering/http-patch</PackageProjectUrl>
10+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
11+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
12+
<IncludeSymbols>true</IncludeSymbols>
13+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
14+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
715
</PropertyGroup>
816

17+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
18+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
19+
</PropertyGroup>
20+
21+
<ItemGroup>
22+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
23+
<PrivateAssets>all</PrivateAssets>
24+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
25+
</PackageReference>
26+
</ItemGroup>
27+
928
</Project>

HttpPatch/HttpPatch.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,25 @@
44
<TargetFramework>net6.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<Authors>Boomin</Authors>
8+
<Company>Boomin</Company>
9+
<PackageProjectUrl>https://github.com/boomin-engineering/http-patch</PackageProjectUrl>
10+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
11+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
12+
<IncludeSymbols>true</IncludeSymbols>
13+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
14+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
15+
</PropertyGroup>
16+
17+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
18+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
719
</PropertyGroup>
820

921
<ItemGroup>
22+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
23+
<PrivateAssets>all</PrivateAssets>
24+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
25+
</PackageReference>
1026
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
1127
</ItemGroup>
1228

build/Get-Version.ps1

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[string]$Ref
4+
)
5+
6+
$ErrorActionPreference = 'Stop'
7+
8+
$tagNameRegex = '^refs/tags/(?<TagName>\S+)$'
9+
$versionRegex = '^v?(?<Major>\d+)\.(?<Minor>\d+)\.(?<Patch>\d+)(?<Suffix>-[A-Za-z0-9-]+)?$'
10+
11+
if ($Ref -notmatch $tagNameRegex) {
12+
Write-Error 'Ref is not a tag'
13+
return
14+
}
15+
16+
$tagName = $Matches.TagName
17+
18+
if ($tagName -notmatch $versionRegex) {
19+
Write-Error 'Tag is not a version'
20+
}
21+
22+
$major = $Matches.Major
23+
$minor = $Matches.Minor
24+
$patch = $Matches.Patch
25+
$suffix = $Matches.Suffix
26+
$suffixStripped = ''
27+
if (![string]::IsNullOrWhiteSpace($suffix)) {
28+
$suffixStripped = $suffix.Substring(1)
29+
}
30+
31+
Write-Host "::set-output name=tag_name::$tagName"
32+
Write-Host "::set-output name=version_full::$major.$minor.$patch$suffix"
33+
Write-Host "::set-output name=version_major::$major"
34+
Write-Host "::set-output name=version_minor::$minor"
35+
Write-Host "::set-output name=version_patch::$patch"
36+
Write-Host "::set-output name=version_suffix::$suffixStripped"
37+
Write-Host "::set-output name=version_2::$major.$minor"
38+
Write-Host "::set-output name=version_3::$major.$minor.$patch"

0 commit comments

Comments
 (0)