mirror of
https://github.com/swartzrock/obsidian-settings-float-plugin.git
synced 2026-07-22 07:48:42 +00:00
127 lines
3.5 KiB
YAML
127 lines
3.5 KiB
YAML
name: Publish Release
|
|
|
|
on:
|
|
workflow_call:
|
|
push:
|
|
tags:
|
|
- "0*"
|
|
- "1*"
|
|
- "2*"
|
|
- "3*"
|
|
- "4*"
|
|
- "5*"
|
|
- "6*"
|
|
- "7*"
|
|
- "8*"
|
|
- "9*"
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: "Release tag to create, for example 0.1.0. Defaults to manifest version."
|
|
required: false
|
|
type: string
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
|
|
jobs:
|
|
publish:
|
|
name: Build and publish release
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v6.0.3
|
|
|
|
- name: Set up Bun
|
|
uses: oven-sh/setup-bun@v2.2.0
|
|
with:
|
|
bun-version: 1.3.14
|
|
|
|
- name: Install dependencies
|
|
run: bun install --frozen-lockfile
|
|
|
|
- name: Typecheck
|
|
run: bun run typecheck
|
|
|
|
- name: Lint
|
|
run: bun run lint
|
|
|
|
- name: Test
|
|
run: bun run test
|
|
|
|
- name: Build
|
|
run: bun run build
|
|
|
|
- name: Prepare release metadata
|
|
id: release
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
INPUT_TAG: ${{ github.event.inputs.tag }}
|
|
run: |
|
|
VERSION="$(node -p "require('./manifest.json').version")"
|
|
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
|
|
TAG_NAME="${GITHUB_REF_NAME}"
|
|
|
|
if [ "${VERSION}" != "${PACKAGE_VERSION}" ]; then
|
|
echo "::error::manifest.json version (${VERSION}) must match package.json version (${PACKAGE_VERSION})."
|
|
exit 1
|
|
fi
|
|
|
|
if [ "${GITHUB_EVENT_NAME}" != "push" ] || [ "${GITHUB_REF_TYPE}" != "tag" ]; then
|
|
TAG_NAME="${INPUT_TAG}"
|
|
if [ -z "${TAG_NAME}" ]; then
|
|
TAG_NAME="${VERSION}"
|
|
fi
|
|
fi
|
|
|
|
if [[ ! "${TAG_NAME}" =~ ^[0-9] ]]; then
|
|
echo "::error::Release tag must start with a digit and match manifest.json version (${VERSION})."
|
|
exit 1
|
|
fi
|
|
|
|
if [ "${TAG_NAME}" != "${VERSION}" ]; then
|
|
echo "::error::Release tag (${TAG_NAME}) must match manifest.json version (${VERSION})."
|
|
exit 1
|
|
fi
|
|
|
|
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
|
|
echo "tag_name=${TAG_NAME}" >> "${GITHUB_OUTPUT}"
|
|
echo "zip_name=settings-float-${VERSION}.zip" >> "${GITHUB_OUTPUT}"
|
|
|
|
if gh release view "${TAG_NAME}" >/dev/null 2>&1; then
|
|
echo "release_exists=true" >> "${GITHUB_OUTPUT}"
|
|
else
|
|
echo "release_exists=false" >> "${GITHUB_OUTPUT}"
|
|
fi
|
|
|
|
- name: Package release zip
|
|
if: steps.release.outputs.release_exists != 'true'
|
|
run: |
|
|
zip "${{ steps.release.outputs.zip_name }}" manifest.json main.js styles.css
|
|
|
|
- name: Create GitHub release
|
|
if: steps.release.outputs.release_exists != 'true'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
NOTES_FILE="docs/release-notes/${{ steps.release.outputs.version }}.md"
|
|
NOTES_ARGS=()
|
|
|
|
if [ -f "${NOTES_FILE}" ]; then
|
|
NOTES_ARGS=(--notes-file "${NOTES_FILE}")
|
|
else
|
|
NOTES_ARGS=(--generate-notes)
|
|
fi
|
|
|
|
gh release create "${{ steps.release.outputs.tag_name }}" \
|
|
"${{ steps.release.outputs.zip_name }}" \
|
|
manifest.json \
|
|
main.js \
|
|
styles.css \
|
|
--title "Settings Float ${{ steps.release.outputs.version }}" \
|
|
--target "${GITHUB_SHA}" \
|
|
"${NOTES_ARGS[@]}"
|