Skip to content

Commit 54ce2b8

Browse files
committed
feat: publish
1 parent 3155906 commit 54ce2b8

File tree

14 files changed

+417
-0
lines changed

14 files changed

+417
-0
lines changed

.config/dotnet-tools.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
"nuke"
99
],
1010
"rollForward": false
11+
},
12+
"cake.tool": {
13+
"version": "5.0.0",
14+
"commands": [
15+
"dotnet-cake"
16+
],
17+
"rollForward": false
1118
}
1219
}
1320
}

.github/workflows/publish.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Publish Packages
2+
3+
on:
4+
push:
5+
tags:
6+
- '*-v*'
7+
8+
env:
9+
DOTNET_VERSION: '9.0.x'
10+
NUGET_SOURCE: 'https://api.nuget.org/v3/index.json'
11+
12+
jobs:
13+
detect-project:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
project: ${{ steps.detect.outputs.project }}
17+
version: ${{ steps.detect.outputs.version }}
18+
tag: ${{ steps.detect.outputs.tag }}
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Detect project and version from tag
26+
id: detect
27+
run: |
28+
TAG_NAME="${{ github.ref_name }}"
29+
echo "Processing tag: $TAG_NAME"
30+
31+
# Extract project name and version from tag (any project name)
32+
if [[ $TAG_NAME =~ ^(.+)-v(.+)$ ]]; then
33+
PROJECT_NAME="${BASH_REMATCH[1]}"
34+
VERSION="${BASH_REMATCH[2]}"
35+
echo "Detected project: $PROJECT_NAME"
36+
echo "Detected version: $VERSION"
37+
echo "project=$PROJECT_NAME" >> $GITHUB_OUTPUT
38+
echo "version=$VERSION" >> $GITHUB_OUTPUT
39+
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT
40+
else
41+
echo "Invalid tag format: $TAG_NAME"
42+
echo "Expected format: <projectname>-v<version>"
43+
exit 1
44+
fi
45+
46+
publish:
47+
needs: detect-project
48+
runs-on: ubuntu-latest
49+
if: needs.detect-project.outputs.project != ''
50+
51+
steps:
52+
- name: Checkout code
53+
uses: actions/checkout@v4
54+
55+
- name: Setup .NET
56+
uses: actions/setup-dotnet@v4
57+
with:
58+
dotnet-version: ${{ env.DOTNET_VERSION }}
59+
60+
- name: Cache NuGet packages
61+
uses: actions/cache@v4
62+
with:
63+
path: ~/.nuget/packages
64+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
65+
restore-keys: |
66+
${{ runner.os }}-nuget-
67+
68+
- name: Build and publish project
69+
uses: cake-build/cake-action@v3
70+
with:
71+
target: Publish
72+
script-path: build.cake
73+
arguments: --project="${{ needs.detect-project.outputs.project }}" --configuration=Release
74+
env:
75+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
76+
77+
- name: Upload packages as artifacts
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: nuget-packages-${{ needs.detect-project.outputs.project }}-${{ needs.detect-project.outputs.version }}
81+
path: ./output/packages/*.nupkg
82+
retention-days: 30
83+
84+
- name: Create GitHub Release
85+
id: create_release
86+
uses: softprops/action-gh-release@v2
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
with:
90+
tag_name: ${{ needs.detect-project.outputs.tag }}
91+
name: ${{ needs.detect-project.outputs.project }} ${{ needs.detect-project.outputs.version }}
92+
body: |
93+
## ${{ needs.detect-project.outputs.project }} ${{ needs.detect-project.outputs.version }}
94+
95+
### Changes
96+
- Automated release from tag ${{ needs.detect-project.outputs.tag }}
97+
98+
### Installation
99+
100+
**NuGet Package Manager:**
101+
```
102+
Install-Package ${{ needs.detect-project.outputs.project }} -Version ${{ needs.detect-project.outputs.version }}
103+
```
104+
105+
**PackageReference:**
106+
```xml
107+
<PackageReference Include="${{ needs.detect-project.outputs.project }}" Version="${{ needs.detect-project.outputs.version }}" />
108+
```
109+
110+
**dotnet CLI:**
111+
```
112+
dotnet add package ${{ needs.detect-project.outputs.project }} --version ${{ needs.detect-project.outputs.version }}
113+
```
114+
draft: false
115+
prerelease: false
116+
files: ./output/packages/${{ needs.detect-project.outputs.project }}.${{ needs.detect-project.outputs.version }}.nupkg

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,5 @@ Thumbs.db
397397

398398
# Project specific
399399
*.DotSettings
400+
.GetSecure.sln
401+
tools/

GetSecure.sln

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6209C30F-28C5-401C-B11A-F72A37E01C0C}"
7+
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetSecure.Core", "src\GetSecure.Core\GetSecure.Core.csproj", "{FB31899E-4773-496F-AAEE-0D3C0E9D060F}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GetSecure.CLI", "src\GetSecure.CLI\GetSecure.CLI.csproj", "{BD314A9A-E594-4BB0-8666-CDDDBD5290DB}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Release|Any CPU = Release|Any CPU
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
21+
{FB31899E-4773-496F-AAEE-0D3C0E9D060F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{FB31899E-4773-496F-AAEE-0D3C0E9D060F}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
{FB31899E-4773-496F-AAEE-0D3C0E9D060F}.Release|Any CPU.ActiveCfg = Release|Any CPU
24+
{FB31899E-4773-496F-AAEE-0D3C0E9D060F}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{BD314A9A-E594-4BB0-8666-CDDDBD5290DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{BD314A9A-E594-4BB0-8666-CDDDBD5290DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{BD314A9A-E594-4BB0-8666-CDDDBD5290DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{BD314A9A-E594-4BB0-8666-CDDDBD5290DB}.Release|Any CPU.Build.0 = Release|Any CPU
29+
EndGlobalSection
30+
GlobalSection(NestedProjects) = preSolution
31+
{FB31899E-4773-496F-AAEE-0D3C0E9D060F} = {6209C30F-28C5-401C-B11A-F72A37E01C0C}
32+
{BD314A9A-E594-4BB0-8666-CDDDBD5290DB} = {6209C30F-28C5-401C-B11A-F72A37E01C0C}
33+
EndGlobalSection
34+
EndGlobal

0 commit comments

Comments
 (0)