Skip to content

Commit 59b92b3

Browse files
authored
Merge pull request #1 from stesee/automated-nuget.org-publish
Automated nuget.org publish
2 parents 15443ab + bc89736 commit 59b92b3

File tree

9 files changed

+140
-38
lines changed

9 files changed

+140
-38
lines changed

.github/workflows/dotnet.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,57 @@
1-
name: .NET
1+
name: .NET build and test
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, automated-nuget.org-publish ]
66
pull_request:
7-
branches: [ main ]
7+
branches: [ main, automated-nuget.org-publish ]
88

99
jobs:
1010
build:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
os: [macos-latest, ubuntu-latest, windows-latest]
14+
os: [ubuntu-latest, macos-latest, windows-latest]
1515
steps:
1616
- uses: actions/checkout@v2
1717
- name: Setup .NET
1818
uses: actions/setup-dotnet@v1
1919
with:
20-
dotnet-version: 5.0.x
20+
dotnet-version: 6.0.x
2121
- name: Restore dependencies
2222
run: dotnet restore
23-
- name: Bump versions
24-
uses: SiqiLu/dotnet-bump-version@master
25-
with:
26-
version_files: "**/*.csproj"
27-
github_token: ${{ secrets.GITHUB_TOKEN }}
2823
- name: Build
2924
run: dotnet build --configuration Release --no-restore
3025
- name: Test
31-
run: dotnet test --no-build --verbosity normal
26+
run: dotnet test --no-build --verbosity normal --configuration Release
3227
- name: "Build & test"
3328
run: |
3429
echo "done!"
3530
pwd
31+
32+
deploy:
33+
runs-on: ubuntu-latest
34+
needs: build
35+
if: github.ref == 'refs/heads/master'
36+
steps:
37+
- uses: actions/checkout@v2
38+
- name: Setup .NET
39+
uses: actions/setup-dotnet@v1
40+
with:
41+
dotnet-version: 6.0.x
42+
- name: Restore dependencies
43+
run: dotnet restore
44+
- name: Build
45+
run: dotnet build --configuration Release --no-restore
3646
- name: Publish
3747
run: dotnet publish --configuration Release --no-restore
48+
- name: NugetPush
49+
run: |
50+
ls ./GithubActionsHelloWorld/bin/Release
51+
dotnet nuget push ./GithubActionsHelloWorld/bin/Release/*.*nupkg --skip-duplicate --include-symbols -p:SymbolPackageFormat=snupkg --api-key ${{secrets.NUGET_TOKEN}} --source https://int.nugettest.org/
3852
- uses: papeloto/action-zip@v1
3953
with:
40-
files: ./bin/Release/net5.0/win-x64/publish/
54+
files: ./GithubActionsHelloWorld/bin/Release/net6.0/publish/
4155
dest: GithubActionsHelloWorld.zip
4256
- uses: "marvinpinto/action-automatic-releases@latest"
4357
with:

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"redhat.vscode-yaml"
4+
]
5+
}

GithubActionsHelloWorld.csproj

Lines changed: 0 additions & 14 deletions
This file was deleted.

GithubActionsHelloWorld.sln

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31702.278
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GithubActionsHelloWorld", "GithubActionsHelloWorld\GithubActionsHelloWorld.csproj", "{61D51FF5-54B5-4D4D-8374-0476FF605F57}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GithubActionsHelloWorldTests", "GithubActionsHelloWorldTests\GithubActionsHelloWorldTests.csproj", "{1756945F-FE1B-498C-897C-743DD7B791DA}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A0700FEC-48D8-490C-8136-B200F4317767}"
11+
ProjectSection(SolutionItems) = preProject
12+
.github\workflows\dotnet.yml = .github\workflows\dotnet.yml
13+
EndProjectSection
14+
EndProject
15+
Global
16+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
17+
Debug|Any CPU = Debug|Any CPU
18+
Release|Any CPU = Release|Any CPU
19+
EndGlobalSection
20+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
21+
{61D51FF5-54B5-4D4D-8374-0476FF605F57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{61D51FF5-54B5-4D4D-8374-0476FF605F57}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
{61D51FF5-54B5-4D4D-8374-0476FF605F57}.Release|Any CPU.ActiveCfg = Release|Any CPU
24+
{61D51FF5-54B5-4D4D-8374-0476FF605F57}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{1756945F-FE1B-498C-897C-743DD7B791DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{1756945F-FE1B-498C-897C-743DD7B791DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{1756945F-FE1B-498C-897C-743DD7B791DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{1756945F-FE1B-498C-897C-743DD7B791DA}.Release|Any CPU.Build.0 = Release|Any CPU
29+
EndGlobalSection
30+
GlobalSection(SolutionProperties) = preSolution
31+
HideSolutionNode = FALSE
32+
EndGlobalSection
33+
GlobalSection(ExtensibilityGlobals) = postSolution
34+
SolutionGuid = {DF7E6DBA-1CE0-4A5B-932A-0759477DD349}
35+
EndGlobalSection
36+
EndGlobal
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<Version Condition="'$(GITHUB_RUN_NUMBER)' != ''">1.0.$(GITHUB_RUN_NUMBER)</Version>
7+
<Version Condition="'$(GITHUB_RUN_NUMBER)' == ''">0.0.1</Version>
8+
<AssemblyVersion>$(Version)</AssemblyVersion>
9+
<FileVersion>$(Version)</FileVersion>
10+
<PackageVersion>$(Version)</PackageVersion>
11+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
12+
<IncludeSymbols>true</IncludeSymbols>
13+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
14+
<PackageId>GithubActionsHelloWorld</PackageId>
15+
</PropertyGroup>
16+
17+
</Project>

GithubActionsHelloWorld/Program.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
4+
namespace GithubActionsHelloWorld
5+
{
6+
public class Program
7+
{
8+
public async static Task Main(string[] args)
9+
{
10+
await Task.Delay(100);
11+
Console.WriteLine("Hello World!");
12+
}
13+
}
14+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using GithubActionsHelloWorld;
2+
using System.Threading.Tasks;
3+
using Xunit;
4+
5+
namespace GithubActionsHelloWorldTests
6+
{
7+
public class GithubActionsHelloWorldTest
8+
{
9+
[Fact]
10+
public async Task Main_ShouldRunWithoutError()
11+
{
12+
var args = new string[] { "WrongParameterCount" };
13+
await Program.Main(args);
14+
}
15+
}
16+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
11+
<PackageReference Include="xunit" Version="2.4.1" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
13+
<PrivateAssets>all</PrivateAssets>
14+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15+
</PackageReference>
16+
<PackageReference Include="coverlet.collector" Version="3.1.0">
17+
<PrivateAssets>all</PrivateAssets>
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19+
</PackageReference>
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<ProjectReference Include="..\GithubActionsHelloWorld\GithubActionsHelloWorld.csproj" />
24+
</ItemGroup>
25+
26+
</Project>

Program.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)