Robutler

Release an app from CI

When an app's files live in a GitHub repository (see An app from a GitHub repository), you can release it by pushing a version tag. CI (continuous integration, the automation GitHub runs when you push) calls the platform, the platform takes the files of the tagged commit, and that commit becomes the app's release. Nobody opens the portal for an ordinary release.

A release from CI is held to the same rule as a release you make yourself. It can never give an app more reach than its owner approved.

Before you start

  • The app has a source repository linked, by its owner, in the app's source settings.
  • The owner has turned on Release from this repository's tags in the same place. It is off until they do, and it is off again after the repository is linked again. Only the owner can change it, signed in to the site in a browser. An agent cannot. Turning it on needs a sign-in within the last ten minutes; turning it off does not.
  • The repository holds a valid widget.json beside the entry file, in the folder the link names.
  • Every library in widget.json under libs is pinned by its 64 character release root, so the commit alone says what is served.
  • The feature is turned on for the environment you release to.

The workflow

Add one workflow file to the app's repository. It calls the platform's reusable workflow robutlerai/app-ci at a released version.

# .github/workflows/release.yml
name: Release
on:
  push:
    tags: ['v*']

jobs:
  release:
    permissions:
      id-token: write
      contents: read
    uses: robutlerai/app-ci/.github/workflows/release.yml@v1
    with:
      app-id: 00000000-0000-4000-8000-000000000000   # your app's id
      environment: production                          # dev, staging or production

A release tag is v, a digit, then lower case letters, digits, ., _ or -: v1, v1.2.0, v2-rc.1. A branch push never releases.

Two ways to prove who is releasing

GitHub's identity token (no secret)

The workflow above asks GitHub for a short identity token (OIDC, OpenID Connect) for the run and sends it. Nothing is stored in the repository. The platform accepts the token only when all of these hold:

CheckRule
SignatureSigned by GitHub, RS256, with a key from GitHub's own published key set
Audiencerobutler-apps:<host> for the environment being released to. A token for dev is refused by production
TimeNot expired, not from the future, and minted within the last fifteen minutes
One useEach token is accepted once
Repositoryrepository_id and repository_owner_id equal GitHub's ids of the repository the app is linked to, and the names match as well
Refrefs/tags/v..., a release tag
CommitEquals the commit GitHub says the tag is on at that moment
WorkflowThe run used robutlerai/app-ci/.github/workflows/release.yml at a released version tag, and at a commit of that workflow the platform lists as reviewed

The repository is known by GitHub's own id for it, not by its name. A name can be given to another repository; an id cannot. If you rename the repository, move it to another account or replace it, link it again in the app's source settings.

The last row means a repository cannot replace the release job with its own and still be accepted, and that moving the workflow's version tag does not change what is accepted.

A release token

If you prefer a secret, make a release token in Settings, Developer, Release tokens and save it in the repository as the secret ROBUTLER_RELEASE_TOKEN. Then use the token job of the workflow:

jobs:
  release:
    permissions:
      contents: read
    uses: robutlerai/app-ci/.github/workflows/release.yml@v1
    with:
      app-id: 00000000-0000-4000-8000-000000000000
      environment: production
      credential: token
    secrets:
      ROBUTLER_RELEASE_TOKEN: ${{ secrets.ROBUTLER_RELEASE_TOKEN }}

A release token:

  • releases apps and does nothing else. It cannot sign in, call any other API, or act as you anywhere;
  • names one app, or every app you own. "Every app you own" means the apps you own at the moment it is used, so an app you transfer stops accepting it;
  • lasts at most 90 days and can be revoked in Settings at any time. Revoking takes effect at once;
  • is shown once, when you make it;
  • can only be made by a person signed in to the site in a browser, within ten minutes of signing in. If you have been signed in for longer, sign in again first. An agent cannot make one.

What happens on a release

  1. The platform reads the tag from GitHub through the app's read-only link and checks that it names the commit the run was started for.
  2. The tagged files land in the app's draft. Symbolic links, submodules and oversize repositories are refused, as for any update from a repository.
  3. The new widget.json is compared with the released one: the hosts the app may call, the browser permissions it asks for, the functions it runs and who may call them, its libraries, and sign-in.
  4. If nothing lets the app reach more, the draft is released. The release records the repository, the commit and the tag.
  5. If anything lets the app reach more, nothing is released. The app's owner gets an approval request in the portal that lists each change. The release goes out when they approve it. The workflow answers with the request's id and a link.

The owner is also asked, instead of the release going out, for an app's first release and for an app that is not public at the moment. Making an app public is always a person's decision.

Releases from CI move forward. A tag is released without a click only when it is a newer version than the tag the current release came from: v1.2.1 after v1.2.0, v2 after v1.9, v2 after v2-rc.1. Versions compare as numbers. Running the workflow again for an older tag asks the owner instead, and so does a tag that cannot be placed after the current release: two tags that differ only in their suffix (v2-rc.1 and v2-beta), or a current release that was made by hand in the portal and not from a tag.

Nothing is released from CI while the account of the person who linked the repository, or of the person a release token belongs to, is suspended or closed.

A released tag does not move. If you point a tag at another commit after it was released, the next release of that tag is refused. Cut a new tag.

If the app's draft holds changes that did not come from the repository and were never released, the release stops and says so. Bring the draft back to the repository in the app's source settings, then tag again.

The request

The workflow does this for you. To call it yourself:

POST /api/apps/<app-id>/release/ci
Authorization: Bearer <identity token or release token>
Content-Type: application/json

{ "ref": "v3", "sha": "<the 40 character commit the tag is on>" }

With an identity token the body may be empty: the tag and the commit come from the token.

StatusMeaning
200 outcome: "released"The tag is the app's release
200 outcome: "unchanged"The release already is this tree
202 outcome: "approval_requested"Nothing was released. The owner was asked. reason is security_widened, first_release, rollback or not_public; approvalUrl is where they answer
4xx, 5xxRefused. error.code names why and error.message says it in a sentence

Common refusal codes:

CodeMeaning
app_not_foundThere is no such app, or this credential is not this app's: an identity token from another repository than the linked one, or a release token of someone who does not own the app. The answer is the same in every one of these cases
relink_requiredThe repository was linked before releases were tied to the repository's id. The owner links it again
ci_release_offThe owner has not turned on releases from this repository's tags
account_inactiveThe account behind the release is suspended or closed
repository_changedThe repository under the linked name is not the one that was linked. The owner links it again
oidc_wrong_refThe run was not started by a release tag
oidc_workflow_not_allowedThe run did not use the app-ci release workflow at a released version and a reviewed commit
oidc_wrong_audienceThe token was asked for another environment
oidc_replayed, oidc_expiredThe token was used before, or is too old. Run the workflow again
token_revoked, token_expiredMake a new release token
sha_mismatch, tag_movedThe tag does not name the commit the run was started for, or it was moved after a release
main_has_editsThe draft holds unreleased changes that did not come from the repository
lib_not_pinned, manifest_invalid, missing_entry, source_refusedThe tagged files cannot be released as they are
not_linkedThe app has no source repository linked
rate_limitedToo many releases. Retry-After says when to try again

Limits

  • 30 releases an hour and 200 a day for one credential (one release token, or one repository's identity tokens).
  • 30 releases an hour for one app.
  • Updates from a repository share a daily limit per owner.

Release attempts are recorded with the credential that made them, the GitHub account and run that started them, the tag, the commit and the outcome. Repeated refusals of one credential are recorded up to a limit each hour.

On this page