Skip to content

Commit e86d279

Browse files
committed
chore: update GitHub Actions workflow to include publish mode selection and improve version resolution logic
1 parent 7c2d342 commit e86d279

1 file changed

Lines changed: 31 additions & 16 deletions

File tree

.github/workflows/release-obsidian-plugin.yml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ on:
77
- "obsidian-v*"
88
workflow_dispatch:
99
inputs:
10-
tag:
11-
description: "Tag to build (e.g. obsidian-v0.1.0). Dry-run only when run manually."
10+
publish:
11+
description: "Publish to GitHub Releases"
1212
required: true
13-
default: "obsidian-v0.0.0-test"
13+
type: choice
14+
options:
15+
- never
16+
- always
17+
default: "never"
1418

1519
permissions:
1620
contents: write
@@ -39,24 +43,35 @@ jobs:
3943
- name: Resolve plugin version
4044
id: version
4145
run: |
46+
manifest_version=$(node -p "require('./manifest.json').version")
4247
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
43-
tag="${{ github.event.inputs.tag }}"
48+
# Manual runs derive the release version from manifest.json.
49+
version="$manifest_version"
50+
tag="obsidian-v$version"
4451
else
4552
tag="${GITHUB_REF_NAME}"
46-
fi
47-
if [ -z "$tag" ] || [[ "$tag" != obsidian-v* ]]; then
48-
echo "::error::Invalid tag '$tag'. Expected format: obsidian-v<version>"
49-
exit 1
50-
fi
51-
version="${tag#obsidian-v}"
52-
manifest_version=$(node -p "require('./manifest.json').version")
53-
if [ "$version" != "$manifest_version" ]; then
54-
echo "::error::Tag version '$version' does not match manifest version '$manifest_version'"
55-
exit 1
53+
if [ -z "$tag" ] || [[ "$tag" != obsidian-v* ]]; then
54+
echo "::error::Invalid tag '$tag'. Expected format: obsidian-v<version>"
55+
exit 1
56+
fi
57+
version="${tag#obsidian-v}"
58+
if [ "$version" != "$manifest_version" ]; then
59+
echo "::error::Tag version '$version' does not match manifest version '$manifest_version'"
60+
exit 1
61+
fi
5662
fi
5763
echo "tag=$tag" >> "$GITHUB_OUTPUT"
5864
echo "version=$version" >> "$GITHUB_OUTPUT"
5965
66+
- name: Resolve publish mode
67+
id: release_mode
68+
run: |
69+
if [ "${{ github.event_name }}" = "push" ] || [ "${{ inputs.publish }}" = "always" ]; then
70+
echo "should_publish=true" >> "$GITHUB_OUTPUT"
71+
else
72+
echo "should_publish=false" >> "$GITHUB_OUTPUT"
73+
fi
74+
6075
- run: npm ci
6176

6277
- run: npm run lint
@@ -70,7 +85,7 @@ jobs:
7085
done
7186
7287
- name: Mirror manifest.json + versions.json to repo root
73-
if: github.event_name == 'push'
88+
if: steps.release_mode.outputs.should_publish == 'true'
7489
working-directory: ${{ github.workspace }}
7590
run: |
7691
cp surfsense_obsidian/manifest.json manifest.json
@@ -90,7 +105,7 @@ jobs:
90105
91106
# Publish release under bare `manifest.json` version (no `obsidian-v` prefix) for BRAT/store compatibility.
92107
- name: Create GitHub release
93-
if: github.event_name == 'push'
108+
if: steps.release_mode.outputs.should_publish == 'true'
94109
uses: softprops/action-gh-release@v3
95110
with:
96111
tag_name: ${{ steps.version.outputs.version }}

0 commit comments

Comments
 (0)