Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .github/workflows/release-version-alignment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: Release Version Alignment

on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
Comment on lines +4 to +7

Comment on lines +3 to +8
permissions:
contents: write

jobs:
publish-and-label:
if: github.actor != 'github-actions[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 20
registry-url: https://registry.npmjs.org

- name: Restrict manual runs to main
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main'
shell: bash
run: |
echo "::error::workflow_dispatch is only allowed from refs/heads/main."
exit 1

- name: Resolve release version
id: version
shell: bash
run: |
set -euo pipefail
PACKAGE_NAME="$(node -p "require('./package.json').name")"
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
EXPECTED_TAG="v${PACKAGE_VERSION}"

if [[ "${GITHUB_REF_TYPE:-}" == "tag" && "${GITHUB_REF_NAME}" != "${EXPECTED_TAG}" ]]; then
echo "::error::Tag '${GITHUB_REF_NAME}' must match package version tag '${EXPECTED_TAG}'."
exit 1
fi

if ! grep -qE "^## \\[${PACKAGE_VERSION//./\\.}\\] - " CHANGELOG.md; then
echo "::error::CHANGELOG.md is missing an entry for version ${PACKAGE_VERSION}."
exit 1
fi

echo "package_name=${PACKAGE_NAME}" >> "$GITHUB_OUTPUT"
echo "package_version=${PACKAGE_VERSION}" >> "$GITHUB_OUTPUT"
echo "expected_tag=${EXPECTED_TAG}" >> "$GITHUB_OUTPUT"

- name: Check npm for target version
id: npm_check
shell: bash
env:
PACKAGE_NAME: ${{ steps.version.outputs.package_name }}
PACKAGE_VERSION: ${{ steps.version.outputs.package_version }}
run: |
set -euo pipefail
if npm view "${PACKAGE_NAME}@${PACKAGE_VERSION}" version >/dev/null 2>&1; then
echo "already_published=true" >> "$GITHUB_OUTPUT"
echo "Version ${PACKAGE_VERSION} is already published on npm."
else
echo "already_published=false" >> "$GITHUB_OUTPUT"
echo "Version ${PACKAGE_VERSION} is not yet published on npm."
fi

- name: Ensure npm token is configured
if: steps.npm_check.outputs.already_published == 'false' && secrets.NPM_TOKEN == ''
shell: bash
env:
PACKAGE_NAME: ${{ steps.version.outputs.package_name }}
PACKAGE_VERSION: ${{ steps.version.outputs.package_version }}
run: |
echo "::error::Missing NPM_TOKEN secret; cannot publish ${PACKAGE_NAME}@${PACKAGE_VERSION}."
exit 1

- name: Publish package to npm
if: steps.npm_check.outputs.already_published == 'false'
shell: bash
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public

- name: Create tag on manual run
if: github.event_name == 'workflow_dispatch'
shell: bash
env:
EXPECTED_TAG: ${{ steps.version.outputs.expected_tag }}
run: |
set -euo pipefail
if git rev-parse -q --verify "refs/tags/${EXPECTED_TAG}" >/dev/null; then
echo "Tag ${EXPECTED_TAG} already exists."
else
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag "${EXPECTED_TAG}"
git push origin "${EXPECTED_TAG}"
echo "Created and pushed tag ${EXPECTED_TAG}."
fi

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.expected_tag }}
name: ${{ steps.version.outputs.expected_tag }}
generate_release_notes: true
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

All notable changes to this project will be documented in this file.

## [1.0.2] - 2026-05-25
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot this should be [1.0.2]-2026-05-25

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 5df09f9: the changelog heading now uses ## [1.0.2]-2026-05-25.


### Added

- `.github/workflows/sync-package-version-with-main.yml` to keep pull request branch versions aligned with `main`.
- `.github/workflows/release-version-alignment.yml` to enforce matching GitHub tag, `package.json`, changelog entry, and npm publish target version.

### Changed

- Bumped package version to `1.0.2`.
- Upgraded `stylelint` from `^16.24.0` to `^17.12.0`.
- Updated GitHub Actions in CI:
- `actions/checkout` from `v4` to `v6`
- `actions/setup-node` from `v4` to `v6`

## [1.0.1] - 2026-05-25

### Fixed

- Patched release metadata and demo HTML (`package.json`, `index.html`) for package stability.

## [1.0.0] - 2026-05-24

### Added
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.