From bcee85984613a867cd59fa683aaac7a24942f47d Mon Sep 17 00:00:00 2001 From: tanglearncode Date: Wed, 21 Oct 2026 11:16:37 +0800 Subject: [PATCH] Publish releases only from a manual release workflow Builds on pushes and pull requests now only upload a workflow artifact. The new Release native MarkText workflow reuses the build and publishes its files to a release named after the MarkText tag. --- .github/workflows/build.yml | 53 +++++++------------------------ .github/workflows/release.yml | 60 +++++++++++++++++++++++++++++++++++ README.md | 16 +++++++--- 3 files changed, 83 insertions(+), 46 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 70668d9..2eafeb2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,23 +4,30 @@ on: push: branches: [main] pull_request: - workflow_dispatch: + workflow_call: inputs: marktext-ref: description: MarkText tag to build from marktext/marktext - required: true + type: string default: v0.20.0 nativeboat-version: description: NativeBoat release tag, or latest - required: true + type: string default: latest + outputs: + marktext-ref: + value: ${{ jobs.build.outputs.marktext-ref }} + marktext-commit: + value: ${{ jobs.build.outputs.marktext-commit }} + nativeboat-version: + value: ${{ jobs.build.outputs.nativeboat-version }} permissions: contents: read concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + group: ${{ github.workflow }}-build-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} env: MARKTEXT_REF: ${{ inputs.marktext-ref || 'v0.20.0' }} @@ -65,7 +72,6 @@ jobs: analyze: 'true' - name: Package output - id: package shell: pwsh env: OUTPUT: ${{ steps.nativeboat.outputs.output-path }} @@ -86,38 +92,3 @@ jobs: name: marktext-native-win-x64 path: release/ if-no-files-found: error - - release: - needs: build - if: github.event_name != 'pull_request' - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/download-artifact@v8 - with: - name: marktext-native-win-x64 - path: release - - - name: Publish release - 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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..971828b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +name: Release native MarkText + +on: + workflow_dispatch: + inputs: + marktext-ref: + description: MarkText tag to build from marktext/marktext; also the release tag + required: true + default: v0.20.0 + nativeboat-version: + description: NativeBoat release tag, or latest + required: true + default: latest + +permissions: + contents: read + +concurrency: + group: release-${{ inputs.marktext-ref }} + +jobs: + build: + uses: ./.github/workflows/build.yml + with: + marktext-ref: ${{ inputs.marktext-ref }} + nativeboat-version: ${{ inputs.nativeboat-version }} + + release: + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/download-artifact@v8 + with: + name: marktext-native-win-x64 + path: release + + - name: Publish release + 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 diff --git a/README.md b/README.md index dc0f513..0497d83 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,15 @@ The [Build native MarkText](.github/workflows/build.yml) workflow: dependencies, 3. compiles `packages/desktop` with the [NativeBoat Build action](https://github.com/XTSoftwareLabs/nativeboat-action), -4. publishes the executable, a ZIP of the full output folder and - `SHA256SUMS.txt` to a release named after the MarkText tag. +4. uploads the executable, a ZIP of the full output folder and + `SHA256SUMS.txt` as a workflow artifact. -Pushes to `main` rebuild and update the release; pull requests build only. To -build another MarkText tag or NativeBoat version, run the workflow manually -from the Actions tab and set `marktext-ref` and `nativeboat-version`. +It runs on pushes to `main` and on pull requests, and publishes nothing. + +## Releasing + +Run the [Release native MarkText](.github/workflows/release.yml) workflow from +the Actions tab. Set `marktext-ref` to the MarkText tag to build and +`nativeboat-version` to a NativeBoat release tag or `latest`. It runs the build +above, then publishes its files to a release named after the MarkText tag. +Running it again for the same tag replaces that release's files.