Skip to content

Merge branch 'master' of https://github.com/Tim-Maes/PrintZPL #30

Merge branch 'master' of https://github.com/Tim-Maes/PrintZPL

Merge branch 'master' of https://github.com/Tim-Maes/PrintZPL #30

Workflow file for this run

name: Build & Publish
on:
push:
branches:
- master
- main
tags:
- 'v*.*.*'
pull_request:
branches:
- master
- main
workflow_dispatch:
env:
CONFIGURATION: Release
PROJECT_PATH: src/PrintZPL.Host/PrintZPL.Host.csproj
FRAMEWORK: net8.0
jobs:
build:
runs-on: ubuntu-latest
name: Build & Validate
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build solution
run: dotnet build --configuration ${{ env.CONFIGURATION }} --no-restore
- name: Check for vulnerable packages
run: dotnet list package --vulnerable --include-transitive || true
- name: Check for deprecated packages
run: dotnet list package --deprecated || true
publish:
runs-on: ubuntu-latest
needs: [build]
strategy:
fail-fast: false
matrix:
runtime:
- win-x64
- linux-x64
- osx-x64
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore "${{ env.PROJECT_PATH }}"
- name: Publish single-file executable (${{ matrix.runtime }})
run: |
echo "Publishing for runtime: ${{ matrix.runtime }}"
dotnet publish "${{ env.PROJECT_PATH }}" \
-c ${{ env.CONFIGURATION }} \
-r ${{ matrix.runtime }} \
--self-contained true \
/p:PublishSingleFile=true \
/p:PublishTrimmed=true \
/p:TrimMode=Link \
/p:EnableCompressionInSingleFile=true
- name: Verify published files
run: |
PUBLISH_DIR="src/PrintZPL.Host/bin/${{ env.CONFIGURATION }}/${{ env.FRAMEWORK }}/${{ matrix.runtime }}/publish"
echo "Contents of publish directory:"
ls -la "$PUBLISH_DIR"
- name: Test published executable (${{ matrix.runtime }})
run: |
PUBLISH_DIR="src/PrintZPL.Host/bin/${{ env.CONFIGURATION }}/${{ env.FRAMEWORK }}/${{ matrix.runtime }}/publish"
if [[ "${{ matrix.runtime }}" == "win-x64" ]]; then
echo "Skipping Windows executable test on Linux runner"
else
chmod +x "$PUBLISH_DIR/PrintZPL.Host"
timeout 10s "$PUBLISH_DIR/PrintZPL.Host" --console || echo "Test completed (expected timeout or exit)"
fi
- name: Zip published output (${{ matrix.runtime }})
run: |
PUBLISH_DIR="src/PrintZPL.Host/bin/${{ env.CONFIGURATION }}/${{ env.FRAMEWORK }}/${{ matrix.runtime }}/publish"
ZIP_NAME="PrintZPL-${{ matrix.runtime }}.zip"
echo "Creating zip file: $ZIP_NAME"
cd "$PUBLISH_DIR"
zip -r "${{ github.workspace }}/$ZIP_NAME" .
echo "Zip file created, checking size:"
ls -la "${{ github.workspace }}/$ZIP_NAME"
- name: Upload artifact for ${{ matrix.runtime }}
uses: actions/upload-artifact@v4
with:
name: PrintZPL-${{ matrix.runtime }}
path: PrintZPL-${{ matrix.runtime }}.zip
if-no-files-found: error
release:
runs-on: ubuntu-latest
needs: publish
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: PrintZPL-*
merge-multiple: true
- name: List downloaded artifacts
run: |
echo "Downloaded artifacts:"
ls -la *.zip
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
PrintZPL-*.zip
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}