-
Notifications
You must be signed in to change notification settings - Fork 0
Publish a developer package to the GitHub npm registry with GitHub Actions #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3a94bc8
feat(gha): publish developer package
kikuomax 21a402d
fix(gha): wrong short commit hash output name
kikuomax f72be5b
docs: update README for how to install developer package
kikuomax a4018e1
chore: bundle README.ja.md into package
kikuomax e954f0e
docs: update README.ja.md
kikuomax 70abf7d
chore(gha): remove trigger for experiments
kikuomax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| name: "Publish a developer package to GitHub npm registry" | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| jobs: | ||
| publish-dev: | ||
| uses: ./.github/workflows/publish-package.yml | ||
|
|
||
| with: | ||
| npm-registry-url: "https://npm.pkg.github.com" | ||
|
|
||
| secrets: | ||
| npm-token: ${{ secrets.GITHUB_TOKEN }} |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| name: "Publish a package to a specified npm registry" | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| npm-registry-url: | ||
| description: "URL of the npm registry to publish to; e.g., https://npm.pkg.github.com for GitHub Packages" | ||
| type: string | ||
| required: true | ||
|
|
||
| secrets: | ||
| npm-token: | ||
| description: "Token that is allowed to publish to the npm registry; e.g., secrets.GITHUB_TOKEN for GitHub Packages" | ||
| required: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
| packages: write | ||
|
|
||
| env: | ||
| node-version: 22 | ||
| pnpm-version: 10 | ||
|
|
||
| jobs: | ||
| build-and-publish: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Get short commit hash | ||
| id: commit-hash | ||
| run: echo "short-commit-hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | ||
|
|
||
| # appends the short commit hash to the version number | ||
| # 1. reads the package.json file | ||
| # 2. replaces the version and saves it in the package.json | ||
| - name: Read package information | ||
| id: package-info | ||
| # uses the exact commit to prevent harmful updates | ||
| uses: jaywcjlove/github-action-package@f6a7afaf74f96a166243f05560d5af4bd4eaa570 | ||
| with: | ||
| path: package.json | ||
| - name: Append short commit hash to the version | ||
| # uses the exact commit to prevent harmful updates | ||
| uses: jaywcjlove/github-action-package@f6a7afaf74f96a166243f05560d5af4bd4eaa570 | ||
| with: | ||
| path: package.json | ||
| version: ${{ steps.package-info.outputs.version }}-${{ steps.commit-hash.outputs.short-commit-hash }} | ||
|
|
||
| - name: Install pnpm ${{ env.pnpm-version }} | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: ${{ env.pnpm-version }} | ||
|
|
||
| - name: Setup Node.js ${{ env.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ env.node-version }} | ||
| cache: pnpm | ||
| registry-url: ${{ inputs.npm-registry-url }} | ||
| scope: "@codemonger-io" | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install | ||
|
|
||
| # the build script is executed by the prepare script | ||
| - name: Build and publish | ||
| env: | ||
| NODE_AUTH_TOKEN: ${{ secrets.npm-token }} | ||
| run: pnpm publish --no-git-checks | ||
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.