@d-dev/bin-upload-darwin-arm64 0.0.3 → 0.0.8

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