Build and Release #6
Workflow file for this run
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 Release | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| DOTNET_VERSION: '9.0.x' | |
| PROJECT_PATH: 'DazContentInstaller/DazContentInstaller.csproj' | |
| ARTIFACT_NAME: 'DazContentInstaller' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Build | |
| run: dotnet build ${{ env.PROJECT_PATH }} --configuration Release | |
| # - name: Test | |
| # run: dotnet test ${{ env.PROJECT_PATH }} --no-build --verbosity normal | |
| # continue-on-error: true | |
| - name: Publish for Windows x64 | |
| run: | | |
| dotnet publish ${{ env.PROJECT_PATH }} \ | |
| --configuration Release \ | |
| --runtime win-x64 \ | |
| --output "./publish/win-x64" \ | |
| --verbosity normal | |
| - name: Publish for Windows x86 | |
| run: | | |
| dotnet publish ${{ env.PROJECT_PATH }} \ | |
| --configuration Release \ | |
| --runtime win-x86 \ | |
| --output "./publish/win-x86" \ | |
| --verbosity normal | |
| - name: Create zip archives | |
| run: | | |
| # Create directories for zip files | |
| mkdir -p ./artifacts | |
| # Zip x64 version | |
| cd ./publish/win-x64 && zip -r "../../artifacts/${{ env.ARTIFACT_NAME }}-win-x64.zip" . && cd ../.. | |
| # Zip x86 version | |
| cd ./publish/win-x86 && zip -r "../../artifacts/${{ env.ARTIFACT_NAME }}-win-x86.zip" . && cd ../.. | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }}-builds | |
| path: ./artifacts/*.zip | |
| retention-days: 30 | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Publish for Windows x64 | |
| run: | | |
| dotnet publish ${{ env.PROJECT_PATH }} \ | |
| --configuration Release \ | |
| --runtime win-x64 \ | |
| --output "./publish/win-x64" \ | |
| --verbosity normal | |
| - name: Publish for Windows x86 | |
| run: | | |
| dotnet publish ${{ env.PROJECT_PATH }} \ | |
| --configuration Release \ | |
| --runtime win-x86 \ | |
| --output "./publish/win-x86" \ | |
| --verbosity normal | |
| - name: Create zip archives | |
| run: | | |
| # Create directories for zip files | |
| mkdir -p ./artifacts | |
| # Zip x64 version | |
| cd ./publish/win-x64 && zip -r "../../artifacts/${{ env.ARTIFACT_NAME }}-${{ github.ref_name }}-win-x64.zip" . && cd ../.. | |
| # Zip x86 version | |
| cd ./publish/win-x86 && zip -r "../../artifacts/${{ env.ARTIFACT_NAME }}-${{ github.ref_name }}-win-x86.zip" . && cd ../.. | |
| - name: Generate release notes | |
| id: release_notes | |
| run: | | |
| tag="${{ github.ref_name }}" | |
| cat << EOF > ./release_notes.md | |
| ## Release $tag | |
| ### Downloads | |
| - **Windows x64**: ${{ env.ARTIFACT_NAME }}-$tag-win-x64.zip | |
| - **Windows x86**: ${{ env.ARTIFACT_NAME }}-$tag-win-x86.zip | |
| **Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ github.event.before }}...$tag | |
| EOF | |
| echo "notes_file=./release_notes.md" >> $GITHUB_OUTPUT | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: ./artifacts/*.zip | |
| body_path: ${{ steps.release_notes.outputs.notes_file }} | |
| draft: false | |
| prerelease: ${{ contains(github.ref_name, '-') }} | |
| generate_release_notes: true |