Skip to content

Commit 6ec8c00

Browse files
committed
Add deployment workflows
1 parent 548e36b commit 6ec8c00

File tree

3 files changed

+127
-29
lines changed

3 files changed

+127
-29
lines changed

.github/workflows/deploy.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Ref: https://github.com/giraffe-fsharp/Giraffe/blob/master/.github/workflows/build.yml
2+
name: SectionMattr Deploy
3+
4+
on:
5+
push:
6+
pull_request:
7+
release:
8+
types:
9+
- published
10+
11+
env:
12+
# Project name to pack and publish
13+
PROJECT_NAME: SectionMattr
14+
# Official NuGet Feed settings
15+
NUGET_FEED: https://api.nuget.org/v3/index.json
16+
NUGET_KEY: ${{ secrets.NUGET_KEY }}
17+
18+
# Kill other jobs when we trigger this workflow by sending new commits to the PR.
19+
# https://stackoverflow.com/a/72408109
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
test:
26+
timeout-minutes: 60
27+
runs-on: ${{ matrix.os }}
28+
strategy:
29+
matrix:
30+
os: [ ubuntu-22.04, windows-2022, macos-14 ]
31+
steps:
32+
-
33+
name: Checkout
34+
uses: actions/checkout@v4
35+
-
36+
name: Setup dotnet
37+
uses: actions/setup-dotnet@v4
38+
with:
39+
dotnet-version: |
40+
6.x
41+
7.x
42+
8.x
43+
-
44+
name: Restore dotnet tool & dependency
45+
run: |
46+
dotnet tool restore
47+
dotnet restore
48+
-
49+
name: Build
50+
run: dotnet build -c Release --no-restore
51+
-
52+
name: Run unit test
53+
run: dotnet test -c Release
54+
-
55+
name: Pack
56+
if: matrix.os == 'ubuntu-latest'
57+
run: |
58+
latestTag=$(git describe --tags --abbrev=0 2>/dev/null || echo 0.0.1)
59+
runId=$GITHUB_RUN_ID
60+
packageVersion="${latestTag//v}-build.${runId}"
61+
dotnet pack -v normal -c Release --no-restore --include-symbols --include-source -p:PackageVersion=$packageVersion $PROJECT_NAME/$PROJECT_NAME.*proj
62+
-
63+
name: Upload Artifact
64+
if: matrix.os == 'ubuntu-latest'
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: nupkg
68+
path: ./$PROJECT_NAME/bin/Release/*.nupkg
69+
70+
deploy:
71+
needs: build
72+
if: github.event_name == 'release'
73+
runs-on: ubuntu-latest
74+
steps:
75+
-
76+
name: Checkout
77+
uses: actions/checkout@v4
78+
-
79+
name: Setup dotnet
80+
uses: actions/setup-dotnet@v4
81+
with:
82+
dotnet-version: |
83+
6.x
84+
7.x
85+
8.x
86+
-
87+
name: Create Release NuGet package
88+
run: |
89+
arrTag=(${GITHUB_REF//\// })
90+
VERSION="${arrTag[2]}"
91+
echo Version: $VERSION
92+
VERSION="${VERSION//v}"
93+
echo Clean Version: $VERSION
94+
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg $PROJECT_NAME/$PROJECT_NAME.*proj
95+
-
96+
name: Push to NuGet Feed
97+
run: dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --skip-duplicate --api-key $NUGET_KEY

.github/workflows/test.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

SectionMattr/SectionMattr.fsproj

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,39 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<!-- Ref: https://github.com/giraffe-fsharp/Giraffe/blob/master/src/Giraffe/Giraffe.fsproj -->
5+
6+
<!-- Build settings -->
7+
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
8+
<DebugType>portable</DebugType>
9+
<OutputType>Library</OutputType>
10+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
11+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
512
<GenerateDocumentationFile>true</GenerateDocumentationFile>
13+
<IncludeSymbols>true</IncludeSymbols>
14+
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
15+
16+
<!-- NuGet settings -->
17+
<PackageId>SectionMattr</PackageId>
18+
<PackageTags>ASP.NET Core;FSharp;Parser</PackageTags>
19+
<PackageProjectUrl>https://github.com/sistracia/section-mattr</PackageProjectUrl>
20+
<RepositoryType>git</RepositoryType>
21+
<RepositoryUrl>https://github.com/sistracia/section-mattr</RepositoryUrl>
22+
23+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
24+
<PackageReadmeFile>README.md</PackageReadmeFile> <!--https://docs.microsoft.com/en-gb/nuget/reference/msbuild-targets#packagereadmefile -->
25+
<!-- SourceLink settings -->
26+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
27+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
28+
29+
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
630
</PropertyGroup>
731

32+
<ItemGroup>
33+
<None Include="$(MSBuildThisFileDirectory)../README.md" Pack="true" PackagePath="/"/>
34+
<None Include="$(MSBuildThisFileDirectory)../LICENSE" Pack="true" PackagePath="/"/>
35+
</ItemGroup>
36+
837
<ItemGroup>
938
<Compile Include="Library.fs" />
1039
</ItemGroup>

0 commit comments

Comments
 (0)