Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/evg4b/goreleaser-npm-publisher

Build and publish npm packages based on goreleaser output folder
https://github.com/evg4b/goreleaser-npm-publisher

binary cli goreleaser npm npm-publish publish release

Last synced: 15 days ago
JSON representation

Build and publish npm packages based on goreleaser output folder

Awesome Lists containing this project

README

        



goreleaser-npm-publisher logo



goreleaser-npm-publisher





NPM Version


NPM Downloads


NPM Unpacked Size




GitHub Actions Workflow Status


Git Hub Release


License




Quality Gate Status


Coverage


Lines of code



Automated tool for building and publishing NPM packages from Go binaries.

# Quick start:

Firstly create release of your package via [goreleaser](https://goreleaser.com/).

```shell
goreleaser build --clean
```

Then just run `goreleaser-npm-publisher` in the same directory (pay attention you should be logging in the registry).

```shell
npx -y goreleaser-npm-publisher publish --clean
```

Or add `--token` parameter to use yor NPM_AUTH_TOKEN

```shell
npx -y goreleaser-npm-publisher publish --clean --token npm_********
```

That's it.

## Use as a library

You can use `goreleaser-npm-publisher` as a standard npm package

```ts publish.ts
import { publish } from 'goreleaser-npm-publisher';

publish({ token: process.env.NPM_TOKEN })
.then(console.log)
.catch(console.error);
```

## Use as a GitHub Action

You can use `goreleaser-npm-publisher` as a GitHub Action.

```yaml
- name: Publish to npm
uses: evg4b/[email protected]
with:
prefix: 'evg4b'
token: ${{ secrets.NPM_AUTH_TOKEN }}
```

For more details see [GitHub Action documentation](https://github.com/evg4b/goreleaser-npm-publisher-action)

## CLI commands and options:

The `goreleaser-npm-publisher` has the following CLI commands:

### list

Displays a list of packages that can be built in the current project with passed options.

#### Options

| Option | type | Description |
| --------------- | ------- | ------------------------------------------------------------------------- |
| **project** | string | Path to the root of go package |
| **builder** | string | The name of the builder whose output should be used for building packages |
| **prefix** | string | NPM package scope prefix |
| **description** | string | NPM package description |
| **verbose** | boolean | Print verbose output |

### build

Builds all packages that can be built in the current project with the specified parameters.
Built packages can be found in the `dist/npm` folder.

| Option | Type | Description |
| --------------- | -------- | ------------------------------------------------------------------------------------- |
| **project** | string | Path to the root of go package |
| **builder** | string | The name of the builder whose output should be used for building packages |
| **clear** | boolean | Clean `dist/npm` folder before build |
| **prefix** | string | NPM package scope prefix |
| **description** | string | NPM package description |
| **files** | string[] | Files witch should be included to the NPM package (`README.md`, `license` by default) |
| **verbose** | boolean | Print verbose output |

### publish

Builds and publishes to the `registry` all packages that can be built in the current project with the specified
parameters.

| Option | Type | Description |
| --------------- | -------- | ------------------------------------------------------------------------------------- |
| **project** | string | Path to the root of go package |
| **builder** | string | The name of the builder whose output should be used for building packages |
| **clear** | boolean | Clean `dist/npm` folder before build |
| **prefix** | string | NPM package scope prefix |
| **description** | string | NPM package description |
| **files** | string[] | Files witch should be included to the NPM package (`README.md`, `license` by default) |
| **token** | string | The NPM auth token |
| **verbose** | boolean | Print verbose output |

## Structure of npm package:

The output will have a main package and platform packages.
The main package will contain the executable script
which will detect the platform and architecture and run the corresponding platform package.
Platform packages will contain the Go binary for the specific platform and architecture.

For example, for the package `go-package` with version `0.0.17`, and goreleaser build for `linux`, `windows`, `darwin`
and `ia32`, `x64`, `arm64` architectures:

Main package:

```
[email protected]
os: linux, win32, darwin
cpu: ia32, x64, arm64
```

Platform packages:

```
[email protected]
os: linux
cpu: ia32
bin: /Users//go-package/dist/npm/dist-go-package-linux-386-go-package

[email protected]
os: win32
cpu: ia32
bin: /Users//go-package/dist/npm/dist-go-package-windows-386-go-package-exe

[email protected]
os: linux
cpu: x64
bin: /Users//go-package/dist/npm/dist-go-package-linux-amd-64-v-1-go-package

[email protected]
os: linux
cpu: arm64
bin: /Users//go-package/dist/npm/dist-go-package-linux-arm-64-go-package

[email protected]
os: win32
cpu: arm64
bin: /Users//go-package/dist/npm/dist-go-package-windows-arm-64-go-package-exe

[email protected]
os: win32
cpu: x64
bin: /Users//go-package/dist/npm/dist-go-package-windows-amd-64-v-1-go-package-exe

[email protected]
os: darwin
cpu: x64
bin: /Users//go-package/dist/npm/dist-go-package-darwin-amd-64-v-1-go-package

[email protected]
os: darwin
cpu: arm64
bin: /Users//go-package/dist/npm/dist-go-package-darwin-arm-64-go-package
```

## Supported platforms and architectures:

### Platforms:

| GOOS | Node.js Platform |
| ------- | ---------------- |
| darwin | darwin |
| linux | linux |
| windows | win32 |
| android | android |
| aix | aix |
| freebsd | freebsd |
| openbsd | openbsd |
| solaris | sunos |
| netbsd | netbsd |

### Architectures:

| GOARCH | Node.js Platform |
| ------- | ---------------- |
| amd64 | x64 |
| 386 | ia32 |
| arm | arm |
| arm64 | arm64 |
| s390x | s390x |
| s390 | s390 |
| riscv64 | riscv64 |
| ppc64 | ppc64 |
| ppc | ppc |
| mips | mips |