diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 14fadf4..731cb0c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,6 +2,10 @@ name: Release # Build, attest provenance, and publish release assets when a version tag is pushed. # Obsidian tags are bare versions with no leading "v" (e.g. 1.0.0). +# A tag carrying a pre-release suffix (a "-", e.g. 1.3.0-alpha / 1.3.0-beta.1) is +# published as a GitHub *prerelease*: GitHub's "latest release" (what Obsidian's +# updater reads) excludes prereleases, so the official channel never sees it, while +# BRAT / manual install still can. See docs/RELEASING.md. on: push: tags: @@ -28,6 +32,33 @@ jobs: - name: Install dependencies run: npm ci + # A tag with a "-" (e.g. 1.3.0-alpha) is a pre-release channel. + - name: Determine release channel + id: channel + shell: bash + run: | + if [[ "${{ github.ref_name }}" == *-* ]]; then + echo "prerelease=true" >> "$GITHUB_OUTPUT" + else + echo "prerelease=false" >> "$GITHUB_OUTPUT" + fi + + # Master's manifest.json stays at the last stable version during alpha/beta + # testing, so stamp the tag's version into the *published* manifest only. + # (Stable tags publish manifest.json as committed; this step is skipped.) + - name: Stamp pre-release version into manifest + if: steps.channel.outputs.prerelease == 'true' + shell: bash + env: + TAG: ${{ github.ref_name }} + run: | + node -e ' + const fs = require("fs"); + const m = JSON.parse(fs.readFileSync("manifest.json", "utf8")); + m.version = process.env.TAG; + fs.writeFileSync("manifest.json", JSON.stringify(m, null, "\t")); + ' + - name: Build run: npm run build @@ -44,6 +75,7 @@ jobs: with: tag_name: ${{ github.ref_name }} name: ${{ github.ref_name }} + prerelease: ${{ steps.channel.outputs.prerelease }} files: | main.js manifest.json