Skip to content

Commit

Permalink
Refactored the ci/cd to auto push to nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
ByronMayne committed Nov 3, 2023
1 parent c649338 commit f9efba8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 37 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"gitversion.tool": {
"version": "5.12.0",
"commands": [
"dotnet-gitversion"
]
}
}
}
2 changes: 0 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ on:

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v3
with:
Expand Down
41 changes: 10 additions & 31 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ on:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
SOLUTION_PATH: ./src/SourceGenerator.Foundations.sln
Configuration: Release
ProjectDir: src\SourceGenerator.Foundations\
ProjectName: SourceGenerator.Foundations.csproj
SolutionPath: src\SourceGenerator.Foundations.sln
jobs:
publish:
name: build, bundle & publish
Expand All @@ -21,33 +24,9 @@ jobs:
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
# Restore
- name: Restore dependencies
run: dotnet restore $env:SOLUTION_PATH
# Build
- name: Build
run: dotnet build $env:SOLUTION_PATH --no-restore
# Test
- name: Test
run: dotnet test $env:SOLUTION_PATH --no-build --verbosity normal
# Publish
- name: publish on version change
id: publish_nuget
uses: brandedoutcast/publish-nuget@v2
with:
# Filepath of the project to be packaged, relative to root of repository
PROJECT_FILE_PATH: $env:PROJECT_PATH
# Platform target to compile (default is empty/AnyCPU)
BUILD_PLATFORM: x64
# NuGet package id, used for version detection & defaults to project name
PACKAGE_NAME: SourceGenerator.Foundations
# Flag to toggle git tagging, enabled by default
TAG_COMMIT: true
# Format of the git tag, [*] gets replaced with actual version
TAG_FORMAT: '*'
# API key to authenticate with NuGet server
NUGET_KEY: ${{secrets.NUGET_API_KEY}}
# NuGet server uri hosting the packages, defaults to https://api.nuget.org
NUGET_SOURCE: https://api.nuget.org
# Flag to toggle pushing symbols along with nuget package to the server, disabled by default
INCLUDE_SYMBOLS: true
- run: dotnet tool restore
- run: dotnet gitversion /output buildserver
- run: dotnet build ${{env.SolutionPath}} -t:build -p:Version=${{env.GitVersion_AssemblySemVer}}
- run: dotnet test ${{env.SolutionPath}}
- run: dotnet build ${{env.SolutionPath}} -t:pack -p:PackageVersion=${{env.GitVersion_SemVer}}
- run: dotnet nuget push ${{env.ProjectDir}}${{env.Configuration}}\*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json
3 changes: 0 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project>
<PropertyGroup>
<Version>1.2.1</Version>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<IncludeBuildOutput>false</IncludeBuildOutput>
<IsRoslynComponent>true</IsRoslynComponent>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>false</IncludeSymbols>
<Title>Source Generator Foundations</Title>
<Authors>Byron Mayne</Authors>
Expand Down

0 comments on commit f9efba8

Please sign in to comment.