Skip to content

Commit d7fe7bb

Browse files
committed
Publish via NuGet Trusted Publishing
1 parent 9b125be commit d7fe7bb

4 files changed

Lines changed: 74 additions & 38 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
name: .NET Core
1+
name: Build
22

33
on:
4-
push:
5-
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
4+
workflow_call:
85

96
jobs:
107
build:
@@ -16,15 +13,15 @@ jobs:
1613
os: [ windows-latest, macos-latest, ubuntu-latest ]
1714

1815
steps:
19-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v6
2017
with:
2118
fetch-depth: 0
2219
- name: Setup .NET 6
23-
uses: actions/setup-dotnet@v4
20+
uses: actions/setup-dotnet@v5
2421
with:
2522
dotnet-version: 6.0.x
2623
- name: Setup .NET 8
27-
uses: actions/setup-dotnet@v4
24+
uses: actions/setup-dotnet@v5
2825
with:
2926
dotnet-version: 8.0.x
3027
- name: Install dependencies
@@ -44,33 +41,3 @@ jobs:
4441
test -s Samples/AspNetCore.SassCompiler.Sample/wwwroot/css/site_sass.css
4542
test -s Samples/AspNetCore.SassCompiler.Sample/wwwroot/lib/css/lib.min.css
4643
47-
publish:
48-
runs-on: ubuntu-latest
49-
needs: [ build ]
50-
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
51-
steps:
52-
- uses: actions/checkout@v4
53-
with:
54-
fetch-depth: 0
55-
- name: Setup .NET 6
56-
uses: actions/setup-dotnet@v4
57-
with:
58-
dotnet-version: 6.0.x
59-
- name: Setup .NET 8
60-
uses: actions/setup-dotnet@v4
61-
with:
62-
dotnet-version: 8.0.x
63-
- name: Publish NuGet
64-
id: publish_nuget
65-
uses: alirezanet/publish-nuget@v3.1.0
66-
with:
67-
PROJECT_FILE_PATH: AspNetCore.SassCompiler/AspNetCore.SassCompiler.csproj
68-
PACKAGE_NAME: AspNetCore.SassCompiler
69-
env:
70-
NUGET_KEY: ${{ secrets.NUGET_KEY }}
71-
- name: Create release
72-
id: create_release
73-
if: success() && steps.publish_nuget.outputs.version != ''
74-
run: gh release create ${{ steps.publish_nuget.outputs.version }} --generate-notes
75-
env:
76-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: PR validation
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
7+
jobs:
8+
build:
9+
uses: ./.github/workflows/build.yml

.github/workflows/release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
7+
jobs:
8+
build:
9+
uses: ./.github/workflows/build.yml
10+
11+
publish:
12+
runs-on: ubuntu-latest
13+
needs: [ build ]
14+
permissions:
15+
id-token: write
16+
contents: write
17+
steps:
18+
- uses: actions/checkout@v6
19+
with:
20+
fetch-depth: 0
21+
- name: Setup .NET 6
22+
uses: actions/setup-dotnet@v5
23+
with:
24+
dotnet-version: 6.0.x
25+
- name: Setup .NET 8
26+
uses: actions/setup-dotnet@v5
27+
with:
28+
dotnet-version: 8.0.x
29+
- name: NuGet Login
30+
uses: NuGet/login@v1
31+
id: login
32+
with:
33+
user: koenvzeijl
34+
- name: Publish NuGet
35+
id: publish_nuget
36+
uses: alirezanet/publish-nuget@v3.1.0
37+
with:
38+
PROJECT_FILE_PATH: AspNetCore.SassCompiler/AspNetCore.SassCompiler.csproj
39+
PACKAGE_NAME: AspNetCore.SassCompiler
40+
env:
41+
NUGET_KEY: ${{ steps.login.outputs.NUGET_API_KEY }}
42+
- name: Create release
43+
id: create_release
44+
if: success() && steps.publish_nuget.outputs.version != ''
45+
run: gh release create ${{ steps.publish_nuget.outputs.version }} --generate-notes
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Directory.Build.props

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<DebugType>embedded</DebugType>
5+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
6+
<RepositoryBranch Condition="'$(GITHUB_REF)' != ''">$(GITHUB_REF)</RepositoryBranch>
7+
</PropertyGroup>
8+
9+
<PropertyGroup>
10+
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
11+
</PropertyGroup>
12+
13+
</Project>

0 commit comments

Comments
 (0)