|
| 1 | +name: Desktop Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version_bump: |
| 7 | + description: Version bump type for DotPilot desktop releases |
| 8 | + required: true |
| 9 | + default: patch |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - patch |
| 13 | + - minor |
| 14 | + - major |
| 15 | + prerelease: |
| 16 | + description: Publish the GitHub Release as a prerelease |
| 17 | + required: true |
| 18 | + default: false |
| 19 | + type: boolean |
| 20 | + |
| 21 | +permissions: |
| 22 | + contents: write |
| 23 | + |
| 24 | +concurrency: |
| 25 | + group: desktop-release-${{ github.ref_name }} |
| 26 | + cancel-in-progress: false |
| 27 | + |
| 28 | +jobs: |
| 29 | + validate_release_ref: |
| 30 | + name: Validate Release Ref |
| 31 | + runs-on: ubuntu-latest |
| 32 | + steps: |
| 33 | + - name: Enforce Supported Release Branches |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + if [[ "${GITHUB_REF_NAME}" == "main" || "${GITHUB_REF_NAME}" == release/* ]]; then |
| 37 | + exit 0 |
| 38 | + fi |
| 39 | +
|
| 40 | + echo "Desktop releases may only run from main or release/* branches." >&2 |
| 41 | + exit 1 |
| 42 | +
|
| 43 | + prepare_release: |
| 44 | + name: Prepare Release |
| 45 | + runs-on: ubuntu-latest |
| 46 | + needs: |
| 47 | + - validate_release_ref |
| 48 | + outputs: |
| 49 | + application_version: ${{ steps.bump_version.outputs.application_version }} |
| 50 | + previous_tag: ${{ steps.previous_tag.outputs.value }} |
| 51 | + release_tag: ${{ steps.bump_version.outputs.release_tag }} |
| 52 | + release_version: ${{ steps.bump_version.outputs.display_version }} |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + with: |
| 56 | + fetch-depth: 0 |
| 57 | + |
| 58 | + - name: Configure Git Identity |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + git config user.name "github-actions[bot]" |
| 62 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 63 | +
|
| 64 | + - name: Fetch Tags |
| 65 | + shell: bash |
| 66 | + run: git fetch --tags --force |
| 67 | + |
| 68 | + - name: Capture Previous Tag |
| 69 | + id: previous_tag |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + previous_tag="$(git tag --list 'v*' --sort=-version:refname | head -n 1)" |
| 73 | + echo "value=${previous_tag}" >> "$GITHUB_OUTPUT" |
| 74 | +
|
| 75 | + - name: Bump App Version |
| 76 | + id: bump_version |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + python3 ./scripts/release/update_app_version.py \ |
| 80 | + --project-file ./DotPilot/DotPilot.csproj \ |
| 81 | + --bump-type '${{ inputs.version_bump }}' \ |
| 82 | + --github-output "$GITHUB_OUTPUT" |
| 83 | +
|
| 84 | + - name: Commit Version Bump |
| 85 | + shell: bash |
| 86 | + run: | |
| 87 | + git add DotPilot/DotPilot.csproj |
| 88 | + git commit -m "chore(release): v${{ steps.bump_version.outputs.display_version }}" |
| 89 | +
|
| 90 | + - name: Create Release Tag |
| 91 | + shell: bash |
| 92 | + run: git tag "${{ steps.bump_version.outputs.release_tag }}" |
| 93 | + |
| 94 | + - name: Push Release Commit And Tag |
| 95 | + shell: bash |
| 96 | + run: | |
| 97 | + git push origin "HEAD:${GITHUB_REF_NAME}" |
| 98 | + git push origin "${{ steps.bump_version.outputs.release_tag }}" |
| 99 | +
|
| 100 | + publish_desktop: |
| 101 | + name: Publish Desktop (${{ matrix.name }}) |
| 102 | + runs-on: ${{ matrix.runner }} |
| 103 | + needs: |
| 104 | + - prepare_release |
| 105 | + strategy: |
| 106 | + fail-fast: false |
| 107 | + matrix: |
| 108 | + include: |
| 109 | + - name: macOS |
| 110 | + runner: macos-latest |
| 111 | + artifact_name: dotpilot-release-macos |
| 112 | + archive_name: dotpilot-desktop-macos.zip |
| 113 | + output_path: artifacts/publish/macos |
| 114 | + - name: Windows |
| 115 | + runner: windows-latest |
| 116 | + artifact_name: dotpilot-release-windows |
| 117 | + archive_name: dotpilot-desktop-windows.zip |
| 118 | + output_path: artifacts/publish/windows |
| 119 | + - name: Linux |
| 120 | + runner: ubuntu-latest |
| 121 | + artifact_name: dotpilot-release-linux |
| 122 | + archive_name: dotpilot-desktop-linux.zip |
| 123 | + output_path: artifacts/publish/linux |
| 124 | + steps: |
| 125 | + - uses: actions/checkout@v4 |
| 126 | + with: |
| 127 | + fetch-depth: 0 |
| 128 | + ref: ${{ needs.prepare_release.outputs.release_tag }} |
| 129 | + |
| 130 | + - name: Install Dependencies |
| 131 | + timeout-minutes: 60 |
| 132 | + uses: "./.github/steps/install_dependencies" |
| 133 | + |
| 134 | + - name: Publish Desktop App |
| 135 | + shell: pwsh |
| 136 | + run: dotnet publish ./DotPilot/DotPilot.csproj -c Release -f net10.0-desktop -o ./${{ matrix.output_path }} |
| 137 | + |
| 138 | + - name: Archive Desktop Publish Output |
| 139 | + shell: pwsh |
| 140 | + run: | |
| 141 | + New-Item -ItemType Directory -Force -Path ./artifacts/releases | Out-Null |
| 142 | + $archivePath = "./artifacts/releases/${{ matrix.archive_name }}" |
| 143 | + if (Test-Path $archivePath) { |
| 144 | + Remove-Item $archivePath -Force |
| 145 | + } |
| 146 | +
|
| 147 | + Compress-Archive -Path "./${{ matrix.output_path }}/*" -DestinationPath $archivePath |
| 148 | +
|
| 149 | + - name: Upload Release Artifact |
| 150 | + uses: actions/upload-artifact@v4 |
| 151 | + with: |
| 152 | + name: ${{ matrix.artifact_name }} |
| 153 | + path: ./artifacts/releases/${{ matrix.archive_name }} |
| 154 | + if-no-files-found: error |
| 155 | + retention-days: 14 |
| 156 | + |
| 157 | + create_release: |
| 158 | + name: Create GitHub Release |
| 159 | + runs-on: ubuntu-latest |
| 160 | + needs: |
| 161 | + - prepare_release |
| 162 | + - publish_desktop |
| 163 | + steps: |
| 164 | + - uses: actions/checkout@v4 |
| 165 | + with: |
| 166 | + fetch-depth: 0 |
| 167 | + ref: ${{ needs.prepare_release.outputs.release_tag }} |
| 168 | + |
| 169 | + - name: Fetch Tags |
| 170 | + shell: bash |
| 171 | + run: git fetch --tags --force |
| 172 | + |
| 173 | + - name: Download Release Artifacts |
| 174 | + uses: actions/download-artifact@v4 |
| 175 | + with: |
| 176 | + path: ./artifacts/release-assets |
| 177 | + |
| 178 | + - name: Generate Feature Summary |
| 179 | + shell: bash |
| 180 | + run: | |
| 181 | + python3 ./scripts/release/get_release_summary.py \ |
| 182 | + --repository '${{ github.repository }}' \ |
| 183 | + --release-tag '${{ needs.prepare_release.outputs.release_tag }}' \ |
| 184 | + --previous-tag '${{ needs.prepare_release.outputs.previous_tag }}' \ |
| 185 | + --output-path ./artifacts/release-summary.md |
| 186 | +
|
| 187 | + - name: Publish GitHub Release |
| 188 | + shell: bash |
| 189 | + env: |
| 190 | + GH_TOKEN: ${{ github.token }} |
| 191 | + PREVIOUS_TAG: ${{ needs.prepare_release.outputs.previous_tag }} |
| 192 | + RELEASE_TAG: ${{ needs.prepare_release.outputs.release_tag }} |
| 193 | + RELEASE_VERSION: ${{ needs.prepare_release.outputs.release_version }} |
| 194 | + REPOSITORY: ${{ github.repository }} |
| 195 | + PRERELEASE: ${{ inputs.prerelease }} |
| 196 | + run: | |
| 197 | + mapfile -t release_assets < <(find ./artifacts/release-assets -type f -name '*.zip' | sort) |
| 198 | + if [[ ${#release_assets[@]} -eq 0 ]]; then |
| 199 | + echo "No release assets were downloaded." >&2 |
| 200 | + exit 1 |
| 201 | + fi |
| 202 | +
|
| 203 | + release_notes="$(cat ./artifacts/release-summary.md)" |
| 204 | + release_command=( |
| 205 | + gh release create "${RELEASE_TAG}" |
| 206 | + "${release_assets[@]}" |
| 207 | + --repo "${REPOSITORY}" |
| 208 | + --verify-tag |
| 209 | + --title "DotPilot ${RELEASE_VERSION}" |
| 210 | + --generate-notes |
| 211 | + --notes "${release_notes}" |
| 212 | + ) |
| 213 | +
|
| 214 | + if [[ -n "${PREVIOUS_TAG}" ]]; then |
| 215 | + release_command+=(--notes-start-tag "${PREVIOUS_TAG}") |
| 216 | + fi |
| 217 | +
|
| 218 | + if [[ "${PRERELEASE}" == "true" ]]; then |
| 219 | + release_command+=(--prerelease) |
| 220 | + fi |
| 221 | +
|
| 222 | + "${release_command[@]}" |
0 commit comments