Skip to content

Commit eba1551

Browse files
Merge pull request #4 from GeoJSON-Net/feature/release-build
GitHub action to release to nuget
2 parents d0bd715 + 7e4036b commit eba1551

5 files changed

Lines changed: 74 additions & 17 deletions

File tree

.github/workflows/ci-build.yml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,46 @@ on:
44
push:
55
pull_request:
66
branches: [ main ]
7+
release:
8+
types:
9+
- published
10+
11+
env:
12+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
13+
DOTNET_CLI_TELEMETRY_OPTOUT: true
14+
15+
# Project name to pack and publish
16+
PROJECT_NAME: GeoJSON.Text
717

818
jobs:
9-
Build:
19+
build:
1020

1121
name: 'Build and Test'
1222
runs-on: ubuntu-latest
13-
defaults:
14-
run:
15-
working-directory: ./src
16-
17-
env:
18-
VSTEST_CONNECTION_TIMEOUT: 900
19-
23+
2024
steps:
2125
- uses: actions/checkout@v2
22-
- name: Setup .NET Core
26+
- name: Setup .NET
2327
uses: actions/setup-dotnet@v1
2428
with:
2529
dotnet-version: |
2630
3.1.x
2731
5.0.x
2832
6.0.x
2933
- name: Install dependencies
30-
run: dotnet restore
34+
run: dotnet restore src/${{ env.PROJECT_NAME }}.sln
3135
- name: Build solution
32-
run: dotnet build -c Release --no-restore /p:Version=1.2.3.4
36+
run: dotnet build src/${{ env.PROJECT_NAME }}.sln -c Release --no-restore
3337
- name: Test
34-
run: dotnet test -c Release --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../coverage/
38+
run: dotnet test src/${{ env.PROJECT_NAME }}.sln -c Release --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=../coverage/
3539
- uses: codecov/codecov-action@v2
3640
if: ${{ github.event_name == 'push' }}
3741
with:
3842
token: ${{ secrets.CODECOV_TOKEN }}
3943
directory: src/coverage
4044
flags: unittests
41-
42-
45+
- name: Upload Artifact
46+
uses: actions/upload-artifact@v2
47+
with:
48+
name: nupkg
49+
path: src/${{ env.PROJECT_NAME }}/bin/Release/*.nupkg

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: 'Build and Test'
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
env:
9+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
10+
DOTNET_CLI_TELEMETRY_OPTOUT: true
11+
12+
# Project name to pack and publish
13+
PROJECT_NAME: GeoJSON.Text
14+
15+
# Official NuGet Feed settings
16+
NUGET_FEED: https://api.nuget.org/v3/index.json
17+
NUGET_KEY: ${{ secrets.NUGET_KEY }}
18+
19+
jobs:
20+
deploy:
21+
name: 'Deploy to Nuget'
22+
if: github.event_name == 'release'
23+
needs: build
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- uses: actions/checkout@v2
28+
- name: Setup .NET Core
29+
uses: actions/setup-dotnet@v1
30+
with:
31+
dotnet-version: |
32+
3.1.x
33+
5.0.x
34+
6.0.x
35+
- name: Create Release NuGet package
36+
run: |
37+
arrTag=(${GITHUB_REF//\// })
38+
VERSION="${arrTag[2]}"
39+
VERSION="${VERSION//v}"
40+
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg src/$PROJECT_NAME/$PROJECT_NAME.csproj
41+
- name: Push to Nuget
42+
run: dotnet nuget push nuget/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{secrets.NUGET_KEY}} --skip-duplicate

key.snk

596 Bytes
Binary file not shown.

src/GeoJSON.Text.Test.Benchmark/GeoJSON.Text.Test.Benchmark.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>netcoreapp3.1;net5;net6</TargetFrameworks>
5+
<TargetFrameworks>netstandard2.0;net5;net6</TargetFrameworks>
66
<ImplicitUsings>disable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<SignAssembly>False</SignAssembly>
9+
<LangVersion>Latest</LangVersion>
910
</PropertyGroup>
1011

1112
<ItemGroup>

src/GeoJSON.Text/GeoJSON.Text.csproj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp3.1;net5;net6</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;net5;net6</TargetFrameworks>
55
<LangVersion>Latest</LangVersion>
66
<Description>.Net types for the GeoJSON RFC to be used with System.Text.Json</Description>
77
<Authors>Matt Hunt</Authors>
88
<Company>GeoJSON.Text</Company>
9-
<Copyright>Copyright © Matt Hunt, Xavier Fischer and Contributors, 2014 - 2021</Copyright>
9+
<Copyright>Copyright © Matt Hunt and Contributors, 2014 - 2021</Copyright>
1010
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1111
<Version>0.1.0</Version>
1212
<PackageProjectUrl>https://github.com/GeoJSON-Net/GeoJSON.Text</PackageProjectUrl>
@@ -20,8 +20,15 @@
2020
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2121
<EmbedUntrackedSources>true</EmbedUntrackedSources>
2222
<PublishRepositoryUrl>true</PublishRepositoryUrl>
23+
<SignAssembly>true</SignAssembly>
24+
<AssemblyOriginatorKeyFile>../key.snk</AssemblyOriginatorKeyFile>
25+
<DelaySign>false</DelaySign>
2326
</PropertyGroup>
2427

28+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
29+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
30+
</PropertyGroup>
31+
2532
<ItemGroup>
2633
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
2734
<PackageReference Include="System.Text.Json" Version="6.0.1" />

0 commit comments

Comments
 (0)