Skip to content

Commit

Permalink
Merge pull request #12 from IntelliTect/CreateNugetPipeline
Browse files Browse the repository at this point in the history
Add pipeline so nuget package can be easily deployed
  • Loading branch information
BenjaminMichaelis authored Oct 3, 2022
2 parents a591ff3 + 8a1f378 commit 9f4fac5
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and Test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

defaults:
run:
shell: pwsh

jobs:
build-and-test:
name: build-and-test on ${{matrix.os}}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
3.1.x
6.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build -p:ContinuousIntegrationBuild=True --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal
76 changes: 76 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Deploy

on:
release:
types: [created]

defaults:
run:
shell: pwsh

env:
baseVersion: 1.0.0

jobs:
build-and-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
3.1.x
6.x
- name: Restore dependencies
run: dotnet restore
- name: Set Version
run: |
echo "${{ github.ref }}"
if ("${{ github.ref }}".startsWith("refs/tags/v")) {
$tagVersion = "${{ github.ref }}".substring(11)
echo "buildVersion=$tagVersion.${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "nugetVersion=$tagVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "preRelease=false" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
} else {
echo "buildVersion=${{ env.baseVersion }}.${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "nugetVersion=${{ env.baseVersion }}-ci${{ github.run_number }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
- name: Build
run: dotnet build -p:Version=${{ env.buildVersion }} -p:ContinuousIntegrationBuild=True --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal
- name: Pack
if: startsWith(github.ref, 'refs/tags/v')
run: dotnet pack -p:PackageVersion=${{ env.nugetVersion }} --configuration Release -o ${{env.DOTNET_ROOT}}/IntelliTect.ListingManagerPack --no-build
- name: Upload Artifacts
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v2
with:
name: NuGet
path: ${{env.DOTNET_ROOT}}/IntelliTect.ListingManagerPack

deploy:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: build-and-test
environment:
name: 'Production'
url: 'https://www.nuget.org/packages/IntelliTect.EssentialCSharp.ListingManager'
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: NuGet
- name: Push NuGet
run: |
$tagVersion = "${{ github.ref }}".substring(11)
echo "::set-output name=TAG_VERSION::$tagVersion"
dotnet nuget push IntelliTect.EssentialCSharp.ListingManager.$tagVersion.nupkg --source https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate
id: tag-version
- name: Upload nupkg to Releases
uses: softprops/action-gh-release@v1
with:
fail_on_unmatched_files: true
generate_release_notes: true
files: IntelliTect.EssentialCSharp.ListingManager.${{ steps.tag-version.outputs.TAG_VERSION }}.nupkg
30 changes: 29 additions & 1 deletion ListingManager/ListingManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<PackAsTool>true</PackAsTool>
<ToolCommandName>ListingManager</ToolCommandName>
<RepositoryType>git</RepositoryType>
<Deterministic>true</Deterministic>
<PackageTags>IntelliTect, EssentialCSharp, ListingManager</PackageTags>
<Authors>IntelliTect</Authors>
<Version>0.1.5</Version>
<PackageId>IntelliTect.EssentialCSharp.ListingManager</PackageId>
Expand All @@ -13,10 +16,35 @@
<LangVersion>10</LangVersion>
<Nullable>enable</Nullable>
<NoWarn>CS1591</NoWarn>
</PropertyGroup>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/IntelliTect/ListingManager</PackageProjectUrl>
<RepositoryUrl>https://github.com/IntelliTect/ListingManager</RepositoryUrl>
<!-- Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>

<!-- Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<ItemGroup>
<None Include="../README.md" Pack="true" PackagePath="\"/>
<SourceRoot Include="$(MSBuildThisFileDirectory)/"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.CommandLine.DragonFruit" Version="0.4.0-alpha.22114.1" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>

0 comments on commit 9f4fac5

Please sign in to comment.