Skip to content

Publish

Publish #9

Workflow file for this run

name: Publish
on:
workflow_dispatch:
jobs:
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Build test apps (Client + Upgrade)
run: |
dotnet publish test_app/Client/ClientSample.csproj -c Release -r win-x64 -p:PublishSingleFile=true --self-contained -o prebuilt
dotnet publish test_app/Upgrade/UpgradeSample.csproj -c Release -r win-x64 -p:PublishSingleFile=true --self-contained -o prebuilt
- name: Publish Tools
run: >
dotnet publish src/GeneralUpdate.Tools.csproj
-c Release -r win-x64
-p:PublishSingleFile=true --self-contained
-p:IncludeNativeLibrariesForSelfExtract=true
-p:IncludeAllContentForSelfExtract=true
-o publish/win-x64
- name: Copy test apps into publish output
run: xcopy prebuilt\* publish\win-x64\test_app_exe\ /Y /I
- name: Upload
uses: actions/upload-artifact@v4
with:
name: win-x64
path: publish/win-x64/
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Build test apps (Client + Upgrade)
run: |
dotnet publish test_app/Client/ClientSample.csproj -c Release -r linux-x64 -p:PublishSingleFile=true --self-contained -o prebuilt
dotnet publish test_app/Upgrade/UpgradeSample.csproj -c Release -r linux-x64 -p:PublishSingleFile=true --self-contained -o prebuilt
- name: Publish Tools
run: >
dotnet publish src/GeneralUpdate.Tools.csproj
-c Release -r linux-x64
-p:PublishSingleFile=true --self-contained
-p:IncludeNativeLibrariesForSelfExtract=true
-p:IncludeAllContentForSelfExtract=true
-o publish/linux-x64
- name: Copy test apps into publish output
run: mkdir -p publish/linux-x64/test_app_exe && cp prebuilt/* publish/linux-x64/test_app_exe/
- name: Upload
uses: actions/upload-artifact@v4
with:
name: linux-x64
path: publish/linux-x64/
release:
needs: [build-windows, build-linux]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout for changelog
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
run: |
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
LOG=$(git log --oneline --no-decorate -100)
else
LOG=$(git log "${PREVIOUS_TAG}..HEAD" --oneline --no-decorate)
fi
FEATURES=""; FIXES=""; REFACTORS=""; TESTS=""; DOCS=""; CHORES=""; OTHERS=""
while IFS= read -r line; do
[ -z "$line" ] && continue
# Remove commit hash prefix
msg=$(echo "$line" | sed -E 's/^[a-f0-9]+ //')
case "$msg" in
feat:*|feature:*) FEATURES="${FEATURES}- ${msg}"$'\n' ;;
fix:*) FIXES="${FIXES}- ${msg}"$'\n' ;;
refactor:*) REFACTORS="${REFACTORS}- ${msg}"$'\n' ;;
test:*) TESTS="${TESTS}- ${msg}"$'\n' ;;
docs:*) DOCS="${DOCS}- ${msg}"$'\n' ;;
chore:*|cleanup:*|ci:*|build:*) CHORES="${CHORES}- ${msg}"$'\n' ;;
*) OTHERS="${OTHERS}- ${msg}"$'\n' ;;
esac
done <<< "$LOG"
BODY=""
append_section() {
if [ -n "$2" ]; then
BODY="${BODY}## $1"$'\n\n'"$2"$'\n'
fi
}
append_section "🚀 Features" "$FEATURES"
append_section "🐛 Bug Fixes" "$FIXES"
append_section "♻️ Refactoring" "$REFACTORS"
append_section "✅ Tests" "$TESTS"
append_section "📝 Documentation" "$DOCS"
append_section "🔧 Chores" "$CHORES"
append_section "📦 Other Changes" "$OTHERS"
[ -z "$BODY" ] && BODY="_No changes detected between tags._"
echo "$BODY" > changelog.md
echo "=== Generated changelog ==="
cat changelog.md
- uses: actions/download-artifact@v4
- name: Get timestamp
id: ts
run: echo "timestamp=$(date -u '+%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
- name: Package win
working-directory: win-x64
run: zip ../GeneralUpdate.Tools_${{ steps.ts.outputs.timestamp }}_win-x64.zip -r *
- name: Package linux
working-directory: linux-x64
run: |
chmod +x *
zip ../GeneralUpdate.Tools_${{ steps.ts.outputs.timestamp }}_linux-x64.zip -r *
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.ts.outputs.timestamp }}
name: GeneralUpdate.Tools ${{ steps.ts.outputs.timestamp }}
body_path: changelog.md
files: |
GeneralUpdate.Tools_${{ steps.ts.outputs.timestamp }}_win-x64.zip
GeneralUpdate.Tools_${{ steps.ts.outputs.timestamp }}_linux-x64.zip