Attach ./bin and ./assets to a release
`release` now uploads every file in the project's ./bin and ./assets when
those directories exist. Nothing to configure, and nothing happens for a
project that has neither.
This is the part deliberately left out when `release` was written,
because it is where the three providers stop resembling each other:
Gitea multipart POST to .../releases/<id>/assets?name=<name>
GitHub raw POST to the separate upload host the release object names
in upload_url, whose RFC 6570 template suffix has to go first
GitLab a release stores links, not files: the file goes into the
project's generic package registry and the release gets a
package link pointing at it
So findRelease and createRelease now return a releaseRef carrying the id
and, for GitHub, that upload host -- the id alone cannot address an
upload. Uploads stream from disk rather than buffering: these are whole
binaries, and the Gitea multipart body is assembled through a pipe.
Only regular files directly in those directories are taken. Symlinks are
skipped, which matters here: build.sh leaves bin/mgsh pointing at one of
its siblings, and uploading the same 9M twice under two names helps
nobody. A name present in both directories is used from bin and reported
for assets. Re-releasing a tag replaces same-named assets rather than
failing on them, since rebuilding and publishing again is the normal
reason to do it, and a file that fails does not stop the rest.
Each provider's request shape is pinned down against the recording
stand-in, and the whole chain was run once end to end -- real repository,
real binaries, a fake Gitea that also serves git-http-backend so the tag
push is real too.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -392,11 +392,43 @@ on different servers. `release` also refuses when the repository is not on the
|
||||
mirror yet and tells you to run `pushremote` first, rather than creating it as a
|
||||
side effect.
|
||||
|
||||
**No binary assets.** The three providers handle uploads in three incompatible
|
||||
ways — Gitea attaches them to the release, GitHub uses a separate upload host,
|
||||
and GitLab does not host them at all but expects a link into its package
|
||||
registry. mgsh publishes source releases with notes; if you need binaries,
|
||||
upload them with the provider's own tooling.
|
||||
#### Binaries and assets
|
||||
|
||||
If the project has a `./bin` or `./assets` directory, every file in it is
|
||||
attached to the release — nothing to configure, and nothing happens for a
|
||||
project that has neither:
|
||||
|
||||
```
|
||||
< src/mgsh > release v4.1.0
|
||||
attaching 5 assets, 38M from ./bin and ./assets
|
||||
remote gitea released https://git.example.com/mike/mgsh.git
|
||||
uploading logo.png 2.0K
|
||||
uploading mgsh-darwin-amd64 9.8M
|
||||
uploading mgsh-darwin-arm64 9.2M
|
||||
uploading mgsh-linux-amd64 9.7M
|
||||
uploading mgsh-linux-arm64 8.9M
|
||||
```
|
||||
|
||||
Only regular files directly in those directories are taken: subdirectories are
|
||||
not descended into, and symlinks are skipped — `bin/mgsh` points at one of its
|
||||
own siblings, and uploading the same binary twice under two names helps nobody.
|
||||
A name present in both directories is used from `bin` and reported for
|
||||
`assets`, since one asset name can only mean one file.
|
||||
|
||||
Re-releasing the same tag replaces same-named assets instead of failing or
|
||||
piling up duplicates, because rebuilding and publishing again is the normal
|
||||
reason to do it. A file that fails to upload does not stop the rest.
|
||||
|
||||
This is where the providers stop resembling each other, and mgsh papers over it:
|
||||
|
||||
| | how the bytes get there |
|
||||
|---|---|
|
||||
| Gitea | multipart `POST` to `…/releases/<id>/assets?name=<name>` |
|
||||
| GitHub | raw `POST` to the separate upload host named by the release's `upload_url` |
|
||||
| GitLab | a release stores links, not files: the file goes into the project's generic **package registry** and the release gets a `package` link pointing at it |
|
||||
|
||||
The GitLab route needs the package registry enabled on the project — it is on by
|
||||
default, but a self-hosted instance can turn it off.
|
||||
|
||||
## Configuration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user