Skip to content

Merge pull request #602 from LogExperts/bugfixes_toolservice_and_unit… #6

Merge pull request #602 from LogExperts/bugfixes_toolservice_and_unit…

Merge pull request #602 from LogExperts/bugfixes_toolservice_and_unit… #6

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
pull-requests: write
jobs:
release:
runs-on: windows-latest
name: Build and Release ${{ github.ref_name }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for GitVersion to compute version from tags
- name: Install .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Install InnoSetup
run: choco install innosetup --no-progress -y
- name: Build and Package
run: ./build.ps1 --target Clean Pack --configuration Release
- name: Install nuget-license tool
run: dotnet tool install --global nuget-license
- name: Update usedComponents.json
shell: pwsh
run: |
# Generate updated component list (packages already restored by build).
# -override supplies license info for packages whose nuspec omits it (e.g. Nuke.GitHub),
# which otherwise makes nuget-license exit non-zero.
$output = nuget-license -i src/LogExpert.sln -o JsonPretty -override "src/Solution Items/nuget-license-overrides.json"
if ($LASTEXITCODE -ne 0) {
Write-Host "::error::nuget-license failed with exit code $LASTEXITCODE"
Write-Host $output
exit 1
}
Set-Content -Path "src/Solution Items/usedComponents.json" -Value $output -Encoding UTF8
- name: Open PR with generated files
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Save generated files before switching branches (checkout would overwrite them)
$tempComponents = [System.IO.Path]::GetTempFileName()
$tempHashes = [System.IO.Path]::GetTempFileName()
Copy-Item "src/Solution Items/usedComponents.json" $tempComponents
Copy-Item "src/PluginRegistry/PluginHashGenerator.Generated.cs" $tempHashes
# Development is PR-protected, so apply the updates on a fresh branch off Development
git fetch origin Development
$branch = "chore/generated-files-${{ github.ref_name }}"
git checkout -B $branch origin/Development
Copy-Item $tempComponents "src/Solution Items/usedComponents.json"
Copy-Item $tempHashes "src/PluginRegistry/PluginHashGenerator.Generated.cs"
git add "src/Solution Items/usedComponents.json"
git add "src/PluginRegistry/PluginHashGenerator.Generated.cs"
git diff --staged --quiet
if ($LASTEXITCODE -eq 0) {
Write-Host "No changes to commit; skipping PR."
exit 0
}
git commit -m "chore: update plugin hashes and usedComponents.json for ${{ github.ref_name }} [skip ci]"
# Force-push so re-running the release for the same tag updates the existing branch
git push --force origin $branch
# Create the PR if one does not already exist for this branch
$existing = gh pr list --head $branch --base Development --state open --json number --jq '.[0].number'
if ([string]::IsNullOrWhiteSpace($existing)) {
gh pr create --base Development --head $branch `
--title "chore: update generated files for ${{ github.ref_name }} [skip ci]" `
--body "Automated update of plugin hashes and ``usedComponents.json`` for release ${{ github.ref_name }}."
} else {
Write-Host "PR #$existing already exists for $branch"
}
# Best-effort auto-merge. Will complete once branch rules are satisfied;
# if the ruleset requires a manual review, merge the PR by hand.
gh pr merge $branch --auto --squash --delete-branch 2>&1 | Write-Host
if ($LASTEXITCODE -ne 0) {
Write-Host "::warning::Could not enable auto-merge for $branch; merge the PR manually."
}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
bin/LogExpert-Setup-*.exe
bin/LogExpert.*.zip
bin/LogExpert.ColumnizerLib.*.nupkg
bin/SftpFileSystem.x64.*.zip
bin/SftpFileSystem.x86.*.zip
bin/chocolatey/logexpert.*.nupkg
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}