@d-dev/bin-upload-darwin-arm64 0.0.3 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +379 -8
- package/bin/bin-upload +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,386 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Bin Upload
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Easily distribute binaries via npm, pypi, and GitHub releases.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`bin-upload` is a CLI tool built with [Bun](https://bun.sh) that packages and publishes pre-built binaries to multiple registries and platforms. It supports:
|
|
8
|
+
|
|
9
|
+
- **npm** — Publishes a main package that depend on platform-specific binary packages using [optionalDependencies](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#optionaldependencies).
|
|
10
|
+
- **PyPI** — Builds wheel (`.whl`) packages for each platform-specific tag.
|
|
11
|
+
- **GitHub Releases** — Creates releases and uploads archive assets (`.tar.gz` or `.zip`).
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### From npm
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
# Globally
|
|
19
|
+
npm install -g @d-dev/bin-upload
|
|
20
|
+
# or as a package dep
|
|
21
|
+
npm install -D @d-dev/bin-upload
|
|
22
|
+
# or run with npx
|
|
23
|
+
npx @d-dev/bin-upload <command>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### From PyPI
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
pip install bin-upload
|
|
30
|
+
# or with UV
|
|
31
|
+
uv tool install bin-upload
|
|
32
|
+
# or run with uvx
|
|
33
|
+
uvx bin-upload <command>
|
|
7
34
|
```
|
|
8
35
|
|
|
9
|
-
|
|
36
|
+
### From GitHub Releases
|
|
37
|
+
|
|
38
|
+
Download the appropriate binary for your platform from the [releases page](https://github.com/dworthen/bin-upload/releases).
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
**Requirements**
|
|
43
|
+
|
|
44
|
+
The following must be installed and available on your path.
|
|
45
|
+
|
|
46
|
+
- [npm](https://www.npmjs.com/): if publishing to npm
|
|
47
|
+
- [uv](https://docs.astral.sh/uv/): if publishing to pypi
|
|
10
48
|
|
|
11
|
-
|
|
12
|
-
|
|
49
|
+
1. **Initialize a configuration file:**
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
bin-upload init
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This will walk you through an interactive prompt and generate a `bin-upload.config.yaml` file.
|
|
56
|
+
|
|
57
|
+
2. **Pack binaries into publishable artifacts:**
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
bin-upload pack
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This will generate artifacts that can be published to npm (tarballs), pypi (wheel), and GitHub (tarballs and zips).
|
|
64
|
+
|
|
65
|
+
3. **Publish the artifacts:**
|
|
66
|
+
|
|
67
|
+
```sh
|
|
68
|
+
bin-upload publish
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This publishes the artifacts generatd by the `pack` command.
|
|
72
|
+
|
|
73
|
+
## Commands
|
|
74
|
+
|
|
75
|
+
### `init`
|
|
76
|
+
|
|
77
|
+
Initialize a `bin-upload` configuration file via interactive prompts.
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
bin-upload init [options]
|
|
13
81
|
```
|
|
14
82
|
|
|
15
|
-
|
|
83
|
+
| Option | Description |
|
|
84
|
+
| -------------- | -------------------------------------- |
|
|
85
|
+
| `--help, -h` | Show help. |
|
|
86
|
+
| `--config, -c` | Path to output configuration file. |
|
|
87
|
+
| `--force, -f` | Overwrite existing configuration file. |
|
|
88
|
+
|
|
89
|
+
### `pack`
|
|
90
|
+
|
|
91
|
+
Build publishable artifacts (npm tarballs, PyPI wheels, GitHub archives) from your binaries.
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
bin-upload pack [options]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
| Option | Description |
|
|
98
|
+
| -------------- | ---------------------------------------------------------------------- |
|
|
99
|
+
| `--help, -h` | Show help. |
|
|
100
|
+
| `--config, -c` | Path to YAML configuration file. Default: `bin-upload.config.yaml`. |
|
|
101
|
+
| `--set, -s` | Set configuration values, e.g., `--set npm.packageJson.version=1.0.0`. |
|
|
102
|
+
| `--source` | Sources to pack: `all`, `npm`, `pypi`, `github`. Default: `all`. |
|
|
103
|
+
| `--verbose` | Enable verbose logging. |
|
|
104
|
+
|
|
105
|
+
### `publish`
|
|
106
|
+
|
|
107
|
+
Publish the packed artifacts to their respective registries.
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
bin-upload publish [options]
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
| Option | Description |
|
|
114
|
+
| -------------- | ---------------------------------------------------------------------- |
|
|
115
|
+
| `--help, -h` | Show help. |
|
|
116
|
+
| `--config, -c` | Path to YAML configuration file. Default: `bin-upload.config.yaml`. |
|
|
117
|
+
| `--set, -s` | Set configuration values, e.g., `--set pypi.publish.token=some-token`. |
|
|
118
|
+
| `--source` | Sources to publish: `all`, `npm`, `pypi`, `github`. Default: `all`. |
|
|
119
|
+
| `--verbose` | Enable verbose logging. |
|
|
120
|
+
|
|
121
|
+
## Configuration
|
|
122
|
+
|
|
123
|
+
The configuration file is a YAML file (default: `bin-upload.config.yaml`) that supports [Eta](https://eta.js.org/docs/4.x.x/intro/quickstart) templating with access to environment variables and built-in variables.
|
|
124
|
+
|
|
125
|
+
### Template Variables
|
|
126
|
+
|
|
127
|
+
- `env` — Access environment variables, e.g., `<%= env.NPM_TOKEN %>`.
|
|
128
|
+
- `vars.gitTag` — The latest semver git tag (without the `v` prefix), extracted from tags matching `v*.*.*`.
|
|
129
|
+
|
|
130
|
+
### Configuration Structure
|
|
131
|
+
|
|
132
|
+
```yaml
|
|
133
|
+
binaries:
|
|
134
|
+
# binaryId -> path to binary file
|
|
135
|
+
linux-x64: "./bin/linux-x64/my-binary"
|
|
136
|
+
darwin-arm64: "./bin/darwin-arm64/my-binary"
|
|
137
|
+
win-x64: "./bin/win-x64/my-binary.exe"
|
|
138
|
+
|
|
139
|
+
pack:
|
|
140
|
+
prePackCommand: "bun run build" # Optional command to run before packing
|
|
141
|
+
dir: "./dist" # Output directory for packed artifacts
|
|
142
|
+
|
|
143
|
+
npm:
|
|
144
|
+
readmeFile: "README.md"
|
|
145
|
+
licenseFile: "LICENSE"
|
|
146
|
+
packageJson:
|
|
147
|
+
name: "@scope/my-package"
|
|
148
|
+
version: <%= vars.gitTag %>
|
|
149
|
+
description: "My binary package"
|
|
150
|
+
license: "MIT"
|
|
151
|
+
binaryPackages:
|
|
152
|
+
# binaryId -> { name, os, arch } using Node.js process.platform/process.arch values
|
|
153
|
+
linux-x64:
|
|
154
|
+
name: "@scope/my-package-linux-x64"
|
|
155
|
+
os: "linux"
|
|
156
|
+
arch: "x64"
|
|
157
|
+
darwin-arm64:
|
|
158
|
+
name: "@scope/my-package-darwin-arm64"
|
|
159
|
+
os: "darwin"
|
|
160
|
+
arch: "arm64"
|
|
161
|
+
win-x64:
|
|
162
|
+
name: "@scope/my-package-win-x64"
|
|
163
|
+
os: "win32"
|
|
164
|
+
arch: "x64"
|
|
165
|
+
binNames:
|
|
166
|
+
- "my-binary" # Optional custom bin entry point names
|
|
167
|
+
publish:
|
|
168
|
+
access: "public"
|
|
169
|
+
tag: "latest"
|
|
170
|
+
# For publishing from local machine
|
|
171
|
+
# Should omit if publishing from GitHub actions
|
|
172
|
+
# using trusted publisher with npm
|
|
173
|
+
"registry=https://registry.npmjs.org/": true
|
|
174
|
+
"//registry.npmjs.org/:_authToken=<%= env.NPM_TOKEN %>": true
|
|
175
|
+
|
|
176
|
+
pypi:
|
|
177
|
+
readmeFile: "README.md"
|
|
178
|
+
platformTags:
|
|
179
|
+
# binaryId -> wheel platform tag
|
|
180
|
+
linux-x64: "manylinux_2_17_x86_64"
|
|
181
|
+
darwin-arm64: "macosx_11_0_arm64"
|
|
182
|
+
win-x64: "win_amd64"
|
|
183
|
+
metadata:
|
|
184
|
+
Name: "my-package"
|
|
185
|
+
Version: <%= vars.gitTag %>
|
|
186
|
+
Summary: "My binary package"
|
|
187
|
+
Requires-Python: ">=3.11"
|
|
188
|
+
entryPointNames:
|
|
189
|
+
- "my-binary" # Optional custom console_scripts entry points
|
|
190
|
+
publish:
|
|
191
|
+
# For publishing from local machine
|
|
192
|
+
# should omit if publishing from GitHub actions
|
|
193
|
+
# using trusted publisher with pypi
|
|
194
|
+
token: "<%= env.PYPI_TOKEN %>"
|
|
195
|
+
|
|
196
|
+
github:
|
|
197
|
+
owner: "my-org"
|
|
198
|
+
repo: "my-repo"
|
|
199
|
+
# Token should have the following repository level permissions
|
|
200
|
+
# Metadata read
|
|
201
|
+
# Contents read and write
|
|
202
|
+
token: "<%= env.GITHUB_TOKEN %>"
|
|
203
|
+
release:
|
|
204
|
+
tag_name: "v<%= vars.gitTag %>"
|
|
205
|
+
archives:
|
|
206
|
+
# Simple: binaryId -> format
|
|
207
|
+
linux-x64: "tar.gz"
|
|
208
|
+
win-x64: "zip"
|
|
209
|
+
# Advanced: custom archive with file globs
|
|
210
|
+
# source:
|
|
211
|
+
# format: "tar.gz"
|
|
212
|
+
# files:
|
|
213
|
+
# - cwd: "src"
|
|
214
|
+
# pattern: "**/*"
|
|
215
|
+
# - "README.md"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Setting Config Values via CLI
|
|
219
|
+
|
|
220
|
+
Use `--set` (`-s`) to override configuration values using dot notation:
|
|
221
|
+
|
|
222
|
+
```sh
|
|
223
|
+
bin-upload pack -s npm.packageJson.version=1.0.0 -s pypi.metadata.Version=1.0.0
|
|
224
|
+
bin-upload publish -s "pypi.publish.token=some-token"
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
This will create the following values in the yaml configuration.
|
|
228
|
+
|
|
229
|
+
```yaml
|
|
230
|
+
npm
|
|
231
|
+
packageJson
|
|
232
|
+
version: 1.0.0
|
|
233
|
+
|
|
234
|
+
pypi
|
|
235
|
+
metadata
|
|
236
|
+
Version: 1.0.0
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Escape dots and equals signs with backslashes when they are part of the key:
|
|
240
|
+
|
|
241
|
+
```sh
|
|
242
|
+
bin-upload publish -s "npm.publish.registry\=https://registry\.npmjs\.org/=true"
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
This will create the following values in the yaml configuration.
|
|
246
|
+
|
|
247
|
+
```yaml
|
|
248
|
+
npm
|
|
249
|
+
publish
|
|
250
|
+
"registry=https://registry.npmjs.org/": true
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## How it Works
|
|
254
|
+
|
|
255
|
+
### npm
|
|
256
|
+
|
|
257
|
+
The `pack` command generates:
|
|
258
|
+
|
|
259
|
+
- A **main package** that detects the user's platform (`process.platform` + `process.arch`) and delegates to the appropriate binary package.
|
|
260
|
+
- **Platform-specific packages** listed as `optionalDependencies` in the main package, each containing the binary for that platform.
|
|
261
|
+
|
|
262
|
+
Bin upload publishes a main npm package that depend on platform-specific binary packages using [optionalDependencies](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#optionaldependencies). When the main package is installed, the corresponding platform-specific package containing the actual binary is also installed. This allows for downloading and installing only the necessary binary without relying on post-install scripts, which some package managers do not run for dependencies.
|
|
263
|
+
|
|
264
|
+
> **Note:** musl Linux binaries cannot be distinguished from glibc Linux binaries via `process.platform`/`process.arch`, so they cannot be published to npm.
|
|
265
|
+
|
|
266
|
+
### PyPI
|
|
267
|
+
|
|
268
|
+
The `pack` command builds platform-specific wheel (`.whl`) files. Each wheel contains:
|
|
269
|
+
|
|
270
|
+
- A Python wrapper module that locates and executes the bundled binary.
|
|
271
|
+
- Console script entry points for CLI usage.
|
|
272
|
+
|
|
273
|
+
Bin upload builds and published wheel (`.whl`) packages for each platform-specific tag. Only one PyPi package is created containing the platform-specific wheel files (unlike npm where each binary is published to its own npm package). Tools such as `pip` and `uv` automatically install the correct wheel for the machine installing the package.
|
|
274
|
+
|
|
275
|
+
### GitHub Releases
|
|
276
|
+
|
|
277
|
+
The `pack` command creates `.tar.gz` or `.zip` archives. The `publish` command creates a GitHub release (if one doesn't exist for the tag) and uploads the archives as release assets.
|
|
278
|
+
|
|
279
|
+
### Publishing
|
|
280
|
+
|
|
281
|
+
The [npm](https://www.npmjs.com/) cli is used to publish to npm while [uv](https://docs.astral.sh/uv/) is used to publish to [PyPi](https://pypi.org/).
|
|
282
|
+
|
|
283
|
+
## Environment Variables
|
|
284
|
+
|
|
285
|
+
| Variable | Used By |
|
|
286
|
+
| -------------- | --------------------------- |
|
|
287
|
+
| `NPM_TOKEN` | npm publish authentication |
|
|
288
|
+
| `PYPI_TOKEN` | PyPI publish authentication |
|
|
289
|
+
| `GITHUB_TOKEN` | GitHub API authentication |
|
|
290
|
+
|
|
291
|
+
These can be set in a `.env` file or your CI environment. When using trusted publishers (e.g., GitHub Actions OIDC), tokens may not be required.
|
|
292
|
+
|
|
293
|
+
## Publishing
|
|
294
|
+
|
|
295
|
+
One of the variables available for reference in the configuration file is `gitTag`, a reference to the latest git tag on the current git branch that matches `v\d+\.\d+\.\d+` (the variable is without the leading `v`). Referencing this variable in the configuration allows for git-based release process and bypasses the need to manually update version numbers when releasing.
|
|
296
|
+
|
|
297
|
+
### Local git-based Release Flow
|
|
298
|
+
|
|
299
|
+
```sh
|
|
300
|
+
git add .
|
|
301
|
+
git commit -m "..."
|
|
302
|
+
git tag -a v1.0.0 -m "Release v1.0.0"
|
|
303
|
+
# The tag needs to exist in the remote
|
|
304
|
+
# in order for bin-upload to create a release
|
|
305
|
+
# for the tag and upload assets
|
|
306
|
+
git push --follow-tags
|
|
307
|
+
bin-upload pack
|
|
308
|
+
bin-upload publish
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Publishing with GitHub actions
|
|
312
|
+
|
|
313
|
+
The following GitHub action will publish the binary artifacts whenever a version tag is pushed to the repo. You will need to establish trusted publishing between the GitHub repo and npm and/or pypi if publishing to those locations.
|
|
314
|
+
|
|
315
|
+
```yaml
|
|
316
|
+
# .github/workflows/relesae.yml
|
|
317
|
+
name: Release
|
|
318
|
+
|
|
319
|
+
on:
|
|
320
|
+
push:
|
|
321
|
+
tags:
|
|
322
|
+
- "v*"
|
|
323
|
+
|
|
324
|
+
permissions:
|
|
325
|
+
contents: write
|
|
326
|
+
id-token: write
|
|
327
|
+
|
|
328
|
+
jobs:
|
|
329
|
+
release:
|
|
330
|
+
runs-on: ubuntu-latest
|
|
331
|
+
steps:
|
|
332
|
+
- uses: actions/checkout@v4
|
|
333
|
+
|
|
334
|
+
- uses: actions/setup-node@v4
|
|
335
|
+
with:
|
|
336
|
+
node-version: "24"
|
|
337
|
+
registry-url: "https://registry.npmjs.org"
|
|
338
|
+
|
|
339
|
+
- name: Install uv
|
|
340
|
+
uses: astral-sh/setup-uv@v7
|
|
341
|
+
|
|
342
|
+
- name: Build binaries
|
|
343
|
+
run: COMMAND TO BUILD YOUR BINARIES
|
|
344
|
+
|
|
345
|
+
- name: Pack
|
|
346
|
+
run: uvx bin-upload pack
|
|
347
|
+
|
|
348
|
+
- name: Publish
|
|
349
|
+
run: uvx bin-upload publish
|
|
350
|
+
env:
|
|
351
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
With the above GitHub action, you no longer need to set auth or tokens in the `npm.publish` and `pypi.publish` sections. You still need to reference the `GITHUB_TOKEN` in the `github` portion of the config.
|
|
355
|
+
|
|
356
|
+
From here, the release process is similar to releasing from local machine
|
|
357
|
+
|
|
358
|
+
```sh
|
|
359
|
+
git add .
|
|
360
|
+
git commit -m "..."
|
|
361
|
+
git tag -a v1.0.0 -m "Release v1.0.0"
|
|
362
|
+
git push --follow-tags
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## Development
|
|
366
|
+
|
|
367
|
+
This project uses [Bun](https://bun.sh) as its runtime and build tool.
|
|
368
|
+
|
|
369
|
+
```sh
|
|
370
|
+
# Install dependencies
|
|
371
|
+
bun install
|
|
372
|
+
|
|
373
|
+
# Build binaries for all platforms
|
|
374
|
+
bun run build
|
|
375
|
+
|
|
376
|
+
# Build for a specific target
|
|
377
|
+
bun run ./scripts/build.ts bun-darwin-arm64
|
|
378
|
+
|
|
379
|
+
# Lint and format
|
|
380
|
+
bun run check
|
|
381
|
+
bun run fix
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
## License
|
|
385
|
+
|
|
386
|
+
[MIT](LICENSE) — Copyright (c) Derek Worthen
|
package/bin/bin-upload
CHANGED
|
Binary file
|