Skip to content

Commit 1c3dafc

Browse files
committed
ci: Add build release workflow
1 parent 5d997a8 commit 1c3dafc

5 files changed

Lines changed: 119 additions & 19 deletions

File tree

.github/workflows/build-debug.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: build-release
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
8+
jobs:
9+
create-release:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 10
12+
outputs:
13+
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
14+
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Semantic Release
19+
uses: cycjimmy/semantic-release-action@v4
20+
id: semantic
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
build-dotnet:
25+
needs: [create-release]
26+
runs-on: ubuntu-latest
27+
timeout-minutes: 10
28+
if: needs.create-release.outputs.new_release_published == 'true'
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: actions/setup-dotnet@v4
32+
# build and pack
33+
- run: dotnet build -c Release -p:Version=${{ needs.create-release.outputs.new_release_version }}
34+
- run: dotnet test -c Release --no-build
35+
- run: dotnet pack ./src/LocalPortFiltering.AspNetCore/LocalPortFiltering.AspNetCore.csproj -c Release --no-build -p:Version=${{ needs.create-release.outputs.new_release_version }} -o ./publish
36+
# Store artifacts.
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: nuget
40+
path: ./publish/
41+
retention-days: 1
42+
43+
nuget-push-dotnet:
44+
needs: [build-dotnet]
45+
runs-on: ubuntu-latest
46+
timeout-minutes: 10
47+
if: needs.create-release.outputs.new_release_published == 'true'
48+
env:
49+
NUGET_PATH: |
50+
./*.nupkg
51+
./*.snupkg
52+
steps:
53+
- uses: actions/checkout@v4
54+
- uses: actions/setup-dotnet@v4
55+
56+
# Download(All) Artifacts to current directory
57+
- uses: actions/download-artifact@v4
58+
with:
59+
name: nuget
60+
- name: Show download aritifacts
61+
run: ls -lR
62+
- name: Validate package exists in artifact - NuGet
63+
run: |
64+
while read -r nuget_path; do
65+
if [[ "${nuget_path}" == "" ]]; then continue; fi
66+
# shellcheck disable=SC2086
67+
if ! ls -l ${nuget_path}; then
68+
echo "Specified nuget package not found. path: $nuget_path"
69+
if [[ "${nuget_path}" == *.nupkg ]]; then
70+
echo ".nupkg must be included in the artifact."
71+
exit 1
72+
fi
73+
fi
74+
done <<< "${NUGET_PATH}"
75+
76+
# Upload to NuGet
77+
- name: Upload to NuGet
78+
run: |
79+
while read -r nuget_path; do
80+
if [[ "$nuget_path" == "" ]]; then continue; fi
81+
# shellcheck disable=SC2086
82+
if ! ls -l ${nuget_path} >/dev/null 2>&1;then
83+
echo "skipping nuget push, $nuget_path not found."
84+
continue
85+
fi
86+
87+
dotnet nuget push "${nuget_path}" --skip-duplicate -s https://api.nuget.org/v3/index.json -k "${NUGET_KEY}"
88+
done <<< "${NUGET_PATH}"
89+
env:
90+
NUGET_KEY: ${{ secrets.PS_NUGET_KEY }}

.releaserc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"plugins": [
3+
"@semantic-release/commit-analyzer",
4+
"@semantic-release/release-notes-generator",
5+
[
6+
"@semantic-release/github"
7+
]
8+
],
9+
"branches": [
10+
"main"
11+
]
12+
}

src/LocalPortFiltering.AspNetCore/LocalPortFiltering.AspNetCore.csproj

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<RootNamespace>LocalPortFiltering.AspNetCore</RootNamespace>
8+
9+
<!-- NuGet Packaging -->
10+
<Id>LocalPortFiltering.AspNetCore</Id>
11+
<PackageVersion>$(Version)</PackageVersion>
12+
<Company>Willy</Company>
13+
<Authors>Willy</Authors>
14+
<Copyright>© Willy Wang.</Copyright>
15+
<PackageTags>filter;localport;port</PackageTags>
16+
<Description>Provides local port filtering middleware and extension methods for ASP.NET Core applications. Enables control over which local ports are allowed to handle requests, enhancing security and controlling access.</Description>
17+
<PackageProjectUrl>https://github.com/willysoft/LocalPortFiltering.AspNetCore</PackageProjectUrl>
18+
<RepositoryUrl>$(PackageProjectUrl)</RepositoryUrl>
19+
<RepositoryType>git</RepositoryType>
20+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
21+
<SignAssembly>true</SignAssembly>
22+
<AssemblyOriginatorKeyFile>opensource.snk</AssemblyOriginatorKeyFile>
23+
<IsPackable>true</IsPackable>
724
</PropertyGroup>
825

926
<ItemGroup>
596 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)