Files

109 lines
3.9 KiB
YAML

name: Publish
on:
workflow_dispatch:
push:
paths-ignore:
- "**/README.md"
- "**/.gitignore"
- "**/.editorconfig"
- "**/LICENSE.md"
- .github/**
- src/BGR.Console.Tests/**
branches:
- main
jobs:
version:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
token: ${{ secrets.ACTIONS_PAT }}
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
- name: Install versionize
run: dotnet tool install --global Versionize
- name: Setup git
run: |
git config --local user.email "65925598+StevanFreeborn@users.noreply.github.com"
git config --local user.name "Stevan Freeborn"
- name: Run versionize
id: versionize
run: |
VERSION=$(versionize -i --exit-insignificant-commits --workingDir ./src/BGR.Console --commit-suffix "[skip ci]")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
continue-on-error: true
- name: Ensure csproj version is updated
if: steps.versionize.outcome == 'success'
run: |
VERSION="${{ steps.versionize.outputs.version }}"
NUMERIC="${VERSION#v}"
sed -i "s|<Version>.*</Version>|<Version>${NUMERIC}</Version>|" src/BGR.Console/BGR.Console.csproj
git add src/BGR.Console/BGR.Console.csproj
git diff --cached --quiet || git commit --amend --no-edit
- name: Upload changelog
if: steps.versionize.outcome == 'success'
uses: actions/upload-artifact@v7
with:
name: change-log
path: src/BGR.Console/CHANGELOG.md
- name: Push changes to GitHub
if: steps.versionize.outcome == 'success'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.ACTIONS_PAT }}
branch: ${{ github.ref }}
tags: true
outputs:
is_new_version: ${{ steps.versionize.outcome == 'success' }}
version: ${{ steps.versionize.outputs.version }}
publish:
needs: [version]
if: needs.version.outputs.is_new_version == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ github.ref }}
token: ${{ secrets.ACTIONS_PAT }}
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
- name: Build
run: dotnet build src
- name: Publish for mac-os
run: dotnet publish src/BGR.Console/BGR.Console.csproj -c Release -r osx-x64 --self-contained -o dist/mac-os
- name: Create zip for mac-os
run: zip -j dist/bgr_osx_x64.zip dist/mac-os/*
- name: Publish for linux-os
run: dotnet publish src/BGR.Console/BGR.Console.csproj -c Release -r linux-x64 --self-contained -o dist/linux-os
- name: Create zip for linux-os
run: zip -j dist/bgr_linux_x64.zip dist/linux-os/*
- name: Publish for windows-os
run: dotnet publish src/BGR.Console/BGR.Console.csproj -c Release -r win-x64 --self-contained -o dist/windows-os
- name: Create zip for windows-os
run: zip -j dist/bgr_windows_x64.zip dist/windows-os/*
- name: Download changlog
uses: actions/download-artifact@v8
with:
name: change-log
path: src/BGR.Console
- name: Create release
uses: softprops/action-gh-release@v3
with:
token: ${{ secrets.ACTIONS_PAT }}
name: bgr ${{ needs.version.outputs.version }}
tag_name: ${{ needs.version.outputs.version }}
draft: false
body_path: src/BGR.Console/CHANGELOG.md
files: |
dist/bgr_osx_x64.zip
dist/bgr_linux_x64.zip
dist/bgr_windows_x64.zip