GitHub Packages のプライベートパッケージ @onk0239/my-era-converter を 1.0.0 から 1.1.0 に更新する完全な手順を説明します。
cd path/to/my-era-converter
{
"name": "@onk0239/my-era-converter",
"version": "1.1.0", // 1.0.0 → 1.1.0 に変更
"type": "module",
// 他の設定はそのまま保持
}
git add package.json
git commit -m "バージョン1.1.0に更新"
git push origin main
git tag v1.1.0
git push origin v1.1.0
npm publish
.npmrc 設定確認//npm.pkg.github.com/:_authToken=ghp_あなたのトークン
@onk0239:registry=https://npm.pkg.github.com
npm install @onk0239/my-era-converter@1.1.0
"dependencies": {
"@onk0239/my-era-converter": "^1.1.0"
}
FROM node:20-alpine
WORKDIR /app
# GitHub認証設定
COPY .npmrc .
RUN chmod 600 .npmrc && \
npm config set @onk0239:registry=https://npm.pkg.github.com
# パッケージインストール
COPY package.json .
RUN npm install
# セキュリティ対策で.npmrc削除
RUN rm -f .npmrc
COPY . .
CMD ["npm", "start"]
# インストールされたバージョン確認
npm list @onk0239/my-era-converter
# レジストリ上の最新バージョン確認
npm view @onk0239/my-era-converter versions --registry=https://npm.pkg.github.com
エラー: 404 Not Found
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/@onk0239%2fmy-era-converter
解決方法:
read:packages権限があるか確認# 認証状態確認
npm whoami --registry=https://npm.pkg.github.com
セマンティックバージョニング
変更履歴管理
## [1.1.0] - 2025-08-11
### Added
- 新しい和暦フォーマットを追加
### Fixed
- 閏年の計算ロジックを修正
GitHub Actions での自動公開
# .github/workflows/publish.yml
name: Publish Package
on:
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
registry-url: https://npm.pkg.github.com
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}