wonderbird/malimo

View on GitHub
.github/workflows/_pack_win.yml

Summary

Maintainability
Test Coverage
name: Pack for Windows

on:
  workflow_call:
    inputs:
      semantic_version:
        description: "Three number version for the Chocolatey package, e.g. 0.1.8-alpha"
        required: true
        type: string
      assembly_version:
        description: "Four number version for the .NET assembly, e.g. 0.1.8.180"
        required: true
        type: string

jobs:
  pack_win:
    name: Pack Windows
    
    strategy:
      matrix:
        runtime:
          - win-x64

    env:
      PUBLISH_DIR: malimo.${{ matrix.runtime }}
      PUBLISH_ZIP_FILENAME: malimo.${{ matrix.runtime }}.zip

    runs-on: windows-latest
    
    steps:
      - uses: actions/checkout@v3

      - name: Setup .NET
        uses: actions/setup-dotnet@v3
        with:
          dotnet-version: 7.0.x

      - name: Create application
        run: |
          dotnet publish malimo/malimo.csproj --configuration Release --runtime "${{ matrix.runtime }}" --self-contained true -p:PublishSingleFile=true -p:Version=${{ inputs.assembly_version }} --output "${{ env.PUBLISH_DIR }}"

      - name: Prepare release files
        shell: bash
        run: |
          rm -vf "${{ env.PUBLISH_DIR }}/malimo.pdb"
          cp -v LICENSE README.md CHANGELOG.md "${{ env.PUBLISH_DIR }}"

      - name: ZIP application
        uses: thedoctor0/zip-release@0.7.1
        with:
          type: 'zip'
          path: ${{ env.PUBLISH_DIR }}
          filename: ${{ env.PUBLISH_ZIP_FILENAME }}
          exclusions: '*.pdb'

      - name: Attach application to build artifacts
        uses: actions/upload-artifact@v3
        with:
          name: ${{ env.PUBLISH_ZIP_FILENAME }}
          path: ${{ env.PUBLISH_ZIP_FILENAME }}
          retention-days: ${{ env.RETENTION_DAYS }}

      - name: Prepare Chocolatey configuration
        run: pwsh ./build/ReplaceVariablesInChocolateyConfiguration.ps1 -version ${{ inputs.semantic_version }} -zipFile ${{ env.PUBLISH_ZIP_FILENAME }}

      - name: Create Chocolatey package
        run: choco pack ./chocolatey/malimo.nuspec

      - name: Attach Chocolatey package to build artifacts
        uses: actions/upload-artifact@v3
        with:
          name: malimo.${{ inputs.semantic_version }}.nupkg
          path: malimo.${{ inputs.semantic_version }}.nupkg
          retention-days: ${{ env.RETENTION_DAYS }}