Skip to content

Latest commit

 

History

History
216 lines (140 loc) · 16.4 KB

PUBLISHING.md

File metadata and controls

216 lines (140 loc) · 16.4 KB

Publishing a release

Put changes on GitHub, publish a release of the server, and look after the key that signs it. This is for the project's owner and developers, and isn't in the app's help.

Releases are signed only with SIGN=1, and only by the owner. Nobody else signs with the release key, and no test build ever does: for a signing test, make a throwaway key. Nothing leaves the development machine, and nothing is pushed or tagged, until the owner says so.

Modules are signed with a key of their own: see The module key.

Words you'll see: a commit is a saved snapshot of your changes, push uploads commits, a branch is a separate line of work, and a release is a downloadable version on GitHub's Releases page.

Putting changes on GitHub

With GitHub Desktop:

  1. Install GitHub Desktop and sign in.
  2. Choose File, then Add local repository, and pick the WittyMediaServer folder.
  3. Write a summary at the bottom left, and click Commit.
  4. Click Push origin at the top.

On the command line, inside the folder:

git status                     # see what changed
git add -A                     # stage everything: .gitignore keeps build output out
git commit -m "What changed"
git push origin master

The first push asks you to sign in: choose Sign in with your browser.

Never commit disc images, media, API keys or a data folder. Run the checks in CONTRIBUTING.md before pushing. GitHub runs them too, in the Actions tab.

Publishing a release

Before it, a soak run of at least 4 hours on Linux, and on Windows when a machine can be spared: Soak runs. It has to pass, or what it found has an issue.

  1. Run scripts/bump-server.sh <version>, and write the CHANGELOG.md section. The release page opens with what to download and where WittyMediaClient is, from body in .github/workflows/release.yml: keep what it says has been run the same as the README's.

  2. Release it with the Release workflow. Nobody pushes a version tag by hand: the repository refuses one from any computer, and nobody can move or delete one (Version tags). In the Actions tab choose Release, then Run workflow, with the version (without the v) and the branch. Or:

    gh workflow run tag.yml -R wittywilla/WittyMediaServer -f version=0.8.0-alpha -f branch=v0.8.0-alpha

    It checks that the version files say that version and that every check on the commit passed, then makes the tag, which starts the release. Tick dry_run to check without making it.

  3. Watch the Actions tab. .github/workflows/release.yml builds everything, stops at the release environment for the owner's approval if it requires one, signs the checksum list, and publishes.

  4. Check the Releases page lists the archives for all ten platforms, the installers (Windows .msi, macOS .pkg, Linux .deb, .rpm, .AppImage, .flatpak and .snap, FreeBSD .pkg), SHA256SUMS.txt and SHA256SUMS.txt.sig.

  5. Give the release a short summary. Installed servers show it as the notes under Settings → About.

A tag with a suffix such as -alpha is published as a pre-release, and its Docker image is tagged alpha. Only a tag with no suffix moves latest.

The tracking issue. Making a release branch (v0.8.0-alpha), or starting the release tracking workflow by hand with a version, opens an issue called "Release tracking", labelled release, with the checklist in .github/release-checklist.md. Starting it again brings the issue up to date and keeps its ticks. Once the release is published, the workflow ticks every line whose files the release has, says in a comment what's left, and closes the issue when nothing is. scripts/release-tracking.sh does the same from your own computer, and DRY_RUN=1 only says what it would do.

To retry, fix what failed and run the release workflow again on the same tag from the Actions tab (Re-run jobs). A tag can't be moved or deleted, and a published version number is never used again: if the fix needs a new commit, release the next version.

The website, after a release

wittymediaserver.com lists the newest server, client, player and reader, and the modules in the catalogue. Its build runs on a schedule, but GitHub can start scheduled builds hours late, so a published release, or a published catalogue, starts the site's build itself. For that, each of those repositories needs the same secret, made once:

  1. On github.com, click your picture, then Settings, Developer settings, Personal access tokens and Fine-grained tokens. Click Generate new token.
  2. Name it Website rebuild. Under Repository access, choose Only select repositories and pick wittywilla/WittyMediaServer.com. Under Permissions, set Actions to Read and write, and leave everything else as it is. Click Generate token and copy it.
  3. In wittywilla/WittyMediaServer, open Settings, Secrets and variables, Actions, and click New repository secret. Name it SITE_BUILD_TOKEN, paste the token, and click Add secret.
  4. Do the same, with the same token, in wittywilla/WittyMediaClient, wittywilla/WittyMediaPlayer, wittywilla/WittyReader and wittywilla/WittyModuleCatalog. The modules don't need it: their new versions reach the site through the catalogue.

The token can only start the website's builds, nothing else. GitHub makes you pick an expiry date; when you make a new token, replace the secret in all five repositories. Without it, or once it has expired, a release still publishes: its website job says so, and the site catches up on its own schedule. To rebuild the site now, open Actions in wittywilla/WittyMediaServer.com, then Build and publish, Run workflow.

