Release CI #2
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: Release CI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag name for the release (e.g., v1.0.0). If empty, a tag will be generated from the run number.' | |
| required: false | |
| default: '' | |
| name: | |
| description: 'Release title (optional). If empty, a title will be generated using the tag.' | |
| required: false | |
| default: '' | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| PROJECT_PATH: 'MagickCrop/MagickCrop.csproj' | |
| PUBLISH_DIR: 'publish' | |
| ARTIFACT_ZIP: 'MagickCrop-win-x64.zip' | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '9.0.x' | |
| - name: Install dependencies | |
| run: dotnet restore ${{ env.PROJECT_PATH }} | |
| - name: Build | |
| run: dotnet build ${{ env.PROJECT_PATH }} | |
| - name: Build for release and Publish (win-x64) | |
| run: >- | |
| dotnet publish ${{ env.PROJECT_PATH }} | |
| -c Release | |
| --self-contained | |
| -r win-x64 | |
| -p:PublishSingleFile=true | |
| -o ${{ env.PUBLISH_DIR }} | |
| - name: Create ZIP archive of publish output | |
| shell: pwsh | |
| run: | | |
| if (Test-Path "${{ env.ARTIFACT_ZIP }}") { Remove-Item -Force "${{ env.ARTIFACT_ZIP }}" } | |
| Compress-Archive -Path "${{ env.PUBLISH_DIR }}/*" -DestinationPath "${{ env.ARTIFACT_ZIP }}" | |
| - name: Upload build artifact (ZIP) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: MagickCrop-win-x64 | |
| path: ${{ env.ARTIFACT_ZIP }} | |
| - name: Compute release tag and name | |
| shell: pwsh | |
| run: | | |
| $tag = "${{ github.event.inputs.tag }}" | |
| if ([string]::IsNullOrWhiteSpace($tag)) { $tag = "v${{ github.run_number }}" } | |
| echo "RELEASE_TAG=$tag" >> $env:GITHUB_ENV | |
| $name = "${{ github.event.inputs.name }}" | |
| if ([string]::IsNullOrWhiteSpace($name)) { $name = "MagickCrop $tag" } | |
| echo "RELEASE_NAME=$name" >> $env:GITHUB_ENV | |
| - name: Create draft GitHub release and upload assets | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ env.RELEASE_TAG }} | |
| name: ${{ env.RELEASE_NAME }} | |
| target_commitish: ${{ github.sha }} | |
| draft: true | |
| prerelease: true | |
| generate_release_notes: true | |
| fail_on_unmatched_files: true | |
| files: | | |
| ${{ env.ARTIFACT_ZIP }} |