|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | | -# This scripts builds master and current branch with nix |
| 3 | +# This scripts builds a designated PREFORK branch and current branch with nix |
4 | 4 | # 0. Prepare environment if needed |
5 | | -# 1. Build master as a prefork build; |
| 5 | +# 1. Build PREFORK as a prefork build; |
6 | 6 | # 2. Upload to nix cache, the reason for not uploading cache for following 2 |
7 | 7 | # steps is that they change for each PR. |
8 | 8 | # 3. Build current branch as a postfork build; |
|
12 | 12 | # Step 0. Prepare environment if needed |
13 | 13 | set -eux -o pipefail |
14 | 14 |
|
| 15 | +PREFORK="" |
| 16 | + |
| 17 | +usage() { |
| 18 | + echo "Usage: $0 --fork-from <PREFORK>" |
| 19 | + exit 1 |
| 20 | +} |
| 21 | + |
| 22 | +# ---- argument parsing -------------------------------------------------------- |
| 23 | +while [[ $# -gt 0 ]]; do |
| 24 | + case "$1" in |
| 25 | + --fork-from) |
| 26 | + # ensure value exists |
| 27 | + if [[ $# -lt 2 ]]; then |
| 28 | + echo "Error: --fork-from requires an argument." |
| 29 | + usage |
| 30 | + fi |
| 31 | + PREFORK="$2" |
| 32 | + shift 2 |
| 33 | + ;; |
| 34 | + --help|-h) |
| 35 | + usage |
| 36 | + ;; |
| 37 | + --*) |
| 38 | + echo "Unknown option: $1" |
| 39 | + usage |
| 40 | + ;; |
| 41 | + *) |
| 42 | + # positional arg — store if needed later |
| 43 | + echo "Unexpected argument: $1" |
| 44 | + usage |
| 45 | + ;; |
| 46 | + esac |
| 47 | +done |
| 48 | + |
| 49 | +if [[ -z "$PREFORK" ]]; then |
| 50 | + echo "Error: --fork-from must be provided." |
| 51 | + usage |
| 52 | +fi |
| 53 | + |
15 | 54 | NIX_OPTS=( --accept-flake-config --experimental-features 'nix-command flakes' ) |
16 | 55 |
|
17 | 56 | if [[ -n "${NIX_CACHE_NAR_SECRET:-}" ]]; then |
@@ -70,8 +109,8 @@ if [ -n "${BUILDKITE:-}" ]; then |
70 | 109 | git fetch origin |
71 | 110 | fi |
72 | 111 |
|
73 | | -# 1. Build master as a prefork build; |
74 | | -git checkout origin/master |
| 112 | +# 1. Build PREFORK as a prefork build; |
| 113 | +git checkout $PREFORK |
75 | 114 | git submodule update --init --recursive --depth 1 |
76 | 115 | nix "${NIX_OPTS[@]}" build "$PWD?submodules=1#devnet" --out-link "prefork-devnet" |
77 | 116 |
|
|
0 commit comments