Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ jobs:
run: go test -count=1 ./config/ ./config/node/ ./lib/tn/ ./lib/constructs/validator_set/ ./stacks/

# Tests the check that release.yaml and publish-node-image.yaml run on each
# release page, and the Telegram announcement that release.yaml posts. The
# announcement test sends only to a local fake Telegram.
# release page, the Telegram announcement that release.yaml posts, and the
# form of draft-release.yaml. The announcement test sends only to a local
# fake Telegram, and the form test reads heights from a fake curl.
release-upgrade-line:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
Expand All @@ -67,6 +68,8 @@ jobs:
run: scripts/release/test-check-upgrade-line.sh
- name: Test the Telegram announcement
run: scripts/release/test-announce-telegram.sh
- name: Test the Draft release form
run: scripts/release/test-compose-release-notes.sh

acceptance-test:
runs-on: ubuntu-latest
Expand Down
194 changes: 194 additions & 0 deletions .github/workflows/draft-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
name: Draft release

# Drafts a release from a form. The person releasing gives the tag, the target
# and whether each network must install the release. The run checks every
# answer before it creates anything, writes the upgrade line that release.yaml
# and publish-node-image.yaml check (docs/release-process.md), adds the
# summary and the notes that GitHub generates, and saves the release as a
# draft.
#
# Why a draft: a release that a workflow creates with GITHUB_TOKEN does not
# start other workflows. So this run stops at the draft, and the person
# releasing reviews it and clicks Publish release. That click starts
# release.yaml and publish-node-image.yaml as before: the upgrade line check,
# the binaries, the image and the Telegram announcement.

run-name: Draft release ${{ inputs.tag }}

'on':
workflow_dispatch:
inputs:
tag:
description: "Tag of the new release, vX.Y.Z (for example v2.7.0). This run saves a draft; you review it and click Publish release."
required: true
type: string
target:
description: "Branch or commit to release. The draft is pinned to the commit it points at when this runs."
required: true
default: main
type: string
mainnet:
description: "Mainnet: must mainnet nodes install this release by a block? If required, fill in the mainnet block and time."
required: true
default: optional
type: choice
options:
- optional
- required
mainnet_block:
description: "Mainnet block from which the release is required, for example 3300000. Only when mainnet is required; leave empty otherwise."
required: false
type: string
mainnet_time:
description: "About when that mainnet block comes, in UTC: YYYY-MM-DD HH:MM. At least 7 days from now. Only when mainnet is required; leave empty otherwise."
required: false
type: string
testnet:
description: "Testnet: must testnet nodes install this release by a block? If required, fill in the testnet block and time."
required: true
default: optional
type: choice
options:
- optional
- required
testnet_block:
description: "Testnet block from which the release is required, for example 16300000. Only when testnet is required; leave empty otherwise."
required: false
type: string
testnet_time:
description: "About when that testnet block comes, in UTC: YYYY-MM-DD HH:MM. Only when testnet is required; leave empty otherwise."
required: false
type: string
summary:
description: "Optional. One line shown under the upgrade line, above the generated notes."
required: false
type: string
short_notice:
description: "Short notice: allow a mainnet time less than 7 days away, for an urgent release. The run warns."
required: false
default: false
type: boolean

permissions:
contents: write

concurrency:
group: draft-release-${{ inputs.tag }}
cancel-in-progress: false

jobs:
draft:
name: Draft the release
runs-on: ubuntu-latest
timeout-minutes: 10
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ inputs.tag }}
TARGET: ${{ inputs.target }}
MAINNET: ${{ inputs.mainnet }}
MAINNET_BLOCK: ${{ inputs.mainnet_block }}
MAINNET_TIME: ${{ inputs.mainnet_time }}
TESTNET: ${{ inputs.testnet }}
TESTNET_BLOCK: ${{ inputs.testnet_block }}
TESTNET_TIME: ${{ inputs.testnet_time }}
SUMMARY: ${{ inputs.summary }}
SHORT_NOTICE: ${{ inputs.short_notice }}
# Public gateways, read for the current heights only.
MAINNET_RPC: https://gateway.mainnet.truf.network/rpc/v1
TESTNET_RPC: https://gateway.testnet.truf.network/rpc/v1
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

# Refuses a wrong tag, a missing or stray block or time, a time in the
# wrong form and a mainnet time less than 7 days away; warns when a block
# is not above its network's current height.
- name: Check the form and write the upgrade line
run: |
scripts/release/compose-release-notes.sh \
--tag "$TAG" --target "$TARGET" \
--mainnet "$MAINNET" --mainnet-block "$MAINNET_BLOCK" --mainnet-time "$MAINNET_TIME" \
--testnet "$TESTNET" --testnet-block "$TESTNET_BLOCK" --testnet-time "$TESTNET_TIME" \
--summary "$SUMMARY" --short-notice "$SHORT_NOTICE" \
--mainnet-rpc "$MAINNET_RPC" --testnet-rpc "$TESTNET_RPC" \
> "$RUNNER_TEMP/head.md"

