Skip to content

Release & Publish

Release & Publish #25

# 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
# Install and Setup GitVersion
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: Use GitVersion
# Step id is used as reference for the output values
id: gitversion
uses: gittools/actions/gitversion/execute@v0
# Setup .NET 6
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.x
# 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
}