https://github.com/springtype-org/github-action-npm-publish
https://github.com/springtype-org/github-action-npm-publish
Last synced: 9 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/springtype-org/github-action-npm-publish
- Owner: springtype-org
- License: mit
- Created: 2020-05-22T15:20:59.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-28T08:58:34.000Z (almost 2 years ago)
- Last Synced: 2025-01-05T06:29:49.039Z (about 1 year ago)
- Language: TypeScript
- Size: 341 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
github-action-npm-publish
> This GitHub Action automates the process of publishing npm packages. It simplifies the workflow for JavaScript and TypeScript projects by integrating seamlessly with your CI/CD pipeline. With this action, you can automatically publish your npm package whenever changes are pushed to your repository, ensuring that your package is always up-to-date with the latest commits.
User Stories
1. As a developer, I want to automate the npm publishing process to save time and reduce manual errors.
2. As a developer, I want to ensure that my npm package is published whenever changes are pushed to the main branch.
Features
- ✅ Automates npm package publishing
- ✅ Integrates seamlessly with GitHub Actions workflows
- ✅ Supports scoped packages
- ✅ Configurable to run on specific branches or tags
- ✅ Securely handles npm authentication
- ✅ Provides detailed logs for troubleshooting
- ✅ Supports both JavaScript and TypeScript projects
- ✅ Easily configurable via `npmrc` settings
Example Usage
Setup
1. **Create a GitHub Workflow File**:
Add a new YAML file in `.github/workflows/` (e.g., `publish.yml`):
```yaml
name: Publish to npm
on:
push:
branches:
- main
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install dependencies
run: npm install
- name: Publish to npm
uses: your-username/github-action-npm-publish@v1
with:
authToken: ${{ secrets.NPM_AUTH_TOKEN }}
registry: 'https://registry.npmjs.org/'
```
2. **Set Up npm Authentication**:
Store your npm authentication token as a secret in your GitHub repository settings. Go to `Settings > Secrets` and add a new secret named `NPM_AUTH_TOKEN` with your npm token.
Using the Action
- **Publishing**:
The action will automatically publish your package to npm whenever you push changes to the `main` branch (or any other branch you configure).
```yaml
- name: Publish to npm
uses: your-username/github-action-npm-publish@v1
with:
authToken: ${{ secrets.NPM_AUTH_TOKEN }}
registry: 'https://registry.npmjs.org/'
```
Configuration
- **authToken**: The npm authentication token. Store it securely in GitHub secrets.
- **registry**: The npm registry URL (default: `https://registry.npmjs.org/`).
Troubleshooting
- Ensure that the `NPM_AUTH_TOKEN` secret is correctly set in your GitHub repository.
- Verify that the workflow file is correctly configured and located in the `.github/workflows/` directory.
- Check the action logs in the GitHub Actions tab for detailed error messages and troubleshooting steps.
Support
For any issues or feature requests, please open an issue on the [GitHub repository](https://github.com/your-username/github-action-npm-publish/issues).
---
This action simplifies and automates the npm publishing process, ensuring that your packages are always up-to-date with minimal manual intervention.