diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 971828b..85a19ef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: release: needs: build - runs-on: ubuntu-latest + runs-on: windows-latest permissions: contents: write steps: @@ -37,24 +37,31 @@ jobs: path: release - name: Publish release + shell: pwsh env: GH_TOKEN: ${{ github.token }} TAG: ${{ needs.build.outputs.marktext-ref }} NATIVEBOAT: ${{ needs.build.outputs.nativeboat-version }} COMMIT: ${{ needs.build.outputs.marktext-commit }} run: | - cat > notes.md < /dev/null 2>&1; then - gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --notes-file notes.md - gh release upload "$TAG" release/* --repo "$GITHUB_REPOSITORY" --clobber - else - gh release create "$TAG" release/* --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" \ - --title "MarkText ${TAG} (native Windows)" --notes-file notes.md - fi + ``.exe`` to run it directly, or the ``.zip`` for the complete output folder. + "@ | Set-Content -Encoding utf8NoBOM notes.md + $files = (Get-ChildItem release -File).FullName + gh release view $env:TAG --repo $env:GITHUB_REPOSITORY *> $null + $exists = $LASTEXITCODE -eq 0 + # Fail on any gh error from here on. + $PSNativeCommandUseErrorActionPreference = $true + if ($exists) { + gh release edit $env:TAG --repo $env:GITHUB_REPOSITORY --notes-file notes.md + gh release upload $env:TAG @files --repo $env:GITHUB_REPOSITORY --clobber + } else { + gh release create $env:TAG @files --repo $env:GITHUB_REPOSITORY --target $env:GITHUB_SHA ` + --title "MarkText $env:TAG (native Windows)" --notes-file notes.md + }