Skip to content

Commit 35a86b5

Browse files
authored
add github workflow for nuget publishing
1 parent 789790d commit 35a86b5

File tree

5 files changed

+93
-3
lines changed

5 files changed

+93
-3
lines changed

.github/workflows/publish.yml

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
build:
10+
runs-on: windows-latest
11+
12+
steps:
13+
- name: Extract version from tag
14+
uses: nowsprinting/check-version-format-action@v3
15+
id: version
16+
with:
17+
prefix: 'v'
18+
19+
- name: Invalid version tag
20+
if: steps.version.outputs.is_valid != 'true'
21+
run: |
22+
echo "Version tag format invalid: ${{ steps.version.outputs.full }}"
23+
exit 1
24+
25+
- name: Checkout
26+
uses: actions/checkout@v3
27+
with:
28+
fetch-depth: 0 # Mandatory to use exact version from tag action
29+
30+
- name: Setup .NET
31+
uses: actions/setup-dotnet@v3
32+
with:
33+
global-json-file: global.json
34+
35+
- name: Check version
36+
# assert version match with project version so only pre-release label can be changed based on release tag
37+
run: dotnet build Remote.Linq.sln -t:CheckVersion -c Release -p BuildVersion="${{ steps.version.outputs.major_without_prefix }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}"
38+
39+
- name: Set version info
40+
run: |
41+
$VersionPrefix="${{ steps.version.outputs.major_without_prefix }}.${{ steps.version.outputs.minor }}.${{ steps.version.outputs.patch }}"
42+
$VersionSuffix="${{ steps.version.outputs.prerelease }}"
43+
$IsStable="${{ steps.version.outputs.is_stable }}"
44+
if ( -not $VersionSuffix ) {
45+
$Version=$VersionPrefix
46+
} else {
47+
$Version="$VersionPrefix-$VersionSuffix"
48+
}
49+
echo "VersionPrefix=$VersionPrefix" >> $Env:GITHUB_ENV
50+
echo "VersionSuffix=$VersionSuffix" >> $Env:GITHUB_ENV
51+
echo "Version=$Version" >> $Env:GITHUB_ENV
52+
echo "IsStable=$IsStable" >> $Env:GITHUB_ENV
53+
echo "Create release: v$Version"
54+
55+
- name: Build
56+
run: dotnet test Remote.Linq.sln -c Release /bl
57+
58+
- name: Upload build log
59+
uses: actions/upload-artifact@v3
60+
with:
61+
name: msbuild_log
62+
path: msbuild.binlog
63+
if-no-files-found: error
64+
65+
- name: Upload packages
66+
uses: actions/upload-artifact@v3
67+
with:
68+
name: nuget_packages
69+
path: artifacts
70+
if-no-files-found: error
71+
72+
- name: Publish packages
73+
env:
74+
MYGET_AUTH_TOKEN: ${{ secrets.MYGET_AUTH_TOKEN }}
75+
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_AUTH_TOKEN }}
76+
run: |
77+
dotnet nuget push artifacts\*.nupkg -k "$env:MYGET_AUTH_TOKEN" -s https://www.myget.org/F/aqua/api/v3/index.json
78+
dotnet nuget push artifacts\*.nupkg -k "$env:NUGET_AUTH_TOKEN" -s https://api.nuget.org/v3/index.json

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ nuget.exe
2929
*.db
3030
.vs/
3131
config.test.json
32+
*.binlog
3233
*.log
3334
/.build/
3435
.testPublish/

Directory.Build.props

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
<MajorVersion>7</MajorVersion>
66
<MinorVersion>2</MinorVersion>
77
<PatchVersion>0</PatchVersion>
8-
<PreReleaseLabel>alpha-002</PreReleaseLabel>
9-
<AquaCoreVersion>5.4.0-alpha-001</AquaCoreVersion>
8+
<PreReleaseLabel>dev</PreReleaseLabel>
9+
<AquaCoreVersion>5.4.0-alpha-002</AquaCoreVersion>
1010
</PropertyGroup>
1111

1212
<PropertyGroup>
@@ -61,7 +61,7 @@
6161
</PropertyGroup>
6262

6363
<ItemGroup>
64-
<PackageReference Include="aqua.tool.Validation" Version="3.0.0-alpha-004" PrivateAssets="all" />
64+
<PackageReference Include="aqua.tool.Validation" Version="3.0.0" PrivateAssets="all" />
6565
</ItemGroup>
6666

6767
<ItemGroup>

Directory.Build.targets

+5
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@
1414
<Output PropertyName="SourceRevisionId" TaskParameter="ConsoleOutput"/>
1515
</Exec>
1616
</Target>
17+
<Target Name="CheckVersion">
18+
<Message Text="Check Version: '$(BuildVersion)' == '$(VersionPrefix)' [$(MSBuildProjectFile)]" Importance="high" />
19+
<Error Condition=" '$(BuildVersion)' == '' " Text="Build version must not be emty" />
20+
<Error Condition=" '$(BuildVersion)' != '$(VersionPrefix)' " Text="Build version '$(BuildVersion)' does not match project version '$(VersionPrefix)'" />
21+
</Target>
1722
</Project>

global.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "8.0.100",
4+
"rollForward": "latestFeature"
5+
}
6+
}

0 commit comments

Comments
 (0)