Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Releasing

How QuitLock releases are made, and how anyone can check one. The workflow is .github/workflows/release.yml.

What a release contains

FileWhat it is
quitlock-<version>.apkThe app, signed with the release key
quitlock-<version>-linux-x86_64The CLI for Linux (static, musl)
quitlock-<version>-windows-x86_64.exeThe CLI for Windows
SHA256SUMSSHA-256 of each file above, as sha256sum writes it

While the repository is public, each file also has a build provenance attestation on GitHub: a signed statement that the release workflow built it from the tagged commit. (GitHub does not offer these for private repositories on ordinary plans, so the workflow skips the step there.)

The release CLI carries the SHA-256 of the release signing certificate. quitlock provision uses it to refuse an APK that claims to be QuitLock but is signed by anyone else. A CLI built without it (any local build) provisions dev builds only.

Release certificate SHA-256: not yet made. It will be written here once the key exists, and it never changes after that.

Checking a release

From the least effort to the most:

  1. The download is intact. In the folder with the downloads and SHA256SUMS:
    sha256sum -c SHA256SUMS --ignore-missing
    
    This only catches damage on the way: whoever could replace a file could replace SHA256SUMS too.
  2. GitHub’s workflow built it from the tagged commit, with the GitHub CLI:
    gh attestation verify quitlock-<version>.apk --repo <owner>/<repo>
    
  3. The APK is signed with the release key. Compare the certificate hash above with:
    apksigner verify --print-certs quitlock-<version>.apk
    
    (apksigner comes with the Android SDK build tools.) quitlock provision does this check for you.
  4. The files match the source. Check out the release’s tag and rebuild:
    git checkout v<version>
    scripts/verify-release.sh quitlock-<version>.apk quitlock-<version>-linux-x86_64
    
    For the APK, it builds the unsigned release APK at the same version and compares every file inside the two. The signature sits outside those files (APK Signature Scheme v2 and v3; the old v1 scheme, which adds files, is turned off), so any difference is real. For the Linux CLI, it builds with the same Rust version, target and path remapping as the workflow, with the certificate hash from the APK compiled in, and compares the two binaries’ SHA-256. The script’s header lists what it needs.

How reproducible the builds are has been checked locally only, not yet against a CI build:

  • Two builds of the CLI from copies of the source in different directories, with the workflow’s path remapping, gave byte-identical binaries (x86_64 Linux, glibc target; no local paths left in the binary).
  • A release APK built in a fresh copy of the source at a different path had exactly the same files inside as one built in the working tree and then signed.
  • A different JDK or Android build tools version may change the APK. The workflow uses Temurin 21 and the newest build tools on the runner; use the same if a comparison fails.

Making the release key (once)

The release signing key never exists on a developer machine (Building). It is made on a system that is not one, put into the repository’s secrets, backed up offline, and the system is then shut down.

The package ID is fixed before the first release. It is dev.t342.quitlock (Decisions). Android treats a different package ID as a different app, so it cannot change once phones run a release. It is under the owner’s domain t342.dev, which must stay renewed.

  1. Boot a clean system that is not a developer machine: for example, a Linux live USB on a computer whose disks are not mounted. It needs a JDK (for keytool), gh, and network access only for the upload in step 3.

  2. Make the key:

    keytool -genkeypair -keystore quitlock-release.p12 -storetype PKCS12 \
        -alias quitlock -keyalg RSA -keysize 4096 -validity 18250 -dname "CN=QuitLock"
    

    Choose a long random password (openssl rand -base64 30, written on paper). With PKCS12, the key password is the same as the keystore password. The key is valid for 50 years: Android refuses to update an app with a different key, so this one has to last.

    The distinguished name is written into the certificate, which anyone can read from every release with apksigner verify --print-certs. Android does not check it, and it cannot change without a new key. CN=QuitLock is enough; leave out personal names, email addresses and places.

    The alias does not matter either: the workflow signs with the keystore’s only key, whatever it is called. A keystore with more than one key is refused.

  3. Read the certificate hash (it shows the alias too):

    keytool -list -v -keystore quitlock-release.p12
    

    It is the SHA256: line, in upper case with colons. The workflow wants it as 64 lower-case hex digits with no colons:

    keytool -list -v -keystore quitlock-release.p12 | sed -n 's/.*SHA256: //p' | tr -d : | tr A-F a-f
    

    The certificate hash is public. It is a repository variable, not a secret, so it shows in logs and can be published.

  4. Put it into the repository. The secrets belong in an environment named release, not in the repository’s own secrets: repository secrets can be read by a workflow run from any branch, environment secrets only by jobs that the environment allows, here version tags.

    • In the repository settings, create the environment release (Settings → Environments). Under deployment branches and tags, allow only tags matching v*. Optionally, add required reviewers.
    • Add a ruleset protecting tags v*, so only maintainers can push them.
    • A secret is text, and the keystore is a binary file, so it is stored in base64. Turn it into text first:
      base64 -w0 quitlock-release.p12 > keystore.txt
      
    • In the browser: in the release environment, add the environment secrets QUITLOCK_KEYSTORE (paste the whole of keystore.txt, one line), QUITLOCK_KEYSTORE_PASSWORD and QUITLOCK_KEY_PASSWORD (the same password). Under Settings → Secrets and variables → Actions → Variables, add the repository variable QUITLOCK_RELEASE_CERT_SHA256 with the hash from step 3.
    • Or with the GitHub CLI, which needs --repo on a system without a clone of the repository:
      gh auth login
      R=<owner>/<repo>
      gh secret set QUITLOCK_KEYSTORE --env release --repo $R < keystore.txt
      gh secret set QUITLOCK_KEYSTORE_PASSWORD --env release --repo $R   # prompts
      gh secret set QUITLOCK_KEY_PASSWORD --env release --repo $R        # the same password
      gh variable set QUITLOCK_RELEASE_CERT_SHA256 --repo $R --body <the 64 hex digits>
      
    • Delete keystore.txt: it is the key, only encoded.
  5. Back it up offline: the .p12 file on two encrypted USB drives kept in different places, and the password on paper with each. If this key is lost, phones running QuitLock can never be updated again. They would need an exit (which waits out the delay) and a fresh install of a new key’s build.

  6. Shut the system down. Nothing of the key may stay on it or be copied to another computer. To read the backup again later (for its hash or alias), use a live system again, not a developer machine.

  7. Write the certificate hash at the top of this page and in Installing, and commit that.

Making a release

  1. Check that main is green in CI.
  2. Tag the commit and push the tag. The version is MAJOR.MINOR.PATCH, each from 0 to 999. The app’s versionCode follows from it (1.2.3 becomes 1002003), and Android refuses to update to a lower one.
    git tag -s v0.1.0 -m "QuitLock 0.1.0"
    git push origin v0.1.0
    
  3. The workflow then:
    • runs the tests;
    • builds the release APK and checks that it is the release package, at that version, not test-only;
    • signs it, and checks the signature against QUITLOCK_RELEASE_CERT_SHA256;
    • builds the CLI for Linux and Windows with the hash compiled in;
    • writes SHA256SUMS, attests every file, and creates a draft release.
  4. Read the draft. Download the files and check them as in “Checking a release”, at least steps 1, 3 and 4.
  5. Publish it. Only then does quitlock update --github see it.

A tag that is not vMAJOR.MINOR.PATCH, or a repository without the variable or the secrets, fails in the first job, before anything is built or signed.