diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dac65a3..dd1b238 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,6 @@ on: push: branches: [main] pull_request: - # The release workflow runs all of CI before it builds anything. - workflow_call: env: CARGO_TERM_COLOR: always @@ -38,6 +36,15 @@ jobs: os: [macos-latest, windows-latest, ubuntu-latest] runs-on: ${{ matrix.os }} steps: + # The release build, the debug test build and the cache together fill a + # stock Linux runner's disk; these preinstalled tools are never used. + - name: Free disk space (Linux) + if: runner.os == 'Linux' + run: | + df -h / + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL + docker image prune -af || true + df -h / - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable - name: Install gpui's Linux libraries (X11 and Wayland) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8c7c369..db3f9d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,7 @@ # Publishes MUDling for macOS, Windows and Linux when a version tag such as -# v1.2.3 on main is pushed. CI runs first; every build then lands on one -# GitHub Release, which publishes each asset's SHA-256 digest. Self-update +# v1.2.3 on main is pushed. The tagged commit must already have a green CI run +# on main; every build then lands on one GitHub Release, created only after +# all builds succeed. GitHub publishes each asset's SHA-256 digest. Self-update # reads those digests, so assets are never renamed after upload. # docs/releasing.md says how to cut a release. name: Release @@ -20,8 +21,20 @@ env: CARGO_TERM_COLOR: always jobs: - check: - uses: ./.github/workflows/ci.yml + # Builds only what CI has already passed on main, rather than running CI + # again where a flaky test or a full disk could fail the release. + gate: + name: CI has passed on this commit + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + env: + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - run: scripts/require-green-ci.sh "$GITHUB_SHA" version: name: Read the version from the tag @@ -45,7 +58,7 @@ jobs: macos: name: macOS (${{ matrix.arch }}) - needs: [check, version] + needs: [gate, version] strategy: matrix: include: @@ -143,7 +156,7 @@ jobs: windows: name: Windows (${{ matrix.arch }}) - needs: [check, version] + needs: [gate, version] strategy: matrix: include: @@ -233,7 +246,7 @@ jobs: linux: name: Linux (${{ matrix.arch }}) - needs: [check, version] + needs: [gate, version] strategy: matrix: include: @@ -250,6 +263,13 @@ jobs: # The runners have no FUSE, so appimagetool runs from its extracted self. APPIMAGE_EXTRACT_AND_RUN: 1 steps: + # The preinstalled tools below are never used and take space the build needs. + - name: Free disk space + run: | + df -h / + sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL + docker image prune -af || true + df -h / - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 - uses: dtolnay/rust-toolchain@b725eda525362e7cf34af9a7243cac1e3f01a7ec # stable - name: Install gpui's Linux libraries (X11 and Wayland) @@ -288,7 +308,6 @@ jobs: - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: path: dist - # Only the builds: CI, run first, uploads its bench reports to this run too. pattern: '{macos,windows,linux}-*' merge-multiple: true diff --git a/docs/releasing.md b/docs/releasing.md index 506dbc2..dad4251 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -1,29 +1,63 @@ # Releasing MUDling A release is a version tag on `main`. Pushing it starts -[`.github/workflows/release.yml`](../.github/workflows/release.yml), which runs -all of CI, then builds every platform and attaches the builds to one GitHub -Release. +[`.github/workflows/release.yml`](../.github/workflows/release.yml), which +checks that CI has passed on the tagged commit, builds every platform and +attaches the builds to one GitHub Release. It does not run CI again: it relies +on the run CI already made when that commit landed on `main`. ## Cutting a release -1. Make sure `main` is green and holds what you want to ship. -2. Tag the commit on `main` and push the tag: +1. Pick a commit on `main` whose CI run is green (check the commit's mark on + GitHub or the **CI** runs under Actions), and that holds what you want to + ship. +2. Tag that commit and push the tag: ```sh - git tag v1.2.3 origin/main + git tag v1.2.3 # or origin/main, once its CI is green git push origin v1.2.3 ``` - The tag must look like `v1.2.3` and point at a commit on `main`, or the - workflow stops before building anything. -3. Watch the **Release** run under Actions. When it finishes, the release is - on the [releases page](https://github.com/Vyttle-LLC/mudling/releases) - with notes generated from the merged pull requests. + The tag must look like `v1.2.3` and point at a commit on `main` with a + passed CI run, or the workflow stops before building anything. +3. Watch the **Release** run under Actions. When every build has succeeded, the + workflow creates the release; it is then on the + [releases page](https://github.com/Vyttle-LLC/mudling/releases) with notes + generated from the merged pull requests. -To write the notes yourself, draft a release for the tag in GitHub's UI first. -The workflow then attaches the builds to that draft instead of creating a -release, and you publish it when you're ready. +Never publish a release in GitHub's UI before the builds land: it would show an +empty release as the latest one. To write the notes yourself, save a *draft* +release for the tag first. The workflow attaches the builds to that draft +instead of creating a release, and you publish it once the run has finished. + +### If the first job stops + +The **CI has passed on this commit** job fails with *"CI hasn't passed on main +for ``"* when the commit has no finished, green CI run on `main`: CI failed, +is still running, or never ran. Nothing has been built or published. Wait for +CI to pass on `main` (or re-run it from the Actions tab), then delete the tag +and push it again: + +```sh +git push origin --delete v1.2.3 +git tag -d v1.2.3 +git tag v1.2.3 +git push origin v1.2.3 +``` + +### Removing a failed tag + +A release whose builds failed leaves a tag and, only if you drafted or +published one, an empty release. Remove both before trying again: + +```sh +gh release delete v1.2.3 --repo Vyttle-LLC/mudling # if a release exists +git push origin --delete v1.2.3 +git tag -d v1.2.3 +``` + +Then push the tag again, as above. Once a release has been published and +people may have downloaded it, don't reuse its version: tag the next one. ## What a release holds diff --git a/scripts/require-green-ci.sh b/scripts/require-green-ci.sh new file mode 100755 index 0000000..3cb0e35 --- /dev/null +++ b/scripts/require-green-ci.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# Fails unless CI has passed on main for the given commit, so a release builds +# only what CI has already checked. Needs gh, jq and GH_REPO (owner/name). +# Usage: scripts/require-green-ci.sh +set -eu + +sha="$1" + +runs="$(gh run list --workflow ci.yml --event push --branch main --commit "$sha" \ + --json status,conclusion --limit 100)" + +if [ "$(printf '%s' "$runs" | jq '[.[] | select(.status == "completed" and .conclusion == "success")] | length')" -gt 0 ]; then + echo "CI passed on main for $sha." + exit 0 +fi + +echo "::error::CI hasn't passed on main for $sha. Wait for it to pass (or re-run it), then delete and push the tag again." +exit 1