- name: Check the tag and the target
id: target
run: |
refs=$(gh api "repos/$GITHUB_REPOSITORY/git/matching-refs/tags/$TAG" --jq '.[].ref')
if grep -qxF "refs/tags/$TAG" <<<"$refs"; then
echo "::error::The tag $TAG exists already. Pick a new tag."
exit 1
fi
# Drafts have no tag yet, so the releases are read too.
releases=$(gh api --paginate "repos/$GITHUB_REPOSITORY/releases?per_page=100" --jq '.[].tag_name')
if grep -qxF "$TAG" <<<"$releases"; then
echo "::error::A release or a draft for $TAG exists already. Finish or delete it on the releases page, or pick a new tag."
exit 1
fi
if [ "$TARGET" = "$GITHUB_REF_NAME" ]; then
# The branch or tag the run was started from: its commit when Run
# workflow was clicked.
sha=$GITHUB_SHA
elif ! sha=$(gh api "repos/$GITHUB_REPOSITORY/commits/$TARGET" --jq .sha); then
echo "::error::The target $TARGET is not a branch, tag or commit of this repository."
exit 1
fi
echo "The target $TARGET is commit $sha."
echo "sha=$sha" >> "$GITHUB_OUTPUT"

# generate-notes only returns text; it creates nothing. GitHub picks the
# previous release as the start of the list.
- name: Write the release notes
env:
SHA: ${{ steps.target.outputs.sha }}
run: |
gh api -X POST "repos/$GITHUB_REPOSITORY/releases/generate-notes" \
-f tag_name="$TAG" -f target_commitish="$SHA" --jq .body > "$RUNNER_TEMP/notes.md"
{ cat "$RUNNER_TEMP/head.md"; echo; cat "$RUNNER_TEMP/notes.md"; } > "$RUNNER_TEMP/body.md"
scripts/release/check-upgrade-line.sh < "$RUNNER_TEMP/body.md"

- name: Create the draft release
id: draft
env:
SHA: ${{ steps.target.outputs.sha }}
run: |
if ! url=$(gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --draft \
--title "$TAG" --target "$SHA" --notes-file "$RUNNER_TEMP/body.md"); then
# GitHub asks for the workflows permission, which GITHUB_TOKEN
# cannot have, to release a commit that changes a workflow file and
# is not the tip of a branch or a tag.
echo "::error::The draft could not be created, or its creation could not be confirmed. Before running the form again, check the releases page for a draft of $TAG, and publish or delete it if it is there. If commit $SHA changes a file under .github/workflows and is no longer the tip of a branch or a tag (for example, the branch moved on during the run), GitHub does not let this workflow release it. Run the form again with a branch whose tip is the commit to release, or write the release by hand (docs/release-process.md)."
exit 1
fi
echo "Draft release: $url"
echo "url=$url" >> "$GITHUB_OUTPUT"