Version tags

A version tag (v0.8.0-alpha, v0.4.0, and a Go module folder's wittydvdplayer/v0.3.0) starts a release, and Go's module proxy keeps every version it has seen for ever. So in every repository that releases:

  • Only the Release workflow makes one (.github/workflows/tag.yml, from WittyModule's kit for the modules). It pushes the tag with a deploy key kept in the repository's tag environment, and the rules let nothing else create one: a git push origin v9.9.9 from any computer, the owner's included, is refused.
  • Nobody moves or deletes one, the owner included: there's no exception.

scripts/set-tag-rules.sh sets this up (the tag environment, its deploy key, the two rulesets) for every repository, and scripts/set-tag-rules.sh --check says what each has. scripts/publish-all.sh --apply asks each repository's Release workflow for its tags.

Signing releases

Installed servers update themselves from Settings, but only to a release whose checksum list has a valid signature from the release key. Its public half is built into every server, in internal/update/keys.go. Whoever has the private half can make updates that every installed server accepts. Lose it, and installed servers can't update themselves any more.

The key was made once, with go run ./scripts/sign keygen, and is at ~/.wms-signing/release.key on the owner's computer. .gitignore refuses *.key files, but still never copy it into the project folder.

Looking after the key

  1. Back it up now. Copy release.key to a password manager, or a USB stick kept somewhere safe. Never email it, or put it in a chat or a shared cloud folder.
  2. Let GitHub sign releases. On github.com, open Settings, then Environments, then New environment, and name it release. Tick Required reviewers and add yourself. Under Environment secrets, add WMS_SIGNING_KEY, with all of release.key as its value. Delete any repository secret of that name. A tag then waits for your approval before it's signed.
  3. Protect tags. Run scripts/set-tag-rules.sh once: see Version tags.

Without the secret, a release comes out unsigned, and servers can't update to it from Settings.

Signing on your own computer

scripts/build-release.sh doesn't sign unless you ask. Only for a real release:

SIGN=1 scripts/build-release.sh 0.8.0-alpha

It uses ~/.wms-signing/release.key, or the file in WMS_SIGNING_KEY, and checks the signature against the key built into the server. With SIGN=1, a missing key warns, and REQUIRE_SIGNING=1 makes that an error.

If a release came out unsigned

Download its SHA256SUMS.txt, sign it, and upload the .sig to the same release:

go run ./scripts/sign sign wittymediaserver-0.8.0-alpha-SHA256SUMS.txt
go run ./scripts/sign verify wittymediaserver-0.8.0-alpha-SHA256SUMS.txt   # "good signature"

If a release has to be taken back

  1. Write wittymediaserver-withdrawn.json, raising serial each time:

    {"module":"wittymediaserver","serial":1,"versions":[{"version":"0.6.0-alpha","severity":"security","reason":"What's wrong."}]}
  2. Sign it with go run ./scripts/sign sign.

  3. Attach both files to a release tagged withdrawals.

Servers stop offering that version, and one already running it says so under Settings → About. A server keeps the highest serial it has seen, so hiding or replaying the list changes nothing. Deleting a release from GitHub isn't enough, as a server that has already seen it can still be offered it.

If the key is exposed or lost

  • Exposed: make a new one with go run ./scripts/sign keygen -key new.key, and add its public key to trustedKeys in internal/update/verify.go, beside the old one. Publish a release signed with the old key, so installed servers learn the new one. Sign later releases with the new key, and remove the old public key a release after that. Replace the WMS_SIGNING_KEY secret straight away.
  • Lost, with nothing exposed: servers can't update themselves any more, as nothing else can sign a release they'll accept. Add a new key the same way, and announce that the next release has to be installed by hand, once.

The module key

Modules and the module catalogue are signed with a second key, the module key, kept apart from the release key. A module key can't sign a server, so losing it can't put a bad server on anyone's machine. Its public half is moduleKey in internal/update/keys.go, and the private half is at ~/.wms-signing/module.key on the owner's computer.

To make one, on another machine or to replace it, run the command below and put the public half it prints in keys.go. It refuses to replace a file that's already there, won't put the key inside this repository, and never opens your existing key.

scripts/new-module-key.sh ~/.wms-signing/module.key

Back it up the same way as the release key: a password manager, or a USB stick kept somewhere safe.

Give the repositories the key, with approval, and check it's there. The second command lists names only, and never prints the key:

scripts/set-module-secret.sh --require-approval ~/.wms-signing/module.key
scripts/set-module-secret.sh --check

A module's release then stops before it's signed, and waits for you to click Approve on its page in the Actions tab. Every module shares the one key, so this approval is what stops a compromised build in one repository getting a release of another signed.

The catalogue also needs the public half, as the variable MODULE_PUBLIC_KEY in WittyModuleCatalog.

To release a module, run its Release workflow, approve the release environment on the run it starts, then run the catalogue's refresh.yml and approve its publish run:

gh workflow run tag.yml -R wittywilla/<Repository> -f version=<x.y.z> -f branch=main

scripts/publish-all.sh rehearses a release of every repository at once, in throwaway clones, and changes nothing on GitHub unless given --apply.

  • Module key lost: make a new one, set it in keys.go, and publish a server release. Older servers can't take new module versions until they update, and keep working with what they have.
  • Module key stolen: the same, and replace the secret in every repository straight away.

Versions. wittymodule bump [-part minor] [-note text] [-changelog CHANGELOG.md] <folder> raises a module's version everywhere it's written, and each module's CI runs wittymodule needs-bump ., which fails when code changed since the last tag and the version didn't. scripts/bump-server.sh <version> does the same for the server. A bump isn't a release.

Building on your own computer

The same script the workflow uses runs locally, from Git Bash on Windows, or as scripts\build-release.ps1. It's unsigned. Build into a folder of your own, and never over one that may be running.

DIST=dist/mine scripts/build-release.sh 0.6.0-alpha                                # all ten platforms
DIST=dist/mine scripts/build-release.sh 0.6.0-alpha windows/amd64 linux/arm64      # just some

On a computer that isn't a Mac, the macOS archives have no menu-bar app, as it needs a Mac to compile, and their apps aren't signed. Unsigned, macOS's Local Network privacy keeps the server off the network: run packaging/macos/sign-app.sh <folder> on a Mac, as the release does. The FreeBSD archives use FreeBSD's own FFmpeg unless you give them a static build, from scripts/build-ffmpeg-static.sh.

Each installer is made from a folder that script built. scripts/test/README.md says what proves each works.

packaging/linux/build-packages.sh 0.6.0-alpha dist/mine/wittymediaserver-0.6.0-alpha-linux-amd64 amd64   # .deb and .rpm, needs nfpm
packaging/linux/appimage/build-appimage.sh 0.6.0-alpha dist/mine/wittymediaserver-0.6.0-alpha-linux-amd64 amd64   # .AppImage, on Linux; downloads appimagetool
packaging/linux/flatpak/build-flatpak.sh 0.6.0-alpha dist/mine/wittymediaserver-0.6.0-alpha-linux-amd64 amd64     # .flatpak, needs flatpak-builder
packaging/linux/snap/build-snap.sh 0.6.0-alpha dist/mine/wittymediaserver-0.6.0-alpha-linux-amd64 amd64           # .snap, needs snapcraft
packaging/linux/make-repository.sh dist/mine out                                                         # an apt and dnf repository
packaging/macos/build-pkg.sh 0.6.0-alpha dist/mine/wittymediaserver-0.6.0-alpha-darwin-arm64 arm64       # .pkg, on a Mac
packaging/freebsd/build-pkg.sh 0.6.0-alpha dist/mine/wittymediaserver-0.6.0-alpha-freebsd-amd64 amd64    # .pkg, on FreeBSD

The AppImage, the Flatpak and the snap are for amd64 and arm64, and are made in the installers-linux job. None of the three has been built or run, here or on GitHub: the first run of build.yml with them in is their first build. They are in the signed checksum list like every other file, and nothing puts them on Flathub or in the Snap Store. appimagetool and the AppImage runtime are pinned by hash in packaging/linux/appimage/tools.lock. The server doesn't yet know these three kinds by name (internal/layout), so an installed one refuses Update now, which is right, but may offer the .tar.gz as its installer.

packaging\windows\build-msi.ps1 -Version 0.6.0-alpha -PackageDir dist\mine\wittymediaserver-0.6.0-alpha-windows-amd64 -Arch amd64

Signing the programs, so nothing warns people

This is a separate thing from the release key. Without these, Windows says "Windows protected your PC", and a Mac refuses the installer until it's right-clicked. Everything works without them. Prices are from memory, so check before buying.

What it costs What you do
Windows A code-signing certificate, about US$200 to $400 a year. Azure Trusted Signing, about US$10 a month, where you qualify. Or SignPath Foundation, free for open source, if accepted Add the signing step to the installers-windows job in release.yml, on the programs before the MSI is built and on the MSI after
macOS Apple Developer Program, US$99 a year Make the Developer ID Application and Developer ID Installer certificates and a notary profile, then set APPLE_APP_IDENTITY, APPLE_INSTALLER_IDENTITY and APPLE_NOTARY_PROFILE for packaging/macos/build-pkg.sh
apt and dnf repositories Free, plus somewhere to host them. None is hosted yet Make a GPG key, keep it as carefully as the release key, and give its id to packaging/linux/make-repository.sh

The WiX Toolset that builds the MSI is free for this project. Its maintenance fee applies to organisations earning over US$10,000 a year.


WittyMediaServer documentation