Skip to content

Release & Publish

Release & Publish #31

# Build the tools, create zip-file, create a tag
# and release, and publish to Chocolatey.
# MANUAL TRIGGERED WORKFLOW
name: Release & Publish
on:
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
# Checkout sources. Depth=0 is for using GitVersion
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
# Install and Setup GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'
# Step id is used as reference for the output values
- name: Use GitVersion to determine the version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
# Build the tools & create the zip-file and nuget packages
# Chocolatey tools are in .\tools. NuGet packages in .\artifacts
- name: Build & Package
run: pwsh .\build.ps1
# Create the CHANGELOG for this release
# We'll compile it from last the version
# to the current commit
- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v1
with:
configuration: "./changelog-config.json"
fromTag: ${{ steps.gitversion.outputs.VersionSourceSha }}
toTag: ${{ steps.gitversion.outputs.Sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Create GitHub release with created zip-file and CHANGELOG for Chocolatey and releases
# NOTE: this is where we prepend "v" before the version in the tag/release
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "./tools.zip"
body: ${{steps.github_release.outputs.changelog}}
tag: "v${{ steps.gitversion.outputs.MajorMinorPatch }}"
token: ${{ secrets.GITHUB_TOKEN }}
# package and publish Chocolatey package for this version
# We publish the nuspec file which references the tools.zip in releases.
- name: Publish to Chocolatey
env:
CHOCO_TOKEN: ${{ secrets.CHOCO_TOKEN }}
run: pwsh .\pack.ps1 -publish -version ${{ steps.gitversion.outputs.MajorMinorPatch }}
# Publish all NuGet packages to NuGet.org
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
# If you retry a failed workflow, already published packages will be skipped without error.
- name: Publish separate tools to NuGet
run: |
foreach($file in (Get-ChildItem "./artifacts" -Recurse -Include *.nupkg)) {
dotnet nuget push $file --api-key "${{ secrets.NUGET_TOOLS }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
}