feat: add GitHub Actions workflows for code quality and automation (#2)

This commit is contained in:
2025-02-02 00:42:19 +02:00
committed by GitHub
parent af6ecdf6ca
commit 210aa969b3
105 changed files with 8807 additions and 408 deletions

43
npm-publish/README.md Normal file
View 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
View 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 }}