|
7 | 7 | - "obsidian-v*" |
8 | 8 | workflow_dispatch: |
9 | 9 | 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" |
12 | 12 | required: true |
13 | | - default: "obsidian-v0.0.0-test" |
| 13 | + type: choice |
| 14 | + options: |
| 15 | + - never |
| 16 | + - always |
| 17 | + default: "never" |
14 | 18 |
|
15 | 19 | permissions: |
16 | 20 | contents: write |
@@ -39,24 +43,35 @@ jobs: |
39 | 43 | - name: Resolve plugin version |
40 | 44 | id: version |
41 | 45 | run: | |
| 46 | + manifest_version=$(node -p "require('./manifest.json').version") |
42 | 47 | 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" |
44 | 51 | else |
45 | 52 | 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 |
56 | 62 | fi |
57 | 63 | echo "tag=$tag" >> "$GITHUB_OUTPUT" |
58 | 64 | echo "version=$version" >> "$GITHUB_OUTPUT" |
59 | 65 |
|
| 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 | +
|
60 | 75 | - run: npm ci |
61 | 76 |
|
62 | 77 | - run: npm run lint |
|
70 | 85 | done |
71 | 86 |
|
72 | 87 | - name: Mirror manifest.json + versions.json to repo root |
73 | | - if: github.event_name == 'push' |
| 88 | + if: steps.release_mode.outputs.should_publish == 'true' |
74 | 89 | working-directory: ${{ github.workspace }} |
75 | 90 | run: | |
76 | 91 | cp surfsense_obsidian/manifest.json manifest.json |
|
90 | 105 |
|
91 | 106 | # Publish release under bare `manifest.json` version (no `obsidian-v` prefix) for BRAT/store compatibility. |
92 | 107 | - name: Create GitHub release |
93 | | - if: github.event_name == 'push' |
| 108 | + if: steps.release_mode.outputs.should_publish == 'true' |
94 | 109 | uses: softprops/action-gh-release@v3 |
95 | 110 | with: |
96 | 111 | tag_name: ${{ steps.version.outputs.version }} |
|
0 commit comments