Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

ci: add manual release workflow

ldm0f1bf28c6c096
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 000000000..fab139254
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,123 @@
+name: Release
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: Version from moli/Cargo.toml (for example, 0.1.0)
+ required: true
+ type: string
+ prerelease:
+ description: Mark this release as a prerelease
+ required: true
+ default: false
+ type: boolean
+ draft:
+ description: Create a draft instead of publishing immediately
+ required: true
+ default: false
+ type: boolean
+
+concurrency:
+ group: release-${{ inputs.version }}
+ cancel-in-progress: false
+
+permissions:
+ contents: write
+
+env:
+ CARGO_TERM_COLOR: always
+ CARGO_INCREMENTAL: "0"
+ GIT_CONFIG_COUNT: "1"
+ GIT_CONFIG_KEY_0: safe.directory
+ GIT_CONFIG_VALUE_0: ${{ github.workspace }}
+
+jobs:
+ release:
+ name: Build and publish
+ runs-on: ubuntu-latest
+ timeout-minutes: 90
+ container: rust:1.96.1-bookworm
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ fetch-depth: 0
+ persist-credentials: false
+
+ - name: Validate release request
+ id: release
+ shell: bash
+ env:
+ INPUT_VERSION: ${{ inputs.version }}
+ run: |
+ set -euo pipefail
+
+ version="${INPUT_VERSION#v}"
+ semver_pattern='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'
+ if [[ ! "$version" =~ $semver_pattern ]]; then
+ echo "Invalid semantic version: $INPUT_VERSION" >&2
+ exit 1
+ fi
+
+ manifest_version=$(awk '$1 == "version" && $2 == "=" { gsub(/"/, "", $3); print $3; exit }' moli/Cargo.toml)
+ if [[ "$version" != "$manifest_version" ]]; then
+ echo "Requested version $version does not match moli/Cargo.toml ($manifest_version)." >&2
+ exit 1
+ fi
+
+ tag="v$version"
+ if git show-ref --verify --quiet "refs/tags/$tag"; then
+ echo "Tag $tag already exists." >&2
+ exit 1
+ fi
+
+ echo "version=$version" >> "$GITHUB_OUTPUT"
+ echo "tag=$tag" >> "$GITHUB_OUTPUT"
+
+ - name: Build and package release
+ shell: bash
+ run: scripts/release.sh --version "${{ steps.release.outputs.version }}"
+
+ - name: Install GitHub CLI
+ shell: bash
+ run: |
+ apt-get update
+ apt-get install --yes --no-install-recommends gh
+
+ - name: Create GitHub Release
+ shell: bash
+ env:
+ GH_TOKEN: ${{ github.token }}
+ RELEASE_TAG: ${{ steps.release.outputs.tag }}
+ RELEASE_DRAFT: ${{ inputs.draft }}
+ RELEASE_PRERELEASE: ${{ inputs.prerelease }}
+ run: |
+ set -euo pipefail
+
+ shopt -s nullglob
+ assets=(dist/*.tar.gz dist/*.sha256)
+ if (( ${#assets[@]} != 2 )); then
+ echo "Expected one archive and one checksum, found ${#assets[@]} release assets." >&2
+ exit 1
+ fi
+
+ args=(
+ release create "$RELEASE_TAG"
+ "${assets[@]}"
+ --repo "$GITHUB_REPOSITORY"
+ --target "$GITHUB_SHA"
+ --title "Moli $RELEASE_TAG"
+ --generate-notes
+ )
+ if [[ "$RELEASE_PRERELEASE" == true ]]; then
+ args+=(--prerelease)
+ fi
+ if [[ "$RELEASE_DRAFT" == true ]]; then
+ args+=(--draft)
+ fi
+
+ release_url=$(gh "${args[@]}")
+ printf 'Created %s\n' "$release_url"
+ printf '### Release created\n\n[%s](%s)\n' \
+ "$RELEASE_TAG" "$release_url" >> "$GITHUB_STEP_SUMMARY"
diff --git a/.gitignore b/.gitignore
index e362d18df..5d23d60e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
/target*
+/dist/
/docs/wild-web-report/.wild-web-*
/docs/wild-web-report/.compare-engines-run
/docs/wild-web-report/.compare-engines-indexed.txt
@@ -26,4 +27,4 @@ __pycache__
# own directory with a repo-relative output path.
/moli-benchmark/moli-benchmark/
-node_modules
\ No newline at end of file
+node_modules
diff --git a/README.md b/README.md
index f1a9799b9..a2632d1ea 100644
--- a/README.md
+++ b/README.md
@@ -276,6 +276,9 @@ Current intentional boundaries:
Unsupported protocol paths fail explicitly — Moli never pretends a browser
action, event, network observation, or visual result occurred when it didn't.
+Maintainers can publish a tagged binary release from GitHub Actions by following
+the [release guide](RELEASING.md).
+
## License
Unless a file or directory carries a different notice, Moli is licensed under
diff --git a/RELEASING.md b/RELEASING.md
new file mode 100644
index 000000000..15ca5ffd0
--- /dev/null
+++ b/RELEASING.md
@@ -0,0 +1,33 @@
+# Releasing Moli
+
+The release workflow currently builds one precompiled artifact for
+`x86_64-unknown-linux-gnu`. The archive contains the `moli` binary, project
+licenses, README, version marker, and third-party license notices. A SHA-256
+checksum is published beside it. The packager strips its staging copy of the
+binary while leaving `target/release/moli` unchanged for local debugging.
+
+## Prepare the release
+
+1. Update `version` in `moli/Cargo.toml` and refresh `Cargo.lock`.
+2. Commit and push those changes to the ref that should be released.
+3. Optionally build the exact same package locally:
+
+ ```bash
+ scripts/release.sh --version 0.1.0
+ ```
+
+ Artifacts are written to `dist/`. The script rejects a version that does
+ not match `moli/Cargo.toml` and verifies the packaged binary's reported
+ version.
+
+## Trigger GitHub Release
+
+1. Open **Actions** in GitHub and choose the **Release** workflow.
+2. Select **Run workflow** and choose the Git ref containing the release.
+3. Enter the version (with or without a leading `v`).
+4. Choose whether the release should be a prerelease or a draft, then run it.
+
+The workflow builds the selected commit, creates the corresponding `vX.Y.Z`
+tag, generates release notes, and uploads the archive and checksum. It stops
+without publishing if the requested version does not match the manifest or if
+the tag already exists.
diff --git a/scripts/release.sh b/scripts/release.sh
new file mode 100755
index 000000000..161c9bf74
--- /dev/null
+++ b/scripts/release.sh
@@ -0,0 +1,190 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
+repo_root="$(cd -- "$script_dir/.." && pwd -P)"
+
+usage() {
+ cat <<'EOF'
+Build and package a Moli release.
+
+Usage:
+ scripts/release.sh --version <VERSION> [options]
+
+Options:
+ --version <VERSION> Release version, with or without a leading "v".
+ --output-dir <DIR> Artifact directory (defaults to ./dist).
+ --binary <PATH> Binary to package (defaults to Cargo's release output).
+ --skip-build Package an existing binary instead of running Cargo.
+ -h, --help Show this help.
+
+Examples:
+ scripts/release.sh --version 0.1.0
+ scripts/release.sh --version v0.1.0 --skip-build --binary target/release/moli
+EOF
+}
+
+fail() {
+ printf 'release: %s\n' "$*" >&2
+ exit 1
+}
+
+require_value() {
+ local option="$1"
+ local value="${2:-}"
+ [[ -n "$value" ]] || fail "$option requires a value"
+}
+
+release_version=""
+output_dir="$repo_root/dist"
+binary=""
+skip_build=false
+
+while (( $# > 0 )); do
+ case "$1" in
+ --version)
+ require_value "$1" "${2:-}"
+ release_version="$2"
+ shift 2
+ ;;
+ --output-dir)
+ require_value "$1" "${2:-}"
+ output_dir="$2"
+ shift 2
+ ;;
+ --binary)
+ require_value "$1" "${2:-}"
+ binary="$2"
+ shift 2
+ ;;
+ --skip-build)
+ skip_build=true
+ shift
+ ;;
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ *)
+ fail "unknown argument: $1"
+ ;;
+ esac
+done
+
+[[ -n "$release_version" ]] || fail "--version is required"
+
+version="${release_version#v}"
+semver_pattern='^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'
+[[ "$version" =~ $semver_pattern ]] || fail "invalid semantic version: $release_version"
+
+manifest_version="$(
+ awk '$1 == "version" && $2 == "=" { gsub(/"/, "", $3); print $3; exit }' \
+ "$repo_root/moli/Cargo.toml"
+)"
+[[ -n "$manifest_version" ]] || fail "could not read the version from moli/Cargo.toml"
+[[ "$version" == "$manifest_version" ]] || \
+ fail "requested version $version does not match moli/Cargo.toml ($manifest_version)"
+
+cd -- "$repo_root"
+
+target="$(rustc -vV | awk '$1 == "host:" { print $2; exit }')"
+[[ "$target" =~ ^[A-Za-z0-9_][A-Za-z0-9_.-]*$ ]] || fail "invalid Rust target: $target"
+
+if [[ "$skip_build" == false ]]; then
+ cargo build --locked --release --package moli
+fi
+
+if [[ -z "$binary" ]]; then
+ target_dir="${CARGO_TARGET_DIR:-$repo_root/target}"
+ if [[ "$target_dir" != /* ]]; then
+ target_dir="$repo_root/$target_dir"
+ fi
+ binary="$target_dir/release/moli"
+elif [[ "$binary" != /* ]]; then
+ binary="$repo_root/$binary"
+fi
+
+[[ -f "$binary" ]] || fail "binary does not exist: $binary"
+[[ -x "$binary" ]] || fail "binary is not executable: $binary"
+
+binary_version="$("$binary" version)"
+[[ "$binary_version" == "$version" ]] || \
+ fail "binary reports version $binary_version, expected $version"
+
+for required_file in README.md RELEASING.md LICENSE LICENSE-APACHE LICENSE-MIT; do
+ [[ -f "$repo_root/$required_file" ]] || fail "missing release file: $required_file"
+done
+for required_dir in third_party/licenses third_party/notices; do
+ [[ -d "$repo_root/$required_dir" ]] || fail "missing release directory: $required_dir"
+done
+
+mkdir -p -- "$output_dir"
+output_dir="$(cd -- "$output_dir" && pwd -P)"
+
+package_name="moli-v${version}-${target}"
+archive_name="$package_name.tar.gz"
+checksum_name="$archive_name.sha256"
+
+[[ ! -e "$output_dir/$archive_name" ]] || fail "artifact already exists: $output_dir/$archive_name"
+[[ ! -e "$output_dir/$checksum_name" ]] || fail "artifact already exists: $output_dir/$checksum_name"
+
+staging_root="$(mktemp -d "$output_dir/.moli-release.XXXXXX")"
+cleanup() {
+ if [[ -n "${staging_root:-}" && -d "$staging_root" ]]; then
+ rm -rf -- "$staging_root"
+ fi
+}
+trap cleanup EXIT
+
+package_dir="$staging_root/$package_name"
+mkdir -p -- "$package_dir/third_party"
+install -m 0755 -- "$binary" "$package_dir/moli"
+
+strip_tool="${STRIP:-strip}"
+command -v -- "$strip_tool" >/dev/null 2>&1 || fail "strip tool does not exist: $strip_tool"
+unstripped_size="$(wc -c < "$package_dir/moli")"
+"$strip_tool" "$package_dir/moli"
+stripped_size="$(wc -c < "$package_dir/moli")"
+packaged_version="$("$package_dir/moli" version)"
+[[ "$packaged_version" == "$version" ]] || \
+ fail "stripped binary reports version $packaged_version, expected $version"
+printf 'Stripped packaged binary: %s -> %s bytes\n' "$unstripped_size" "$stripped_size"
+
+install -m 0644 -- \
+ "$repo_root/README.md" \
+ "$repo_root/RELEASING.md" \
+ "$repo_root/LICENSE" \
+ "$repo_root/LICENSE-APACHE" \
+ "$repo_root/LICENSE-MIT" \
+ "$package_dir/"
+cp -R -- "$repo_root/third_party/licenses" "$package_dir/third_party/licenses"
+cp -R -- "$repo_root/third_party/notices" "$package_dir/third_party/notices"
+printf '%s\n' "$version" > "$package_dir/VERSION"
+
+tar -C "$staging_root" -czf "$staging_root/$archive_name" "$package_name"
+tar -tzf "$staging_root/$archive_name" > "$staging_root/archive-contents.txt"
+grep -Fxq "$package_name/moli" "$staging_root/archive-contents.txt" || \
+ fail "packaged archive does not contain the moli binary"
+
+if command -v sha256sum >/dev/null 2>&1; then
+ (
+ cd -- "$staging_root"
+ sha256sum "$archive_name" > "$checksum_name"
+ sha256sum --check "$checksum_name"
+ )
+elif command -v shasum >/dev/null 2>&1; then
+ (
+ cd -- "$staging_root"
+ shasum -a 256 "$archive_name" > "$checksum_name"
+ shasum -a 256 --check "$checksum_name"
+ )
+else
+ fail "sha256sum or shasum is required"
+fi
+
+mv -- "$staging_root/$archive_name" "$output_dir/$archive_name"
+mv -- "$staging_root/$checksum_name" "$output_dir/$checksum_name"
+
+printf 'Created %s\n' "$output_dir/$archive_name"
+printf 'Created %s\n' "$output_dir/$checksum_name"