Using Moru
Releases
A release gives a tag a title, notes and files to download. It starts as a draft, and each file is pinned by its SHA-256 in a signed record in the repository.
A release is what people download for a version: a tag, with a title, notes written in Markdown, and files such as archives, installers and checksum lists. A tag has at most one release.
A release has two parts:
- The record is in the repository, signed like every change, request and comment: the tag, the commit it pointed at, the title, the notes, who published it, and each file’s name, size and SHA-256. It travels with the repository when it’s imported or moved.
- The files are on the repository’s node, outside git. The node works out a file’s SHA-256 as it’s uploaded, keeps the file under that hash, and only ever serves it as the file a record names by it.
Create a release#
The tag has to exist first. Push it as usual:
git tag -a v0.2.0 -m "0.2.0"
git push origin v0.2.0 Then, with write access, any of:
- open the Releases page (Releases on the Code tab, or
gthenl), click Create release and pick the tag, - open the Tags page (the tag count on the Code tab) and click Create release beside the tag, or
- browse the code at the tag (pick it in the branch menu on the Code tab) and click Create release in the bar above the files.
In the form:
- Give it a title. Left empty, it’s the tag’s name.
- Write the notes in Markdown. Preview shows them as they’ll appear.
- Tick Pre-release for a version that isn’t ready for everyone, such as a release candidate.
- Pick the files. They upload one after another, each with its own progress.
- Click Save draft to keep working on it later, or Publish.
The Code tab shows how many releases there are, and the latest one, beside the tag count. A tag that has a release links to it, on the Tags page and in the bar above its files.
Drafts#
A release starts as a draft. Only people with write access see a draft, on the Releases page and under its own address, and only they can download its files. Everyone else gets “not found”. So a release with many files can be put together, checked and then published in one step, and nobody downloads half of it.
While it’s a draft you can change everything: the title, the notes, the pre-release flag, and the files. Uploading a file under a name the draft already has replaces it, and a file can be removed.
Publish ends the draft. A published release can’t go back to being one.
After publication#
Once a release is published:
| You can | You can’t |
|---|---|
| Change the title, the notes and the pre-release flag | Replace a file |
| Add files | Remove a file |
| Turn it back into a draft |
A file’s name in a published release always means the same bytes, so a checksum someone copied from the page stays true. Uploading the same bytes again under the same name changes nothing; other bytes under that name are refused.
To fix a published file, an admin of the repository deletes the release, and it’s made again with the right files. Both the old release and the new one stay in the repository’s signed history.
Files and checksums#
A file’s name is made of letters, digits and ., _, +, -. It can’t start with a
dot, is at most 255 bytes long, and is unique in its release whatever the case: App.zip and app.zip can’t both be there.
A release’s page shows each file’s size and its SHA-256, with a button that copies the hash. To check a download against it:
sha256sum timetable-linux-x64.tar.gz # Linux
shasum -a 256 timetable-linux-x64.tar.gz # macOS The output must start with the hash the page shows. The hash is part of the signed record, so it also holds for a copy of the file you got from somewhere else.
Download URLs#
Every file has an address that doesn’t change:
https://<node>/r/<owner>/<name>/releases/download/<tag>/<file> And one that always leads to that file of the latest release:
https://<node>/r/<owner>/<name>/releases/latest/download/<file> The latest release is the newest published release that isn’t a pre-release, by
when it was published. The Releases page marks it Latest. The second address
redirects to the first, so tell curl to follow redirects with -L:
curl -LO https://moru.example.com/r/acme/timetable/releases/latest/download/timetable-linux-x64.tar.gz A download that broke can pick up where it stopped. With curl, add -C -:
curl -L -C - -O https://moru.example.com/r/acme/timetable/releases/download/v0.2.0/timetable-linux-x64.tar.gz Files of a public repository need no sign-in. For a private one, the browser uses your session, and a script sends a token:
curl -LO https://moru.example.com/r/acme/timetable/releases/download/v0.2.0/timetable-linux-x64.tar.gz \
-H "Authorization: Bearer $MORU_TOKEN" Files are always sent as downloads, never shown in the browser.
A tag that moved or was deleted#
A release remembers the commit its tag pointed at when the release was created. If someone later moves the tag to another commit, or deletes it, the release stays, with its files, and its page says that the tag moved or is gone. The files are the ones that were uploaded; nothing is rebuilt from the tag.
A new release can only be created for a tag that exists.
Limits#
| Limit | Value |
|---|---|
| One file | 1 GiB |
| Files in one release | 200 |
| All release files of one repository together | 10 GiB, unless the node says otherwise |
A file that several releases of a repository share, such as the same install script in each, is stored and counted once.
The node’s admin sets the repository limit, and can turn releases off for the whole
node: see MORU_RELEASE_QUOTA in Configuration. With
releases off, existing releases can still be read and downloaded, and nothing can be
created, changed or uploaded. An upload is also refused while the node’s disk is nearly
full.
Uploads don’t resume: one that breaks starts over.
Who can do what#
| Role | Can |
|---|---|
| Read | See published releases and download their files. On a public repository that’s anyone, signed in or not |
| Write | See drafts; create and edit releases, upload files, publish, and delete a draft |
| Admin | Delete a published release |
See Organizations and access for the roles.
From a script#
Everything the form does is in the REST API. With a
token in MORU_TOKEN, this creates a draft for the tag v0.2.0, uploads a file and
publishes:
REPO=https://moru.example.com/api/v0/repos/acme/timetable
curl -sS -X PUT $REPO/releases/v0.2.0 \
-H "Authorization: Bearer $MORU_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"title": "0.2.0", "notes": "Shows the next departure first."}'
curl -sS --upload-file dist/timetable-linux-x64.tar.gz \
$REPO/release-files/v0.2.0/timetable-linux-x64.tar.gz \
-H "Authorization: Bearer $MORU_TOKEN"
curl -sS -X PUT $REPO/releases/v0.2.0 \
-H "Authorization: Bearer $MORU_TOKEN" \
-H 'Content-Type: application/json' \
-d '{"draft": false}' The API page has the other calls and what each answers.
Webhooks send release.published, release.updated and release.deleted. Drafts send nothing.
From CI#
A CI job can publish the release of the tag it runs on, without a token of yours. The
job asks for releases: write in a workflow in .moru/workflows/, and the node gives it
a token that lasts as long as the job and writes only that tag’s release:
on:
push:
tags: ['v*']
jobs:
release:
permissions:
releases: write
steps:
- run: make dist
- name: Publish the release
run: |
tag="${MORU_REF#refs/tags/}"
api="$MORU_URL/api/v0/repos/$MORU_REPO"
auth="Authorization: Bearer $MORU_TOKEN"
curl -fsS -X PUT -H "$auth" -H 'Content-Type: application/json' \
-d '{"draft": true}' "$api/releases/$tag"
curl -fsS -X PUT -H "$auth" --data-binary @dist/app.tar.gz \
"$api/release-files/$tag/app.tar.gz"
curl -fsS -X PUT -H "$auth" -H 'Content-Type: application/json' \
-d '{"draft": false}' "$api/releases/$tag" Push the tag, and the job creates a draft, uploads the file and publishes. curl must
be on the runner. The release shows the person who pushed the tag as its author, and
links to the CI run it came from.
Only push and manual runs of a tag get a token that writes a release, and the person the run is for needs write access. The token can’t delete a published release. See A token for the job.
Where the files are kept#
Release files are on the repository’s node, and unlike CI artifacts nothing can rebuild them, so every copy of the node’s data has them:
- Backups include them. See Backups.
- A move to another node of the same host takes them along.
- The bucket, on a node that mirrors itself to one, gets each file, encrypted when the repository is private. See Object storage.
- Deleting the repository puts them in the trash with it. Bringing the repository back within 7 days brings its releases back too.
A file no release names any more, because its release was deleted or a draft dropped it, is removed from the node’s disk a day later.
A copy of the repository on another host, such as an import or a mirror, has the releases’ records but not their files. There, each release shows with its notes and checksums, and its files are marked “not on this node”. Download them from the node that holds them, and check them against the SHA-256 shown.