Skip to content

Commit 114d32c

Browse files
committed
Publish release bundles from GitHub Actions
1 parent e4f9d35 commit 114d32c

4 files changed

Lines changed: 116 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: Existing git tag to publish
11+
required: true
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-24.04
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
arch:
23+
- x64
24+
- arm64
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: oven-sh/setup-bun@v2
29+
30+
- name: Install dependencies
31+
run: bun install --frozen-lockfile
32+
33+
- name: Build Terrarium binary
34+
run: |
35+
mkdir -p release/dist
36+
bun build --compile --target=bun-linux-${{ matrix.arch }} scripts/terrariumctl.ts --outfile release/dist/terrariumctl
37+
38+
- name: Package release bundle
39+
run: |
40+
cd release
41+
zip -rq "../terrarium-linux-${{ matrix.arch }}.zip" dist
42+
43+
- uses: actions/upload-artifact@v4
44+
with:
45+
name: terrarium-linux-${{ matrix.arch }}
46+
path: terrarium-linux-${{ matrix.arch }}.zip
47+
if-no-files-found: error
48+
49+
publish:
50+
runs-on: ubuntu-24.04
51+
needs: build
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- uses: actions/download-artifact@v4
56+
with:
57+
path: artifacts
58+
59+
- name: Resolve release tag
60+
id: tag
61+
env:
62+
INPUT_TAG: ${{ github.event.inputs.tag }}
63+
run: |
64+
if [ -n "${INPUT_TAG}" ]; then
65+
echo "value=${INPUT_TAG}" >> "${GITHUB_OUTPUT}"
66+
else
67+
echo "value=${GITHUB_REF_NAME}" >> "${GITHUB_OUTPUT}"
68+
fi
69+
70+
- name: Prepare release assets
71+
env:
72+
RELEASE_TAG: ${{ steps.tag.outputs.value }}
73+
run: |
74+
mkdir -p release-assets
75+
cp artifacts/terrarium-linux-x64/terrarium-linux-x64.zip release-assets/
76+
cp artifacts/terrarium-linux-arm64/terrarium-linux-arm64.zip release-assets/
77+
sed "s|^EMBEDDED_BOOTSTRAP_REF=\"\" # TERRARIUM_RELEASE_REF$|EMBEDDED_BOOTSTRAP_REF=\"${RELEASE_TAG}\" # TERRARIUM_RELEASE_REF|" install.sh > release-assets/install.sh
78+
chmod 0644 release-assets/install.sh
79+
(
80+
cd release-assets
81+
sha256sum terrarium-linux-x64.zip terrarium-linux-arm64.zip install.sh > SHA256SUMS
82+
)
83+
84+
- name: Publish GitHub release
85+
uses: softprops/action-gh-release@v2
86+
with:
87+
tag_name: ${{ steps.tag.outputs.value }}
88+
files: |
89+
release-assets/install.sh
90+
release-assets/terrarium-linux-x64.zip
91+
release-assets/terrarium-linux-arm64.zip
92+
release-assets/SHA256SUMS
93+
generate_release_notes: true
94+
prerelease: ${{ contains(steps.tag.outputs.value, '-') }}

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ The goal is simple: make a single VPS feel safe enough for experimentation, capa
1212
## Install:
1313

1414
```bash
15-
curl -fsSL https://raw.githubusercontent.com/terion-name/terrarium/refs/heads/main/install.sh | bash
15+
curl -fsSL https://github.com/terion-name/terrarium/releases/latest/download/install.sh | bash
1616
```
1717

18-
The shell bootstrap is intentionally thin. It downloads a compiled `terrariumctl` bundle from GitHub Releases when possible, clones the Terrarium repo into `/opt/terrarium`, stages the bundled binary into that checkout, and falls back to a source build only when you target a branch-like `--ref` such as `main`.
18+
The shell bootstrap is intentionally thin. The release-published `install.sh` is pinned to the release it came from, downloads the matching compiled `terrariumctl` bundle from GitHub Releases, clones the Terrarium repo into `/opt/terrarium`, and stages that binary into the checkout. If you explicitly target a branch-like `--ref` such as `main`, it falls back to a source build.
19+
20+
If you want to pin a specific release instead of `latest`, use the tagged release asset directly:
21+
22+
```bash
23+
curl -fsSL https://github.com/terion-name/terrarium/releases/download/0.0.0-beta1/install.sh | bash
24+
```
1925

