Release v3.1.1 (#66) #169
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| release: | |
| types: [ published ] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| DOTNET_VERSION: '9.0.x' | |
| PROJECT_NAME: 'ZPL2PDF' | |
| jobs: | |
| # Build, Test, and Publish | |
| build-test-publish: | |
| name: Build & Test (${{ matrix.name }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Main platforms with tests | |
| - name: Windows x64 | |
| os: windows-latest | |
| runtime: win-x64 | |
| run_tests: true | |
| - name: Linux x64 | |
| os: ubuntu-latest | |
| runtime: linux-x64 | |
| run_tests: true | |
| - name: macOS x64 | |
| os: macos-latest | |
| runtime: osx-x64 | |
| run_tests: true | |
| # Additional cross-platform builds (no tests) | |
| - name: Windows x86 | |
| os: ubuntu-latest | |
| runtime: win-x86 | |
| run_tests: false | |
| - name: Linux ARM64 | |
| os: ubuntu-latest | |
| runtime: linux-arm64 | |
| run_tests: false | |
| - name: Linux ARM | |
| os: ubuntu-latest | |
| runtime: linux-arm | |
| run_tests: false | |
| - name: macOS ARM64 | |
| os: ubuntu-latest | |
| runtime: osx-arm64 | |
| run_tests: false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v5 | |
| 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 Release --no-restore | |
| - name: Run unit tests | |
| if: matrix.run_tests == true | |
| run: dotnet test tests/ZPL2PDF.Unit/ --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage" | |
| - name: Run integration tests | |
| if: matrix.run_tests == true | |
| run: dotnet test tests/ZPL2PDF.Integration/ --configuration Release --no-build --verbosity normal | |
| - name: Publish application | |
| run: dotnet publish ${{ env.PROJECT_NAME }}.csproj --configuration Release --runtime ${{ matrix.runtime }} --self-contained true --output ./publish/${{ matrix.runtime }} | |
| - name: Create archive | |
| shell: bash | |
| run: | | |
| cd ./publish/${{ matrix.runtime }} | |
| if [[ "${{ matrix.runtime }}" == win-* ]]; then | |
| if [[ "${{ runner.os }}" == "Windows" ]]; then | |
| powershell -Command "Compress-Archive -Path * -DestinationPath ../ZPL2PDF-${{ matrix.runtime }}.zip -Force" | |
| else | |
| zip -r ../ZPL2PDF-${{ matrix.runtime }}.zip . | |
| fi | |
| else | |
| tar -czf ../ZPL2PDF-${{ matrix.runtime }}.tar.gz . | |
| fi | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: ZPL2PDF-${{ matrix.runtime }} | |
| path: ./publish/ZPL2PDF-${{ matrix.runtime }}.* | |
| # Docker build and test | |
| docker-build: | |
| name: Docker Build and Test | |
| runs-on: ubuntu-latest | |
| needs: build-test-publish | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| load: true | |
| tags: zpl2pdf:latest | |
| platforms: linux/amd64 | |
| - name: Test Docker image | |
| run: | | |
| docker run --rm zpl2pdf:latest /app/ZPL2PDF --help | |
| # Code quality checks | |
| code-quality: | |
| name: Code Quality | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Cache NuGet packages | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/.nuget/packages | |
| key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
| restore-keys: | | |
| ${{ runner.os }}-nuget- | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Run code analysis | |
| run: dotnet build --configuration Release --verbosity normal | |
| - name: Check for TODO comments | |
| run: | | |
| if grep -r "FIXME\|HACK" . --include="*.cs" --exclude-dir=bin --exclude-dir=obj; then | |
| echo "::warning::Found FIXME/HACK comments in source code" | |
| fi | |
| if grep -r "TODO" . --include="*.cs" --exclude-dir=bin --exclude-dir=obj; then | |
| echo "::notice::Found TODO comments in source code" | |
| fi | |
| # Security scan | |
| security-scan: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| security-events: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Run Trivy vulnerability scanner | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: '.' | |
| format: 'sarif' | |
| output: 'trivy-results.sarif' | |
| - name: Upload Trivy scan results | |
| uses: github/codeql-action/upload-sarif@v3 | |
| with: | |
| sarif_file: 'trivy-results.sarif' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| continue-on-error: true | |
| # Release | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: [build-test-publish, docker-build, code-quality] | |
| if: github.event_name == 'release' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| path: ./artifacts | |
| - name: Create release archive | |
| run: | | |
| mkdir -p ./release | |
| for dir in ./artifacts/*/; do | |
| runtime=$(basename "$dir") | |
| if [[ -d "$dir" ]]; then | |
| cp -r "$dir"/* ./release/ | |
| fi | |
| done | |
| - name: Create checksums | |
| run: | | |
| cd ./release | |
| find . -type f -name "ZPL2PDF*" -exec sha256sum {} \; > checksums.txt | |
| - name: Upload release assets | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: ./release/checksums.txt | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |