Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
50 changes: 42 additions & 8 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ on:
tag:
# `npm publish --tag X` only works for a *new* version. To re-tag an
# already-published version, use `npm dist-tag add` outside this workflow.
description: "Dist-tag for the new version being published (e.g. next, beta). Does not retag existing versions."
# Leave blank to auto-detect: semver prereleases (anything with a `-`
# in the version) publish under `next`, stable versions under `latest`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Major] dist-tag 설정이 자동으로 결정되도록 수정되었습니다. RC 버전이 배포될 경우 stable 버전이 아닌 next 버전으로 배포될 수 있습니다.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Major] dist-tag override에 대한 설명이 부족합니다. 사용자가 dist-tag를 명시적으로 지정할 수 있도록 설명해야 합니다.

description: "Dist-tag override (leave blank for auto: prerelease→next, stable→latest)"
required: false
default: "latest"
default: ""

jobs:
publish:
Expand All @@ -33,11 +35,25 @@ jobs:

- uses: actions/setup-node@v4
with:
# Node 22 ships npm 11; npm Trusted Publishers (OIDC) requires
# npm 11.5.1+ to perform the OIDC token exchange.
node-version: "22"
# Node 24 LTS ships npm 11.x; npm Trusted Publishers (OIDC) needs
# npm 11.5.1+ to perform the token exchange. Node 22's older
# patch releases shipped npm 10.x, so picking 24 sidesteps the
# need to upgrade npm out-of-band.
node-version: "24"
registry-url: "https://registry.npmjs.org"

- name: Verify npm version supports OIDC trusted publishers
# Belt-and-suspenders against actions/setup-node ever resolving an
# older Node 24 patch with a too-old bundled npm.
run: |
NPM_VERSION=$(npm --version)
REQUIRED="11.5.1"
if [ "$(printf '%s\n%s\n' "$REQUIRED" "$NPM_VERSION" | sort -V | head -n1)" != "$REQUIRED" ]; then
echo "::error::npm $NPM_VERSION installed; OIDC trusted publishers require >= $REQUIRED"
exit 1
fi
echo "npm $NPM_VERSION ≥ $REQUIRED ✓"

- name: Verify release commit is on main
if: github.event_name == 'release'
# Catches releases accidentally cut from a feature branch or stale commit.
Expand Down Expand Up @@ -75,6 +91,26 @@ jobs:
# Catch ESM/CJS or path-resolution regressions before publishing.
run: npm run smoke

- name: Resolve npm dist-tag
id: dist_tag
# A semver prerelease (2.0.1-rc.1) accidentally going out under the
# `latest` tag would displace the stable release for every consumer
# doing `npm install <pkg>`. Auto-route prereleases to `next`; allow
# an explicit override via workflow_dispatch.
env:
INPUT_TAG: ${{ inputs.tag }}
run: |
PKG_VERSION=$(node -p "require('./package.json').version")
if [ -n "$INPUT_TAG" ]; then
DIST_TAG="$INPUT_TAG"
elif [[ "$PKG_VERSION" == *-* ]]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Suggestion] Bash의 [[ ... == *-* ]] 구문도 훌륭하지만, 버전 문자열 검증을 더 엄격하게 수행하려면 [[ "$PKG_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+-.*$ ]] 형태의 정규식을 활용하여 예기치 않은 비표준 버전 포맷에 대한 라우팅 오류를 방어하는 것도 좋은 방법입니다.

DIST_TAG="next"
else
DIST_TAG="latest"
fi
echo "Publishing $PKG_VERSION under dist-tag: $DIST_TAG"
echo "tag=$DIST_TAG" >> "$GITHUB_OUTPUT"

- name: Publish to npm
# Authentication is handled by npm Trusted Publishers (OIDC) — the
# `id-token: write` permission above plus the registry-url from
Expand All @@ -83,6 +119,4 @@ jobs:
# required; nothing to rotate every 90 days.
# `provenance: true` lives in package.json's publishConfig, so it
# applies regardless of who runs `npm publish`.
run: npm publish --tag "${TAG:-latest}"
env:
TAG: ${{ inputs.tag }}
run: npm publish --tag "${{ steps.dist_tag.outputs.tag }}"
4 changes: 2 additions & 2 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
ruby-version: "3.3"
- uses: actions/setup-node@v4
with:
# Match the publish workflow (Node 22 / npm 11) so the smoke test
# Match the publish workflow (Node 24 / npm 11) so the smoke test
# runs against the same runtime we'll publish from.
node-version: "22"
node-version: "24"
- uses: actions/setup-python@v5
with:
python-version: "3.11"
Expand Down
2 changes: 1 addition & 1 deletion packages/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@swift-man/material-design-color",
"version": "2.0.0",
"version": "2.0.1-rc.1",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[Major] PR 본문에서 'rc' 태그 배포를 의도하셨으나, 기존처럼 GitHub Release 이벤트를 통해 이 버전을 배포하게 되면 워크플로우의 ${TAG:-latest} 폴백 처리로 인해 npm에 latest 태그가 덮어씌워질 위험이 큽니다. 이번 배포는 기존 latest 보호를 위해 가급적 GitHub Actions 탭에서 workflow_dispatch 이벤트를 이용해 tag 파라미터에 rc를 직접 입력하여 수동 실행하시길 권장합니다.

"type": "module",
"description": "Material Design 3 color schemes (light/dark, 48 roles) and Material 2 palette for TypeScript / JavaScript. Framework-agnostic — works in React Native, Expo, web, Node.",
"license": "MIT",
Expand Down
Loading