Fix sentence case ESLint config for Obsidian review bot compliance #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| pull_request: | |
| types: | |
| - closed | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| jobs: | |
| release: | |
| name: Update changelog and create release | |
| runs-on: ubuntu-latest | |
| if: github.actor != 'github-actions[bot]' && github.event.pull_request.merged == true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build plugin | |
| run: npm run build | |
| - name: Determine version bump from merged PR | |
| id: bump | |
| env: | |
| PR_BODY: ${{ github.event.pull_request.body || '' }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| if [ -z "$PR_NUMBER" ]; then | |
| echo "::error::Expected pull request metadata on pull_request.closed." | |
| exit 1 | |
| fi | |
| echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" | |
| # Write PR body to a temp file to reliably preserve multiline content | |
| PR_BODY_FILE=$(mktemp) | |
| printf '%s\n' "$PR_BODY" > "$PR_BODY_FILE" | |
| DELIM="EOF_$(uuidgen 2>/dev/null || echo "${RANDOM}${RANDOM}")" | |
| printf 'pr_body<<%s\n' "$DELIM" >> "$GITHUB_OUTPUT" | |
| cat "$PR_BODY_FILE" >> "$GITHUB_OUTPUT" | |
| printf '%s\n' "$DELIM" >> "$GITHUB_OUTPUT" | |
| # Extract only the checkbox lines between version-bump markers | |
| CHECKBOX_LINES=$(awk '/<!--changelog-type-start-->/, /<!--changelog-type-end-->/' "$PR_BODY_FILE") | |
| if [ -z "$CHECKBOX_LINES" ]; then | |
| echo "::warning::Version-bump markers not found in PR body; scanning full body." | |
| CHECKBOX_LINES=$(cat "$PR_BODY_FILE") | |
| fi | |
| rm -f "$PR_BODY_FILE" | |
| # Detect checked version-bump checkbox | |
| if grep -qE '\- \[[xX]\] \*\*Major\*\*' <<< "$CHECKBOX_LINES"; then | |
| echo "bump_type=major" >> "$GITHUB_OUTPUT" | |
| elif grep -qE '\- \[[xX]\] \*\*Minor\*\*' <<< "$CHECKBOX_LINES"; then | |
| echo "bump_type=minor" >> "$GITHUB_OUTPUT" | |
| elif grep -qE '\- \[[xX]\] \*\*Patch\*\*' <<< "$CHECKBOX_LINES"; then | |
| echo "bump_type=patch" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "::error::No version bump checkbox selected in PR #$PR_NUMBER." | |
| exit 1 | |
| fi | |
| - name: Compute new version | |
| if: steps.bump.outputs.bump_type != 'none' | |
| id: version | |
| run: | | |
| CURRENT=$(node -p "require('./package.json').version") | |
| BUMP="${{ steps.bump.outputs.bump_type }}" | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT" | |
| case "$BUMP" in | |
| major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;; | |
| minor) MINOR=$((MINOR + 1)); PATCH=0 ;; | |
| patch) PATCH=$((PATCH + 1)) ;; | |
| esac | |
| NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" | |
| echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT" | |
| echo "current_version=$CURRENT" >> "$GITHUB_OUTPUT" | |
| - name: Update version in package.json and manifest.json | |
| if: steps.bump.outputs.bump_type != 'none' | |
| run: | | |
| NEW="${{ steps.version.outputs.new_version }}" | |
| # Update package.json | |
| node -e " | |
| const fs = require('fs'); | |
| const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); | |
| pkg.version = '${NEW}'; | |
| fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); | |
| " | |
| # Update manifest.json | |
| node -e " | |
| const fs = require('fs'); | |
| const m = JSON.parse(fs.readFileSync('manifest.json', 'utf8')); | |
| m.version = '${NEW}'; | |
| fs.writeFileSync('manifest.json', JSON.stringify(m, null, 2) + '\n'); | |
| " | |
| # Update versions.json | |
| node -e " | |
| const fs = require('fs'); | |
| const v = JSON.parse(fs.readFileSync('versions.json', 'utf8')); | |
| const minApp = JSON.parse(fs.readFileSync('manifest.json', 'utf8')).minAppVersion; | |
| v['${NEW}'] = minApp; | |
| fs.writeFileSync('versions.json', JSON.stringify(v, null, 2) + '\n'); | |
| " | |
| - name: Extract PR description for changelog | |
| if: steps.bump.outputs.bump_type != 'none' | |
| id: changelog_entry | |
| env: | |
| PR_BODY: ${{ steps.bump.outputs.pr_body }} | |
| run: | | |
| # Extract text between changelog-description markers | |
| DESCRIPTION=$(echo "$PR_BODY" | \ | |
| awk '/<!--changelog-description-start-->/,/<!--changelog-description-end-->/' | \ | |
| grep -v '<!--' | sed '/^[[:space:]]*$/d') | |
| if [ -z "$DESCRIPTION" ]; then | |
| DESCRIPTION="No description provided." | |
| fi | |
| DELIM="EOF_$(date +%s)_$RANDOM" | |
| { | |
| echo "description<<$DELIM" | |
| echo "$DESCRIPTION" | |
| echo "$DELIM" | |
| } >> "$GITHUB_OUTPUT" | |
| - name: Update CHANGELOG.md | |
| if: steps.bump.outputs.bump_type != 'none' | |
| env: | |
| NEW: ${{ steps.version.outputs.new_version }} | |
| DESCRIPTION: ${{ steps.changelog_entry.outputs.description }} | |
| PR_NUMBER: ${{ steps.bump.outputs.pr_number }} | |
| GITHUB_REPOSITORY: ${{ github.repository }} | |
| run: | | |
| DATE=$(date +%Y-%m-%d) | |
| # Insert new entry after the first line (# Changelog header) | |
| DATE="$DATE" node -e ' | |
| const fs = require("fs"); | |
| const NEW = process.env.NEW; | |
| const DATE = process.env.DATE; | |
| const DESCRIPTION = process.env.DESCRIPTION || "No description provided."; | |
| const PR = process.env.PR_NUMBER; | |
| const REPO = process.env.GITHUB_REPOSITORY; | |
| const content = fs.readFileSync("CHANGELOG.md", "utf8"); | |
| const lines = content.split("\n"); | |
| // Find the first line that starts with "## " after the header | |
| let insertAt = lines.findIndex((l, i) => i > 0 && l.startsWith("## ")); | |
| if (insertAt === -1) insertAt = lines.length; | |
| const entry = `## [${NEW}] – ${DATE}\n\n### Changed\n\n${DESCRIPTION} (PR #${PR})\n\n[${NEW}]: https://github.com/${REPO}/releases/tag/${NEW}\n`; | |
| lines.splice(insertAt, 0, entry); | |
| fs.writeFileSync("CHANGELOG.md", lines.join("\n")); | |
| ' | |
| - name: Commit version and changelog updates | |
| if: steps.bump.outputs.bump_type != 'none' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add package.json manifest.json versions.json CHANGELOG.md | |
| git commit -m "chore: release ${{ steps.version.outputs.new_version }} [skip ci]" | |
| git push | |
| - name: Build release artifacts | |
| if: steps.bump.outputs.bump_type != 'none' | |
| run: npm run build | |
| - name: Create GitHub Release | |
| if: steps.bump.outputs.bump_type != 'none' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NEW: ${{ steps.version.outputs.new_version }} | |
| DESCRIPTION: ${{ steps.changelog_entry.outputs.description }} | |
| run: | | |
| gh release create "${NEW}" \ | |
| --title "${NEW}" \ | |
| --notes "${DESCRIPTION}" \ | |
| main.js manifest.json | |
| # -------------------------------------------------------------------------- | |
| # Obsidian Community Plugins marketplace | |
| # -------------------------------------------------------------------------- | |
| # Publishing to the Obsidian Community Plugins marketplace is a manual | |
| # process that requires opening a pull request in the official | |
| # obsidianmd/obsidian-releases repository: | |
| # https://github.com/obsidianmd/obsidian-releases | |
| # | |
| # Steps (one-time, to list the plugin): | |
| # 1. Fork obsidianmd/obsidian-releases. | |
| # 2. Add an entry to community-plugins.json with your plugin id, name, | |
| # author, description, and repo. | |
| # 3. Open a PR to obsidianmd/obsidian-releases and wait for approval. | |
| # | |
| # Once listed, subsequent releases are picked up automatically by Obsidian | |
| # when the GitHub release tag matches the version in manifest.json. | |
| # No additional automation step is required for updates after the initial | |
| # listing PR is merged. | |
| # -------------------------------------------------------------------------- |