Skip to content

Commit

Permalink
feat(workflows): Added NuGet publishing step
Browse files Browse the repository at this point in the history
  • Loading branch information
ViMaSter committed Feb 28, 2023
1 parent 647dfdf commit 998947e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build (and Release)
name: Build, Release, Publish

on:
push:
Expand Down Expand Up @@ -99,24 +99,25 @@ jobs:
needs: [ unit-test, integration-test ]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v3

- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && secrets.ELEVATED_GITHUB_TOKEN || github.token }}

- name: Setup .NET
uses: actions/setup-dotnet@v3

- name: Build
run: dotnet build --configuration Release
- name: Install Versionize
run: dotnet tool install --global Versionize

- name: Setup git
run: |
git config --local user.email "[email protected]"
git config --local user.name "Versionize Bot"
- name: Versionize Release
- name: Install Versionize
run: dotnet tool install --global Versionize

- name: Run Versionize
id: versionize
run: 'versionize --changelog-all --exit-insignificant-commits --commit-suffix " [skip ci]"'
continue-on-error: true
Expand All @@ -132,6 +133,10 @@ jobs:
github_token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
branch: ${{ github.ref }}
tags: true

- name: Create NuPkg
if: steps.versionize.outcome == 'success'
run: dotnet pack --configuration Release

- name: Download ubuntu artifacts
if: steps.versionize.outcome == 'success'
Expand Down Expand Up @@ -160,6 +165,7 @@ jobs:
zip -r ScorecardGenerator-ubuntu-x64-$version.zip ubuntu-artifacts
zip -r ScorecardGenerator-windows-x64-$version.zip windows-artifacts
zip -r ScorecardGenerator-macos-x64-$version.zip macos-artifacts
zip -r ScorecardGenerator-nupkg-x64-$version.zip ScorecardGenerator/nupkg/*.nupkg -j
if: steps.versionize.outcome == 'success'
- name: "Create release with all artifacts"
Expand All @@ -173,9 +179,20 @@ jobs:
--target ${{ github.sha }} \
--title "$version" \
-F CHANGELOG.md \
ScorecardGenerator-nupkg-x64-$version.zip \
ScorecardGenerator-ubuntu-x64-$version.zip \
ScorecardGenerator-windows-x64-$version.zip \
ScorecardGenerator-macos-x64-$version.zip
env:
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
shell: bash

- name: Publish to NuGet
if: steps.versionize.outcome == 'success'
run: |
version=$(git describe --tags --abbrev=0)
dotnet nuget push ScorecardGenerator/nupkg/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
env:
GITHUB_TOKEN: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
shell: bash
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ riderModule.iml
.DS_Store

# vale
styles
styles

# nuget packages
nupkg/
27 changes: 5 additions & 22 deletions ScorecardGenerator/ScorecardGenerator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Version>1.1.0</Version>
<PackAsTool>true</PackAsTool>
<PackageOutputPath>./nupkg</PackageOutputPath>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Description>Generate Azure Wiki-friendly markdown files with scores for dotnet projects.</Description>
<PackageProjectUrl>https://github.com/ViMaSter/service-scorecard-generator</PackageProjectUrl>
Expand Down Expand Up @@ -37,28 +37,11 @@
<EmbeddedResource Include="Checks\PendingRenovateAzurePRs\README.md" />
<EmbeddedResource Include="Checks\ProperDockerfile\README.md" />
</ItemGroup>

<ItemGroup>
<None Include="..\LICENSE" Pack="true" PackagePath=""/>
<None Include="..\README.md" Pack="true" PackagePath=""/>
<Version>1.0.0</Version>
<PackAsTool>true</PackAsTool>
<PackageOutputPath>./nupkg</PackageOutputPath>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Description>Generate Azure Wiki-friendly markdown files with scores for dotnet projects.</Description>
<PackageProjectUrl>https://github.com/ViMaSter/service-scorecard-generator</PackageProjectUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/ViMaSter/service-scorecard-generator.git</RepositoryUrl>
<Authors>Vincent Mahnke ([email protected])</Authors>
<Copyright>(c) 2023 by Vincent Mahnke</Copyright>
<PackageTags>dotnet;csharp;azure-devops;markdown</PackageTags>
<PackageReleaseNotes>Check CHANGELOG.md</PackageReleaseNotes>
<None Include="..\README.md" Pack="true" PackagePath="README.md">
<Link>README.md</Link>
</None>
</ItemGroup>

<ItemGroup>
<None Include="..\LICENSE" Pack="true" PackagePath=""/>
<None Include="..\README.md" Pack="true" PackagePath=""/>
</ItemGroup>

</Project>

0 comments on commit 998947e

Please sign in to comment.