ebullient_obsidian-deck-notes/.github/workflows/release.yml
dependabot[bot] 7eaa2708be
Bump actions/checkout from 6.0.2 to 7.0.0
Bumps [actions/checkout](https://github.com/actions/checkout) from 6.0.2 to 7.0.0.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](de0fac2e45...9c091bb21b)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-07-20 02:14:01 +00:00

138 lines
4.3 KiB
YAML

name: Release Obsidian Plugin
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
inputs:
version:
description: 'New version or major, minor, patch'
default: 'patch'
required: true
update_manifest:
description: 'Update manifest.json'
default: true
required: true
type: boolean
update_brat:
description: 'Update brat manifest'
default: true
required: true
type: boolean
env:
GH_BOT_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
GH_BOT_NAME: "GitHub Action"
jobs:
build:
permissions:
contents: write
id-token: write
attestations: write
runs-on: ubuntu-latest
outputs:
version: ${{ steps.build.outputs.version }}
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
# persist-credentials required: this step pushes commits and tags
# zizmor: ignore[artipacked]
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: Use Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
cache: 'npm'
# Build the plugin
- name: Build and Tag
id: build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INPUT_VERSION: ${{ github.event.inputs.version }}
INPUT_UPDATE_MANIFEST: ${{ github.event.inputs.update_manifest }}
INPUT_UPDATE_BRAT: ${{ github.event.inputs.update_brat }}
run: |
echo "version: $INPUT_VERSION"
echo "update_manifest: $INPUT_UPDATE_MANIFEST"
echo "update_brat: $INPUT_UPDATE_BRAT"
git config user.name "$GH_BOT_NAME"
git config user.email "$GH_BOT_EMAIL"
npm ci
npm version "$INPUT_VERSION" --no-git-tag-version
VERSION=$(grep '^ "version"' package.json | cut -d'"' -f4)
echo "$VERSION"
if git rev-parse "refs/tags/$VERSION" > /dev/null 2>&1; then
echo "🛑 Tag $VERSION already exists. Delete the release and tag manually, then re-run."
exit 1
fi
if [ "$INPUT_UPDATE_MANIFEST" = "true" ]; then
# shellcheck disable=SC2086
sed -i 's|\(version":\) "[0-9\.]*"|\1 "'$VERSION'"|' manifest.json
fi
if [ "$INPUT_UPDATE_BRAT" = "true" ]; then
# shellcheck disable=SC2086
sed -i 's|\(version":\) "[0-9\.]*"|\1 "'$VERSION'"|' manifest-beta.json
fi
git add .
git status
git commit -m "🔖 $VERSION"
git push
git tag "$VERSION"
git push --tags
npm run brat-notes -- "${VERSION}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
# Package the required files into a zip
- name: Package
env:
REPO_NAME: ${{ github.event.repository.name }}
RELEASE_VERSION: ${{ steps.build.outputs.version }}
run: |
mv build "$REPO_NAME"
zip -r "${REPO_NAME}-${RELEASE_VERSION}.zip" "$REPO_NAME"
unzip -j "${REPO_NAME}-${RELEASE_VERSION}.zip" \
"$REPO_NAME/main.js" \
"$REPO_NAME/styles.css"
# Attest build provenance for release artifacts
- name: Attest build artifacts
uses: actions/attest@59d89421af93a897026c735860bf21b6eb4f7b26 # v4
with:
subject-path: |
${{ github.event.repository.name }}-${{ steps.build.outputs.version }}.zip
./main.js
./styles.css
# Create the release on github
- name: Create Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INPUT_UPDATE_MANIFEST: ${{ github.event.inputs.update_manifest }}
REPO_NAME: ${{ github.event.repository.name }}
RELEASE_VERSION: ${{ steps.build.outputs.version }}
run: |
prerelease=true
if [ "$INPUT_UPDATE_MANIFEST" = "true" ]; then
prerelease=false
fi
gh release create "$RELEASE_VERSION" \
-F ./release-notes.md \
--title "$RELEASE_VERSION" \
--verify-tag \
--prerelease=${prerelease} \
"${REPO_NAME}-${RELEASE_VERSION}.zip" \
'./main.js' \
'./styles.css' \
'./manifest.json' \
'./manifest-beta.json'