📝 Edit page
➕ Add page
Publish
Publish a Node package to GitHub or NPM
Samples
Use NPM Publish
Examples from Publishing Node.js packages in the GH Actions docs. There is an example there for Yarn too.
See also About packaging with GitHub Actions.
- Publish to NPM -
main.yml
name: Node.js Package on: release: types: [created] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 # Set up .npmrc file to publish to npm - uses: actions/setup-node@v1 with: node-version: '12.x' registry-url: 'https://registry.npmjs.org' - run: npm install - run: npm publish env: NODE_AUTH_TOKEN: $
- Publish to GitHub -
main.yml
name: Node.js Package on: release: types: [created] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 # Set up .npmrc file to publish to GitHub Packages - uses: actions/setup-node@v1 with: node-version: '12.x' registry-url: 'https://npm.pkg.github.com' # Defaults to the user or organization that owns the workflow file scope: '@octocat' - run: npm install - run: npm publish env: NODE_AUTH_TOKEN: $
Semantic release
See semantic-release/semantic-release and docs.
semantic-release automates the whole package release workflow including: determining the next version number, generating the release notes and publishing the package.
Based on workflow in Presite.
main.yml
steps: - uses: actions/checkout@v2 - name: Use Node.js $ uses: actions/setup-node@v1 with: node-version: $ - run: npm install - run: npm test - run: npx semantic-release env: GITHUB_TOKEN: $ NPM_TOKEN: $