| @@ -0,0 +1,96 @@ |
| 1 | +# A release: pushing a `v*` tag builds the dist compiler and the runtime |
| 2 | +# archives and keeps them as the run's artifact, `louise-<tag>-x86_64-linux`: |
| 3 | +# a tar.xz of the `louise` binary and the three runtime archives (the |
| 4 | +# binary looks for them next to itself), with the tarball's sha256. |
| 5 | +# `louise self update` downloads and installs it (issue #284). |
| 6 | +# |
| 7 | +# CI artifacts — expiring (90 days at most) and run-keyed — are the |
| 8 | +# interim distribution until the forge has real releases (toboggan#94); |
| 9 | +# the update command's discovery is the one function that knows this |
| 10 | +# shape. The tag must name the workspace's version (`v0.1.0` builds |
| 11 | +# `louise 0.1.0`): the smoke test below, and every updating client, |
| 12 | +# refuse a mismatch. |
| 13 | +name: release |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + tags: ["v*"] |
| 18 | + workflow_dispatch: |
| 19 | + |
| 20 | +jobs: |
| 21 | + release: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + timeout-minutes: 60 |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Install toolchains |
| 28 | + run: | |
| 29 | + sudo_cmd=$(command -v sudo || true) |
| 30 | + $sudo_cmd apt-get update -qq |
| 31 | + # lld and llvm (llvm-ar): scripts/runtime.sh's lto archive. |
| 32 | + $sudo_cmd apt-get install -y -qq build-essential clang lld llvm curl xz-utils |
| 33 | + if ! command -v rustup >/dev/null && [ ! -x "$HOME/.cargo/bin/rustup" ]; then |
| 34 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ |
| 35 | + | sh -s -- -y --profile minimal --default-toolchain none |
| 36 | + fi |
| 37 | + |
| 38 | + - name: Build the dist compiler and the runtime archives |
| 39 | + run: | |
| 40 | + export PATH="$HOME/.cargo/bin:$PATH" |
| 41 | + cargo build --profile dist -p louise -p louise_rt |
| 42 | + scripts/runtime.sh dist |
| 43 | + |
| 44 | + # A tag push names the release after the tag; a manual run after the |
| 45 | + # commit (its artifact is for trying the workflow, not for `louise |
| 46 | + # self update`, which looks at tag runs only). |
| 47 | + - name: Package louise-<tag>-x86_64-linux.tar.xz |
| 48 | + id: package |
| 49 | + run: | |
| 50 | + set -euo pipefail |
| 51 | + version="${GITHUB_REF#refs/tags/}" |
| 52 | + if [ "$version" = "$GITHUB_REF" ]; then |
| 53 | + version="v0.0.0-$(git rev-parse --short HEAD)" |
| 54 | + fi |
| 55 | + name="louise-$version-x86_64-linux" |
| 56 | + mkdir -p "out/$name" |
| 57 | + install -m 0755 target/dist/louise "out/$name/louise" |
| 58 | + install -m 0644 \ |
| 59 | + target/dist/liblouise_rt.a \ |
| 60 | + target/dist/liblouise_rt-fast.a \ |
| 61 | + target/dist/liblouise_rt-lto.a \ |
| 62 | + target/dist/liblouise_rt-lto.llvm \ |
| 63 | + "out/$name/" |
| 64 | + tar -C out -cJf "out/$name.tar.xz" "$name" |
| 65 | + (cd out && sha256sum "$name.tar.xz" > "$name.tar.xz.sha256") |
| 66 | + cat "out/$name.tar.xz.sha256" |
| 67 | + echo "artifact=$name" >> "$GITHUB_OUTPUT" |
| 68 | + |
| 69 | + # What every client runs before it installs anything: the tarball's |
| 70 | + # louise runs and is the tag's version. |
| 71 | + - name: Smoke-test the tarball |
| 72 | + run: | |
| 73 | + set -euo pipefail |
| 74 | + artifact="${{ steps.package.outputs.artifact }}" |
| 75 | + mkdir -p "$RUNNER_TEMP/smoke" |
| 76 | + tar -C "$RUNNER_TEMP/smoke" -xJf "out/$artifact.tar.xz" |
| 77 | + reported="$("$RUNNER_TEMP/smoke/$artifact/louise" --version)" |
| 78 | + echo "$reported" |
| 79 | + # On a tag, the binary must be the tag's version (`v0.1.0` |
| 80 | + # builds `louise 0.1.0`): clients refuse a mismatch. |
| 81 | + if [ "$GITHUB_REF" != "${GITHUB_REF#refs/tags/}" ]; then |
| 82 | + version="${GITHUB_REF#refs/tags/}" |
| 83 | + [ "$reported" = "louise ${version#v}" ] || { |
| 84 | + echo "::error::the tag ($version) and the binary ($reported) differ; bump the workspace version" |
| 85 | + exit 1 |
| 86 | + } |
| 87 | + fi |
| 88 | + |
| 89 | + - name: Upload the artifact `louise self update` installs |
| 90 | + uses: https://code.forgejo.org/forgejo/upload-artifact@v5 |
| 91 | + with: |
| 92 | + name: ${{ steps.package.outputs.artifact }} |
| 93 | + path: | |
| 94 | + out/*.tar.xz |
| 95 | + out/*.tar.xz.sha256 |
| 96 | + retention-days: 90 |