- name: Write the run summary
env:
SHA: ${{ steps.target.outputs.sha }}
DRAFT_URL: ${{ steps.draft.outputs.url }}
run: |
body=$RUNNER_TEMP/body.md
{
echo "## Draft release $TAG"
echo
echo "Review it, then click **Publish release**: $DRAFT_URL"
echo
echo "Target: \`$TARGET\`, commit \`$SHA\`."
echo
echo "### Upgrade line"
echo
echo '```text'
head -n 1 "$body"
echo '```'
echo
echo "### Telegram message after you publish"
echo
echo '```text'
scripts/release/announce-telegram.sh --dry-run "$TAG" "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/tag/$TAG" < "$body"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
39 changes: 35 additions & 4 deletions docs/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This page is for maintainers who publish a TN node release. Node operators read

The release notes open with one line that says whether node operators must install the release. `release.yaml` and `publish-node-image.yaml` check that line before they build anything. A release without it gets no binaries and no image, and the `latest` image tag does not move.

The **Draft release** form writes this line for you; see [Publishing a Release](#publishing-a-release).

The line is exactly one of these four forms:

- Optional on both networks:
Expand Down Expand Up @@ -60,7 +62,7 @@ A required release must run every block before its block the same way as the rel

## Notice for a Required Release

- Publish a required release at least 7 days before its mainnet block, and state its testnet block on the same line.
- Publish a required release at least 7 days before its mainnet block, and state its testnet block on the same line. The **Draft release** form refuses a mainnet time less than 7 days away unless **Short notice** is ticked.
- Pick each block from the measured block rate, as in [Pick the activation height](maa-rollout.md#pick-the-activation-height), and round the time.
- A migration that needs the new release, for example one whose actions call a method only that release has, is applied on a network only after the release's block on that network.
- Where the change waits on an on-chain network parameter that the release adds, as `maa_exec` waits on `maa_activation_height`, the release's block is the earliest block in which the resolution that sets the parameter may pass, not the height that resolution sets. A node on an older release cannot read the parameter and halts once that resolution passes, whatever height it sets (see [Failure modes and rollback](maa-rollout.md#failure-modes-and-rollback)). If operators need more time, hold the resolution back and edit the release notes to the new block and time. After the resolution has passed, a follow-up resolution can still move the activation height later (see [Re-scheduling](maa-rollout.md#re-scheduling)), but that only delays the change on upgraded nodes and gives no more time to a node on an older release.
Expand Down Expand Up @@ -90,10 +92,39 @@ Without `--dry-run`, it posts the message to the chat in `TELEGRAM_CHAT_ID`, in

## Publishing a Release

The normal way is the **Draft release** form. It writes the upgrade line, adds the notes that GitHub generates, and saves the release as a draft for you to review and publish. Writing the notes by hand is the fallback.

### With the Draft Release Form

1. On the repository's **Actions** tab, choose **Draft release**, then **Run workflow**. Leave **Use workflow from** on `main`.
2. Fill in the form:
- **Tag**: the new release's tag, `vX.Y.Z`. No release, draft or tag may have it yet.
- **Target**: the branch or commit to release, `main` by default. The draft is pinned to one commit, so a later merge does not slip into the release. When the target is the branch in **Use workflow from**, as `main` is by default, that commit is the branch's tip when you click **Run workflow**. For another target, it is the commit the target points at when the run checks it, shortly after the start. GitHub does not let the run release a commit that changes a file under `.github/workflows` and is not the tip of a branch or a tag; the run then stops with an error and creates nothing. Give a branch whose tip is that commit as the target, or release [by hand](#by-hand).
- **Mainnet** and **Testnet**: `optional` or `required`; see [Optional or Required](#optional-or-required).
- For each required network, its **block** and its **time**, in UTC as `YYYY-MM-DD HH:MM`; see [Notice for a Required Release](#notice-for-a-required-release). Leave both empty for an optional network. The run refuses a block or a time given for an optional network, so that nothing you typed is dropped.
- **Summary**: optional. One line shown under the upgrade line, above the generated notes.
- **Short notice**: tick it only for an urgent release whose mainnet time is less than 7 days away. The run then warns instead of refusing.
3. Click **Run workflow**. The run checks every answer before it creates anything and lists each problem it finds. It warns when a required block is not above that network's current height. It writes the notes: the upgrade line, then the summary when given, then the notes that GitHub generates since the previous release. It checks them with `check-upgrade-line.sh` and saves them as a draft release.
4. Open the run. Its summary shows the upgrade line, the Telegram message that the release will post, and the link to the draft.
5. Open the draft and review it. You can edit it, keeping the upgrade line first. Editing a draft starts no workflow.
6. Click **Publish release**. That starts the workflows in [What Publishing Starts](#what-publishing-starts). Publish soon after the run: the 7 days of notice count from the run, not from the publish.

The run stops at a draft because a release that a workflow creates with its `GITHUB_TOKEN` does not start other workflows. Your click on **Publish release** does, so the check, the binaries, the image and the Telegram announcement run as for a release written by hand.

`scripts/release/compose-release-notes.sh` checks the form and writes the upgrade line. `scripts/release/test-compose-release-notes.sh` tests it; CI runs it.

### By Hand

When the form cannot be used:

1. Draft the release from its tag, generate the notes, and put the upgrade line first.
2. Check the notes with `scripts/release/check-upgrade-line.sh`.
3. Publish. `release.yaml` builds the four `kwild` tarballs, uploads them to the release and posts the Telegram announcement. `publish-node-image.yaml` pushes the image as `v<version>`, `<version>`, `sha-<short commit>` and `latest`.
4. If the line was missing or wrong, both workflows fail before they build. Edit the release to fix the line. `release.yaml` runs again on the edit, uploads the binaries and posts the announcement. `publish-node-image.yaml` runs only when a release is published, so run **Publish Node Image** by hand on the release tag with **Also tag this build as latest**. A manual run has no release notes to read, so it skips the check.
5. After a required release, run **Build AMI** so that nodes launched from the AMI start on it.
3. Publish.

### What Publishing Starts

1. `release.yaml` builds the four `kwild` tarballs, uploads them to the release and posts the Telegram announcement. `publish-node-image.yaml` pushes the image as `v<version>`, `<version>`, `sha-<short commit>` and `latest`.
2. If the line was missing or wrong, both workflows fail before they build. Edit the release to fix the line. `release.yaml` runs again on the edit, uploads the binaries and posts the announcement. `publish-node-image.yaml` runs only when a release is published, so run **Publish Node Image** by hand on the release tag with **Also tag this build as latest**. A manual run has no release notes to read, so it skips the check.
3. After a required release, run **Build AMI** so that nodes launched from the AMI start on it.

Every edit of the release notes runs `release.yaml` again, which builds and uploads the binaries again. It does not post the announcement again.
Loading
Loading