mirror of
https://github.com/ivuorinen/actions.git
synced 2026-01-26 03:23:59 +00:00
feat: add GitHub Actions workflows for code quality and automation (#2)
This commit is contained in:
43
npm-publish/README.md
Normal file
43
npm-publish/README.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# ivuorinen/actions/npm-publish
|
||||
|
||||
## Publish to NPM
|
||||
|
||||
### Description
|
||||
|
||||
Publishes the package to the NPM registry with configurable scope and registry URL.
|
||||
|
||||
### Inputs
|
||||
|
||||
| name | description | required | default |
|
||||
| ----------------- | ----------------------------------- | -------- | -------------------------------------- |
|
||||
| `registry-url` | <p>Registry URL for publishing.</p> | `false` | `https://registry.npmjs.org/` |
|
||||
| `scope` | <p>Package scope to use.</p> | `false` | `@ivuorinen` |
|
||||
| `package-version` | <p>The version to publish.</p> | `false` | `${{ github.event.release.tag_name }}` |
|
||||
|
||||
### Runs
|
||||
|
||||
This action is a `composite` action.
|
||||
|
||||
### Usage
|
||||
|
||||
```yaml
|
||||
- uses: ivuorinen/actions/npm-publish@main
|
||||
with:
|
||||
registry-url:
|
||||
# Registry URL for publishing.
|
||||
#
|
||||
# Required: false
|
||||
# Default: https://registry.npmjs.org/
|
||||
|
||||
scope:
|
||||
# Package scope to use.
|
||||
#
|
||||
# Required: false
|
||||
# Default: @ivuorinen
|
||||
|
||||
package-version:
|
||||
# The version to publish.
|
||||
#
|
||||
# Required: false
|
||||
# Default: ${{ github.event.release.tag_name }}
|
||||
```
|
||||
57
npm-publish/action.yml
Normal file
57
npm-publish/action.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
---
|
||||
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
|
||||
name: Publish to NPM
|
||||
description: 'Publishes the package to the NPM registry with configurable scope and registry URL.'
|
||||
author: 'Ismo Vuorinen'
|
||||
|
||||
branding:
|
||||
icon: package
|
||||
color: green
|
||||
|
||||
inputs:
|
||||
registry-url:
|
||||
description: 'Registry URL for publishing.'
|
||||
required: false
|
||||
default: 'https://registry.npmjs.org/'
|
||||
scope:
|
||||
description: 'Package scope to use.'
|
||||
required: false
|
||||
default: '@ivuorinen'
|
||||
package-version:
|
||||
description: 'The version to publish.'
|
||||
required: false
|
||||
default: ${{ github.event.release.tag_name }}
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Setup Node.js
|
||||
uses: ivuorinen/actions/node-setup@main
|
||||
|
||||
- name: Authenticate NPM
|
||||
shell: bash
|
||||
run: |
|
||||
echo "//${{ inputs.registry-url }}/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
|
||||
|
||||
- name: Publish Package
|
||||
shell: bash
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
pkg_version=$(node -p "require('./package.json').version")
|
||||
if [ "$pkg_version" != "${{ inputs.package-version }}" ]; then
|
||||
echo "Version mismatch: package.json ($pkg_version) != input (${{ inputs.package-version }})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dry run first
|
||||
npm publish \
|
||||
--registry ${{ inputs.registry-url }} \
|
||||
--dry-run \
|
||||
--scope ${{ inputs.scope }}
|
||||
|
||||
npm publish \
|
||||
--registry ${{ inputs.registry-url }} \
|
||||
--verbose \
|
||||
--scope ${{ inputs.scope }} \
|
||||
--tag ${{ inputs.package-version }}
|
||||
Reference in New Issue
Block a user