Skip to content

Commit fafb840

Browse files
committed
Add the way to build & publish the package.
1 parent 5dce39f commit fafb840

5 files changed

Lines changed: 91 additions & 1 deletion

File tree

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# directories
2+
**/bin/
3+
**/obj/
4+
**/out/
5+
6+
# files
7+
Dockerfile*
8+
**/*.md
9+
10+
!README.md

.github/workflows/build.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
push:
3+
branches:
4+
- master
5+
pull_request:
6+
branches:
7+
- master
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 15
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
- name: Build
16+
run: docker build --target build .
17+
- name: Test
18+
run: docker build --target test .

.github/workflows/publish.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
on:
2+
release:
3+
types: [released]
4+
jobs:
5+
publish:
6+
runs-on: ubuntu-latest
7+
timeout-minutes: 15
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v2
11+
- name: Set VERSION variable from tag
12+
run: echo "VERSION=${GITHUB_REF/refs\/tags\/}" >> $GITHUB_ENV
13+
- name: Build
14+
run: docker build --target build .
15+
- name: Test
16+
run: docker build --target test .
17+
- name: Pack & Publish
18+
run: docker build --target pack-and-push --build-arg PackageVersion=${VERSION} --build-arg NuGetApiKey=${{secrets.NUGET_API_KEY}} .
19+

Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
2+
WORKDIR /source
3+
4+
# copy csproj and restore as distinct layers
5+
COPY *.sln .
6+
COPY src/StrEnum.Dapper/StrEnum.Dapper.csproj ./src/StrEnum.Dapper/StrEnum.Dapper.csproj
7+
COPY test/StrEnum.Dapper.UnitTests/StrEnum.Dapper.UnitTests.csproj ./test/StrEnum.Dapper.UnitTests/StrEnum.Dapper.UnitTests.csproj
8+
RUN dotnet restore
9+
10+
# copy everything else and build app
11+
COPY ./ ./
12+
WORKDIR /source
13+
RUN dotnet build -c release -o /out/package --no-restore /p:maxcpucount=1
14+
15+
FROM build as test
16+
RUN dotnet test /p:maxcpucount=1
17+
18+
FROM build as pack-and-push
19+
WORKDIR /source
20+
21+
ARG PackageVersion
22+
ARG NuGetApiKey
23+
24+
RUN dotnet pack ./src/StrEnum.Dapper/StrEnum.Dapper.csproj -o /out/package -c Release
25+
RUN dotnet nuget push /out/package/StrEnum.Dapper.$PackageVersion.nupkg -k $NuGetApiKey -s https://api.nuget.org/v3/index.json

src/StrEnum.Dapper/StrEnum.Dapper.csproj

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

33
<PropertyGroup>
44
<PackageId>StrEnum.Dapper</PackageId>
@@ -20,4 +20,22 @@
2020
<PackageReference Include="Dapper" Version="[2.0.4,3.0.0)" />
2121
</ItemGroup>
2222

23+
<Target Name="SetNuspecProperties" BeforeTargets="GenerateNuspec">
24+
<PropertyGroup>
25+
<NuspecProperties>$(NuspecProperties);config=$(Configuration)</NuspecProperties>
26+
<NuspecProperties>$(NuspecProperties);version=$(PackageVersion)</NuspecProperties>
27+
</PropertyGroup>
28+
<Message Importance="high" Text="NuspecProperties: $(NuspecProperties)" />
29+
</Target>
30+
31+
32+
<ItemGroup>
33+
<None Include="..\..\README.md" Pack="true" PackagePath=""/>
34+
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
35+
36+
<PackageReference Include="MinVer" Version="3.1.0">
37+
<PrivateAssets>all</PrivateAssets>
38+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
39+
</PackageReference>
40+
</ItemGroup>
2341
</Project>

0 commit comments

Comments
 (0)