Build and Release #14
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: Build and Package All Runtimes | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version tag (e.g. v1.0.0)' | |
| required: true | |
| default: 'v1.0.0' | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| env: | |
| FRAMEWORK: net8.0 | |
| PROJECT: ConvertApi.Cli/ConvertApi.Cli.csproj | |
| TAG_NAME: ${{ github.ref_name }} | |
| strategy: | |
| matrix: | |
| runtime: [ "win-x64", "linux-x64", "linux-arm64", "osx-x64", "osx-arm64" ] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.x' | |
| # Run tests | |
| # - name: Test | |
| # run: dotnet test ConvertApi.Cli.Tests | |
| - name: Publish for ${{ matrix.runtime }} | |
| run: | | |
| dotnet publish ${{ env.PROJECT }} \ | |
| -c Release \ | |
| -r ${{ matrix.runtime }} \ | |
| --self-contained true \ | |
| /p:PublishSingleFile=true \ | |
| /p:IncludeNativeLibrariesForSelfExtract=true \ | |
| /p:DebugType=none \ | |
| /p:DebugSymbols=false | |
| # - name: Upload artifact for ${{ matrix.runtime }} | |
| # uses: actions/upload-artifact@v3 | |
| # with: | |
| # name: convertApi-cli-${{ matrix.runtime }} | |
| # path: ConvertApi.Cli/bin/Release/${{ env.FRAMEWORK }}/${{ matrix.runtime }}/publish | |
| # retention-days: 1 | |
| # Use a step that archives the published files. This ensures we upload a zip asset. | |
| - name: Zip package for ${{ matrix.runtime }} | |
| run: | | |
| cd ConvertApi.Cli/bin/Release/${{ env.FRAMEWORK }}/${{ matrix.runtime }}/publish | |
| zip -r ../../../../../convertApi-cli-${{ matrix.runtime }}.zip ./* | |
| # Create or update the release only once at first matrix job (not on each matrix job). | |
| - name: Create Release | |
| if: ${{ matrix.runtime == 'win-x64' }} | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ env.TAG_NAME }} | |
| release_name: ${{ env.TAG_NAME }} | |
| draft: false | |
| prerelease: false | |
| # Upload each runtime's asset to the newly created release. | |
| - name: Upload Release Asset | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./convertApi-cli-${{ matrix.runtime }}.zip | |
| asset_name: convertApi-cli-${{ matrix.runtime }}.zip | |
| asset_content_type: application/zip |