mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-26 17:26:23 +02:00
chore: update GitHub Actions workflow to include publish mode selection and improve version resolution logic
This commit is contained in:
parent
7c2d34283b
commit
e86d279d55
1 changed files with 31 additions and 16 deletions
31
.github/workflows/release-obsidian-plugin.yml
vendored
31
.github/workflows/release-obsidian-plugin.yml
vendored
|
|
@ -7,10 +7,14 @@ on:
|
||||||
- "obsidian-v*"
|
- "obsidian-v*"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
tag:
|
publish:
|
||||||
description: "Tag to build (e.g. obsidian-v0.1.0). Dry-run only when run manually."
|
description: "Publish to GitHub Releases"
|
||||||
required: true
|
required: true
|
||||||
default: "obsidian-v0.0.0-test"
|
type: choice
|
||||||
|
options:
|
||||||
|
- never
|
||||||
|
- always
|
||||||
|
default: "never"
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
@ -39,24 +43,35 @@ jobs:
|
||||||
- name: Resolve plugin version
|
- name: Resolve plugin version
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
|
manifest_version=$(node -p "require('./manifest.json').version")
|
||||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
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
|
else
|
||||||
tag="${GITHUB_REF_NAME}"
|
tag="${GITHUB_REF_NAME}"
|
||||||
fi
|
|
||||||
if [ -z "$tag" ] || [[ "$tag" != obsidian-v* ]]; then
|
if [ -z "$tag" ] || [[ "$tag" != obsidian-v* ]]; then
|
||||||
echo "::error::Invalid tag '$tag'. Expected format: obsidian-v<version>"
|
echo "::error::Invalid tag '$tag'. Expected format: obsidian-v<version>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
version="${tag#obsidian-v}"
|
version="${tag#obsidian-v}"
|
||||||
manifest_version=$(node -p "require('./manifest.json').version")
|
|
||||||
if [ "$version" != "$manifest_version" ]; then
|
if [ "$version" != "$manifest_version" ]; then
|
||||||
echo "::error::Tag version '$version' does not match manifest version '$manifest_version'"
|
echo "::error::Tag version '$version' does not match manifest version '$manifest_version'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
echo "tag=$tag" >> "$GITHUB_OUTPUT"
|
||||||
echo "version=$version" >> "$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 ci
|
||||||
|
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
|
|
@ -70,7 +85,7 @@ jobs:
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Mirror manifest.json + versions.json to repo root
|
- 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 }}
|
working-directory: ${{ github.workspace }}
|
||||||
run: |
|
run: |
|
||||||
cp surfsense_obsidian/manifest.json manifest.json
|
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.
|
# Publish release under bare `manifest.json` version (no `obsidian-v` prefix) for BRAT/store compatibility.
|
||||||
- name: Create GitHub release
|
- name: Create GitHub release
|
||||||
if: github.event_name == 'push'
|
if: steps.release_mode.outputs.should_publish == 'true'
|
||||||
uses: softprops/action-gh-release@v3
|
uses: softprops/action-gh-release@v3
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.version.outputs.version }}
|
tag_name: ${{ steps.version.outputs.version }}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue