Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 56 additions & 26 deletions .github/workflows/_rust-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,22 @@ jobs:
echo "::error::could not derive worker dir from manifest_path=$MANIFEST"
exit 1
fi
# A worker's frontend lives in web/ (embedded SPA, e.g. console)
# or ui/ (injected console UI, e.g. state).
if [[ -f "$worker/web/package.json" ]]; then
webdir="web"
elif [[ -f "$worker/ui/package.json" ]]; then
webdir="ui"
else
# A worker's frontend lives in web/ (embedded SPA, e.g. console),
# ui/ (injected console UI, e.g. state), or both (console ships an
# embedded SPA and an injected config form). Build every dir that
# exists — the matrix shards skip pnpm entirely (SKIP_WEB_BUILD +
# SKIP_UI_BUILD), so any dist missing here panics their build.rs.
webdirs=""
[[ -f "$worker/web/package.json" ]] && webdirs="web"
[[ -f "$worker/ui/package.json" ]] && webdirs="$webdirs ui"
webdirs="${webdirs# }"
if [[ -z "$webdirs" ]]; then
echo "::error::$worker has neither web/package.json nor ui/package.json; web_bundle=true requires one"
exit 1
fi
echo "worker=$worker" >> "$GITHUB_OUTPUT"
echo "webdir=$webdir" >> "$GITHUB_OUTPUT"
echo "::notice::pre-building bundle in $worker/$webdir/"
echo "webdirs=$webdirs" >> "$GITHUB_OUTPUT"
echo "::notice::pre-building bundle(s): $webdirs in $worker/"

# `pnpm/action-setup` must run before `setup-node` so that
# `setup-node`'s `cache: 'pnpm'` finds the binary on PATH. The pnpm
Expand All @@ -173,19 +176,30 @@ jobs:
# any standalone <worker>/web lockfile.
cache-dependency-path: '**/pnpm-lock.yaml'

- name: pnpm install
working-directory: ${{ steps.dirs.outputs.worker }}/${{ steps.dirs.outputs.webdir }}
run: pnpm install --frozen-lockfile

- name: pnpm build
working-directory: ${{ steps.dirs.outputs.worker }}/${{ steps.dirs.outputs.webdir }}
run: pnpm build
- name: pnpm install + build
env:
WORKER: ${{ steps.dirs.outputs.worker }}
WEBDIRS: ${{ steps.dirs.outputs.webdirs }}
run: |
set -euo pipefail
for d in $WEBDIRS; do
(cd "$WORKER/$d" && pnpm install --frozen-lockfile && pnpm build)
done
Comment on lines +179 to +187

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files matching workflow/action names:"
fd -a '_rust-binary.yml|action.yml|upload-rust-binary-action' . | sed 's#^\./##' | head -200

echo
python3 - <<'PY'
from pathlib import Path
import re
for p in Path('.github/workflows').glob('*.yml'):
    text = p.read_text()
    if '_rust-binary.yml' in str(p) or 'upload-rust' in text or 'web-build' in text or 'build' in text:
        lines = [f"{i+1}: {line}" for i,line in enumerate(text.splitlines()) if any(s in line for s in ['web-build', 'build', 'upload', 'checkout', 'inputs.tag_name', 'ref:', 'uses:'])]
        print(f"\n== {p} ==")
        for ln in lines[:220]:
            print(ln)
PY

Repository: iii-hq/workers

Length of output: 11853


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Tracked files under .github:"
git ls-files .github | sed -n '1,200p'

echo
echo "Relevant workflow lines:"
awk 'NR>=140 && NR<=420 {printf "%5d: %s\n", NR, $0}' .github/workflows/_rust-binary.yml

echo
echo "Potential uploaded composite action files:"
git ls-files | rg 'upload-rust|action\.yml|\.yml$|\.yaml$' | rg '(^|/)upload|action\.ya?ml' | sed -n '1,200p'

Repository: iii-hq/workers

Length of output: 13070


🌐 Web query:

taiki-e upload-rust-binary-action v1 action.yml ref inputs composite action

💡 Result:

The taiki-e/upload-rust-binary-action is a composite GitHub Action designed to build and upload Rust binaries to GitHub Releases [1][2]. The action.yml file defines it as a composite action that executes a shell script (main.sh) [1][3]. Regarding the ref input specifically: The ref input is one of the many supported inputs for this action [1]. In the underlying main.sh script, the ref variable is assigned from INPUT_REF (the value provided to the ref input) or defaults to GITHUB_REF [3]. This value is subsequently used to determine the tag for the release, derived via tag="${ref#refs/tags/}" [3]. Key characteristics of the action's action.yml and operation include: - Inputs: The action accepts numerous inputs, such as bin (required), token, archive, target, features, profile, and ref [1][2][3]. - Implementation: It uses runs: using: composite and runs a bash script [1]. - Default Token: It defaults to ${{ github.token }} [1][4]. - List Inputs: Several inputs (like bin, package, include, asset, and checksum) support whitespace- or comma-separated lists [4][5]. For detailed usage, you can refer to the official repository documentation [2][6].

Citations:


🌐 Web query:

github.com taiki-e upload-rust-binary-action v1 main.sh checkout upload tag

💡 Result:

The taiki-e/upload-rust-binary-action is a GitHub Action designed to build Rust binaries and upload them as assets to GitHub Releases [1][2]. The main.sh file serves as the core script for the action's execution [3], which is triggered by the action's composite step definition in action.yml [4]. Regarding your query on checkout, tag, and upload: 1. Checkout: In typical usage, you must include the actions/checkout step before calling this action [1][5]. This ensures the repository code is available for building the binary [1]. 2. Tag: The action identifies the target GitHub Release using the git tag [3]. By default, it uses the GITHUB_REF environment variable to determine the tag [6]. If you need to specify a different tag, the action provides a ref input option [6]. The action uses the GitHub CLI (gh release upload) to upload assets to the release associated with that tag [3]. 3. Upload: The upload process is handled automatically by the action once the build is complete [1]. It supports building and uploading multiple binaries (specified by the bin input) and allows for customization of the archive name using variables like $bin, $target, and $tag [1][2]. Note that this action does not strictly require a manual token input anymore; it defaults to ${{ github.token }} [7][6]. Additionally, ensure your workflow has the necessary permissions (specifically contents: write) to create or upload to releases [1][5].

Citations:


🌐 Web query:

raw.githubusercontent.com taiki-e upload-rust-binary-action v1 main.sh INPUT_REF gh release

💡 Result:

The ref input option in taiki-e/upload-rust-binary-action is used to specify a fully-formed tag reference for a release [1][2]. In the action's main.sh script, the ref variable is initialized using the INPUT_REF environment variable, which corresponds to the ref input provided in a GitHub Actions workflow [3]: ref="${INPUT_REF:-"${GITHUB_REF:-}"}" If INPUT_REF is not explicitly set, the action defaults to using GITHUB_REF [3]. The script then validates that the ref starts with refs/tags/. If it does not, the action will generally terminate with an error (unless running in dry-run mode) because it is designed to support events originating from tags or releases [3]. By specifying the ref input, you can override the default behavior and upload binaries to a specific, arbitrary tag reference (e.g., refs/tags/my_tag) [1][2].

Citations:


Build frontend assets from the release tag.

The workflow checks out the default GITHUB_REF for both web-build and build, while upload-rust-binary is invoked with ref: refs/tags/${{ inputs.tag_name }} and uses that ref only for release lookup. Check out refs/tags/${{ inputs.tag_name }} in both web-build and build so the bundled assets match the tagged Rust source.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/_rust-binary.yml around lines 179 - 187, Update the
checkout steps in both the web-build and build jobs to use refs/tags/${{
inputs.tag_name }} instead of the default GITHUB_REF, ensuring frontend assets
and bundled Rust binaries are built from the same release tag used by
upload-rust-binary.

# Stage a fixed <dir>/dist layout: with a single upload path the
# artifact root is deterministic no matter how many dirs were
# built (multi-path uploads re-root at the common ancestor, which
# would flatten the single-dir case).
mkdir -p /tmp/web-bundle
for d in $WEBDIRS; do
mkdir -p "/tmp/web-bundle/$d"
cp -R "$WORKER/$d/dist" "/tmp/web-bundle/$d/dist"
done

- name: Upload web bundle
uses: actions/upload-artifact@v4
with:
name: web-bundle
path: ${{ steps.dirs.outputs.worker }}/${{ steps.dirs.outputs.webdir }}/dist/
path: /tmp/web-bundle/
if-no-files-found: error
retention-days: 1

Expand Down Expand Up @@ -302,27 +316,43 @@ jobs:
run: |
set -euo pipefail
worker=$(dirname "$MANIFEST")
webdir="web"
[[ ! -f "$worker/web/package.json" && -f "$worker/ui/package.json" ]] && webdir="ui"
echo "worker=$worker" >> "$GITHUB_OUTPUT"
echo "webdir=$webdir" >> "$GITHUB_OUTPUT"

- name: Download web bundle
if: inputs.web_bundle
uses: actions/download-artifact@v4
with:
name: web-bundle
path: ${{ steps.dirs.outputs.worker }}/${{ steps.dirs.outputs.webdir }}/dist/
path: ${{ steps.dirs.outputs.worker }}/.web-bundle/

# The artifact carries a fixed <dir>/dist layout (web/dist, ui/dist —
# whichever the pre-build job produced). Move each into place so the
# worker's build.rs finds every dist it will refuse to build itself.
- name: Place pre-built dist(s)
if: inputs.web_bundle
shell: bash
env:
WORKER: ${{ steps.dirs.outputs.worker }}
run: |
set -euo pipefail
for d in web ui; do
if [[ -d "$WORKER/.web-bundle/$d/dist" ]]; then
rm -rf "$WORKER/$d/dist"
mkdir -p "$WORKER/$d"
mv "$WORKER/.web-bundle/$d/dist" "$WORKER/$d/dist"
fi
done
rm -rf "$WORKER/.web-bundle"

- name: Build and upload binary
uses: taiki-e/upload-rust-binary-action@v1
env:
# Honored by the worker's build.rs: when set, the script trusts
# the dist/ already on disk and never invokes pnpm. The dist comes
# from the `web-build` job's artifact above. `SKIP_WEB_BUILD` is
# console/build.rs (embedded SPA under web/); `SKIP_UI_BUILD` is
# state/build.rs (injected console UI under ui/) — setting both is
# harmless, each build.rs reads only its own.
# the dist/ already on disk and never invokes pnpm. The dists come
# from the `web-build` job's artifact above. `SKIP_WEB_BUILD`
# covers the embedded SPA under web/; `SKIP_UI_BUILD` covers the
# injected console UI under ui/ (console reads both; state only
# the latter) — setting both is always harmless.
SKIP_WEB_BUILD: ${{ inputs.web_bundle && '1' || '' }}
SKIP_UI_BUILD: ${{ inputs.web_bundle && '1' || '' }}
with:
Expand Down
Loading