2026
Terrarium provisions the host with:
2127

@@ -41,13 +47,13 @@ Terrarium provisions the host with:
4147
Interactive:
4248

4349
```bash
44-
curl -fsSL https://raw.githubusercontent.com/terion-name/terrarium/refs/heads/main/install.sh | bash
50+
curl -fsSL https://github.com/terion-name/terrarium/releases/latest/download/install.sh | bash
4551
```
4652

4753
Non-interactive:
4854

4955
```bash
50-
curl -fsSL https://raw.githubusercontent.com/terion-name/terrarium/refs/heads/main/install.sh | bash -s -- \
56+
curl -fsSL https://github.com/terion-name/terrarium/releases/latest/download/install.sh | bash -s -- \
5157
--non-interactive \
5258
--email admin@your-domain.tld \
5359
--acme-email certs@your-domain.tld \

docs/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Terrarium is intentionally split into three layers:
44

55
1. `install.sh`
6-
Thin bootstrap only. It downloads a compiled `terrariumctl` bundle from Releases when possible and falls back to a source build only for branch-like refs.
6+
Thin bootstrap only. The release-published installer is pinned to its own release, downloads the matching compiled `terrariumctl` bundle from Releases, and falls back to a source build only for branch-like refs.
77
2. `terrariumctl`
88
Single Terrarium binary. It provides `install`, `backup`, `proxy`, `idp`, and maintenance subcommands, clones or updates the Terrarium repository into `/opt/terrarium`, stages the compiled binary into that checkout, and invokes Ansible locally when needed.
99
3. Ansible

install.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ set -Eeuo pipefail
44
REPO_URL="${TERRARIUM_REPO_URL:-https://github.com/terion-name/terrarium.git}"
55
GITHUB_REPO="${TERRARIUM_GITHUB_REPO:-terion-name/terrarium}"
66
REF=""
7+
EMBEDDED_BOOTSTRAP_REF="" # TERRARIUM_RELEASE_REF
8+
BOOTSTRAP_REF="${TERRARIUM_BOOTSTRAP_REF:-}"
79
TMPDIR_PATH=""
810

11+
if [[ -z "${BOOTSTRAP_REF}" && -n "${EMBEDDED_BOOTSTRAP_REF}" ]]; then
12+
BOOTSTRAP_REF="${EMBEDDED_BOOTSTRAP_REF}"
13+
fi
14+
915
usage() {
1016
cat <<'EOF'
1117
Usage: install.sh [options]
@@ -16,7 +22,8 @@ Usage: install.sh [options]
1622
All other flags are forwarded to `terrariumctl install`.
1723
1824
Behavior:
19-
- without --ref, the bootstrap downloads the latest Terrarium release bundle
25+
- without --ref, the bootstrap downloads the bundled release when the installer is release-pinned
26+
- otherwise without --ref, it downloads the latest Terrarium release bundle
2027
- with a tag-like --ref, it downloads that release bundle
2128
- with a branch-like --ref (for example main), it falls back to a source build
2229
EOF
@@ -159,6 +166,9 @@ main() {
159166
arch="$(detect_arch)"
160167

161168
if [[ -z "${REF}" ]]; then
169+
if [[ -n "${BOOTSTRAP_REF}" ]] && download_release_bundle "${tmpdir}" "${arch}" "${BOOTSTRAP_REF}"; then
170+
exit 0
171+
fi
162172
resolved_ref="$(resolve_latest_tag)"
163173
if [[ -n "${resolved_ref}" ]] && download_release_bundle "${tmpdir}" "${arch}" "${resolved_ref}"; then
164174
exit 0

0 commit comments

Comments
 (0)