From e86d279d5500aa27319e4e5e037bae66c2ea8511 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Wed, 22 Apr 2026 05:34:17 +0530 Subject: [PATCH] chore: update GitHub Actions workflow to include publish mode selection and improve version resolution logic --- .github/workflows/release-obsidian-plugin.yml | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release-obsidian-plugin.yml b/.github/workflows/release-obsidian-plugin.yml index 198b87611..1560f1c41 100644 --- a/.github/workflows/release-obsidian-plugin.yml +++ b/.github/workflows/release-obsidian-plugin.yml @@ -7,10 +7,14 @@ on: - "obsidian-v*" workflow_dispatch: inputs: - tag: - description: "Tag to build (e.g. obsidian-v0.1.0). Dry-run only when run manually." + publish: + description: "Publish to GitHub Releases" required: true - default: "obsidian-v0.0.0-test" + type: choice + options: + - never + - always + default: "never" permissions: contents: write @@ -39,24 +43,35 @@ jobs: - name: Resolve plugin version id: version run: | + manifest_version=$(node -p "require('./manifest.json').version") if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then - tag="${{ github.event.inputs.tag }}" + # Manual runs derive the release version from manifest.json. + version="$manifest_version" + tag="obsidian-v$version" else tag="${GITHUB_REF_NAME}" - fi - if [ -z "$tag" ] || [[ "$tag" != obsidian-v* ]]; then - echo "::error::Invalid tag '$tag'. Expected format: obsidian-v" - exit 1 - fi - version="${tag#obsidian-v}" - manifest_version=$(node -p "require('./manifest.json').version") - if [ "$version" != "$manifest_version" ]; then - echo "::error::Tag version '$version' does not match manifest version '$manifest_version'" - exit 1 + if [ -z "$tag" ] || [[ "$tag" != obsidian-v* ]]; then + echo "::error::Invalid tag '$tag'. Expected format: obsidian-v" + exit 1 + fi + version="${tag#obsidian-v}" + if [ "$version" != "$manifest_version" ]; then + echo "::error::Tag version '$version' does not match manifest version '$manifest_version'" + exit 1 + fi fi echo "tag=$tag" >> "$GITHUB_OUTPUT" echo "version=$version" >> "$GITHUB_OUTPUT" + - name: Resolve publish mode + id: release_mode + run: | + if [ "${{ github.event_name }}" = "push" ] || [ "${{ inputs.publish }}" = "always" ]; then + echo "should_publish=true" >> "$GITHUB_OUTPUT" + else + echo "should_publish=false" >> "$GITHUB_OUTPUT" + fi + - run: npm ci - run: npm run lint @@ -70,7 +85,7 @@ jobs: done - name: Mirror manifest.json + versions.json to repo root - if: github.event_name == 'push' + if: steps.release_mode.outputs.should_publish == 'true' working-directory: ${{ github.workspace }} run: | cp surfsense_obsidian/manifest.json manifest.json @@ -90,7 +105,7 @@ jobs: # Publish release under bare `manifest.json` version (no `obsidian-v` prefix) for BRAT/store compatibility. - name: Create GitHub release - if: github.event_name == 'push' + if: steps.release_mode.outputs.should_publish == 'true' uses: softprops/action-gh-release@v3 with: tag_name: ${{ steps.version.outputs.version }}