Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 12, 2025

Plan: Add GitHub Packages Publishing Support

This task adds support for publishing the library to GitHub Packages in addition to npm, using GitHub Actions.

Checklist:

  • Explore repository structure and understand current setup
  • Review existing release workflow and package.json
  • Create .npmrc file for GitHub Packages authentication (Removed - not needed)
  • Update release workflow to publish to both npm and GitHub Packages
  • Verify token permissions are properly configured
  • Validate YAML syntax
  • Update README with installation instructions for GitHub Packages
  • Update README with release process documentation
  • Run code review and address feedback
  • Address review comments:
    • Removed .npmrc file (was interfering with npm publish)
    • Added rebuild step before GitHub Packages publish
    • Fixed README comment about manual publishing
    • Fixed Prettier formatting issues
  • Run security checks (CodeQL) - no issues found
  • Final validation complete

Summary of Changes:

Files Modified:

  1. .github/workflows/release.yml - Enhanced to publish to both npm and GitHub Packages with rebuild
  2. .npmrc - Removed (not needed, uses registry-url in workflow instead)
  3. README.md - Updated with installation and release documentation
  4. vitest.config.js - Prettier formatting fix

Key Implementation Details:

Token Permissions: Workflow already has packages: write permission
Dual Publishing: Publishes to npm first, then rebuilds and publishes to GitHub Packages
Conditional Logic: Only publishes to GitHub Packages when changesets actually publishes
Authentication: Uses NPM_TOKEN for npm, GITHUB_TOKEN for GitHub Packages via registry-url
No .npmrc needed: Registry configuration handled by actions/setup-node
Rebuild before GitHub Packages: Ensures clean build for GitHub Packages
Documentation: Clear instructions for users on both installation methods
Security: No vulnerabilities detected by CodeQL scanner
Formatting: All files pass Prettier checks

Original prompt

このライブラリをnpmだけでなくgithub packagesにもアップするようにしてほしい。
GitHub Actionsから行うこと。それから、トークン権限に注意。


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add support for publishing to GitHub Packages Add GitHub Packages publishing to release workflow Dec 12, 2025
Copilot AI requested a review from yuki-js December 12, 2025 17:52
@yuki-js yuki-js marked this pull request as ready for review December 12, 2025 17:57
Copilot AI review requested due to automatic review settings December 12, 2025 17:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables dual-publishing of the @aokiapp/tlv package to both npm and GitHub Packages registries through GitHub Actions when releases are created.

  • Added GitHub Packages publishing step in the release workflow that triggers after successful npm publish
  • Created registry configuration file (.npmrc) for the @aokiapp scope
  • Updated documentation with installation instructions for both registries

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
.npmrc Adds registry configuration pointing @aokiapp scope to GitHub Packages with token authentication
.github/workflows/release.yml Extends release workflow to publish to GitHub Packages after npm publish, with separate Node.js setup steps for each registry
README.md Documents installation instructions for both npm and GitHub Packages, including authentication requirements and automatic publishing behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.npmrc Outdated
Comment on lines 1 to 2
@aokiapp:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

This .npmrc configuration will interfere with npm registry publishing. By setting the registry for the @aokiapp scope globally, all npm operations for @aokiapp/tlv (including the initial npm publish in the workflow) will attempt to use GitHub Packages registry instead of the npm registry.

This configuration should either be:

  1. Removed entirely and rely on the registry-url parameter in actions/setup-node to configure the registry per step, or
  2. Only applied conditionally during the GitHub Packages publish step (e.g., by creating the file dynamically in the workflow)

The workflow's registry-url parameter in actions/setup-node should be sufficient to configure the appropriate registry for each publish step without needing this file.

Suggested change
@aokiapp:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in bd8307f - removed .npmrc file entirely. The workflow now relies solely on registry-url parameter in actions/setup-node to configure registries per step.


- name: Publish to GitHub Packages
if: steps.changesets.outputs.published == 'true'
run: npm publish
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The GitHub Packages publish step should rebuild the package before publishing. When npm run release executes (which runs npm run build && changeset publish), it builds the package for npm. However, when publishing to GitHub Packages, you're reusing the same built artifacts without rebuilding. This could be problematic if:

  1. The build process embeds registry URLs or configuration
  2. You want to ensure a clean build for each registry
  3. There are any registry-specific modifications needed

Consider adding npm run build before the npm publish command, or ensuring that the build artifacts are registry-agnostic. For example:

run: npm run build && npm publish
Suggested change
run: npm publish
run: npm run build && npm publish

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in bd8307f - added npm run build before npm publish in the GitHub Packages publish step to ensure a clean build.

README.md Outdated
npm run changelog # Create changeset
npm run version # Update version
npm run publish # Publish to npm
npm run publish # Publish to npm (manual, or use GitHub Actions)
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The comment is misleading - it suggests npm publish is "manual, or use GitHub Actions", but based on the workflow, npm publish is automated via the changesets action. The manual commands shown are for local development/testing, not the primary release method.

Consider clarifying this to make it clear that GitHub Actions is the primary/recommended method for releases, and manual publishing is only for special cases or local testing. For example: "Publish manually (for testing, otherwise use GitHub Actions)"

Suggested change
npm run publish # Publish to npm (manual, or use GitHub Actions)
npm run publish # Publish manually (for testing, otherwise use GitHub Actions)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in bd8307f - updated comment to clarify: "Publish manually (for testing, otherwise use GitHub Actions)"

@yuki-js
Copy link
Member

yuki-js commented Dec 12, 2025

Copy link
Contributor Author

Copilot AI commented Dec 12, 2025

https://github.com/AokiApp/tlv/actions/runs/20175243863/job/57922046535?pr=13 is failing @copilot

Fixed in bd8307f - the CI failure was due to Prettier formatting issues in README.md and vitest.config.js. Both files have been formatted and should now pass the checks.

@yuki-js yuki-js merged commit 18069a7 into main Dec 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants