-
Notifications
You must be signed in to change notification settings - Fork 59
ci: build release SDKs and NPM packages on self-hosted runners #4562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v4.2-dev
Are you sure you want to change the base?
Changes from 1 commit
00f4071
b7fc7a0
18d9cb6
f9723d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -37,7 +37,14 @@ on: | |||||||||||||
| jobs: | ||||||||||||||
| build-and-release: | ||||||||||||||
| name: Build release AAR (arm64-v8a + x86_64) | ||||||||||||||
| runs-on: ubuntu-24.04 | ||||||||||||||
| # Same persistent runner as kotlin-sdk-build.yml, so the multi-hour | ||||||||||||||
| # cargo/NDK build reuses its warm ~/.cargo and target/ caches instead of | ||||||||||||||
| # building cold on a hosted runner. No fork PR guard is needed here: the | ||||||||||||||
| # workflow only triggers on release/workflow_dispatch (via release.yml), | ||||||||||||||
| # never on pull_request. The maven-central-deploy job below deliberately | ||||||||||||||
| # stays on a hosted runner so the environment-scoped publishing secrets | ||||||||||||||
| # never touch the persistent machine. | ||||||||||||||
| runs-on: [self-hosted, kotlin-ci] | ||||||||||||||
| timeout-minutes: 180 | ||||||||||||||
| permissions: | ||||||||||||||
| contents: write # attach the AAR to the platform release | ||||||||||||||
|
|
@@ -58,6 +65,29 @@ jobs: | |||||||||||||
| sha: ${{ steps.resolve-sha.outputs.sha }} | ||||||||||||||
|
|
||||||||||||||
| steps: | ||||||||||||||
| # Same idempotent host check as kotlin-sdk-build.yml, plus gh (used by | ||||||||||||||
| # the tag validation below and preinstalled only on hosted images). Runs | ||||||||||||||
| # before checkout so the validation step can rely on gh. | ||||||||||||||
| - name: Ensure runner dependencies | ||||||||||||||
| run: | | ||||||||||||||
| set -euo pipefail | ||||||||||||||
|
|
||||||||||||||
| MISSING=() | ||||||||||||||
| for pkg in build-essential cmake curl gh jq libgmp-dev libpulse0 libssl-dev libx11-xcb1 pkg-config python3 unzip zip; do | ||||||||||||||
| dpkg -s "$pkg" >/dev/null 2>&1 || MISSING+=("$pkg") | ||||||||||||||
| done | ||||||||||||||
| if [ ${#MISSING[@]} -gt 0 ]; then | ||||||||||||||
| echo "Installing: ${MISSING[*]}" | ||||||||||||||
| sudo apt-get update -qq | ||||||||||||||
| sudo apt-get install -qq --yes "${MISSING[@]}" | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| if [ ! -x "$HOME/.cargo/bin/rustup" ]; then | ||||||||||||||
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ | ||||||||||||||
| | sh -s -- -y --no-modify-path --default-toolchain none | ||||||||||||||
| fi | ||||||||||||||
| echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" | ||||||||||||||
|
|
||||||||||||||
| # A workflow_dispatch `tag` input is free-form and actions/checkout would | ||||||||||||||
| # happily resolve it to a BRANCH (or any ref). Normalize and validate it | ||||||||||||||
| # here — reject anything that is not an existing platform release tag | ||||||||||||||
|
|
@@ -124,21 +154,30 @@ jobs: | |||||||||||||
| # raw dispatch input — so the released AAR is built from the tag's | ||||||||||||||
| # commit and a manual run can never build from a branch. | ||||||||||||||
| ref: ${{ steps.release-ref.outputs.checkout_ref }} | ||||||||||||||
| clean: false | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: printf '%s\n' '--- relevant repository conventions ---'
for f in /tmp/coderabbit-repo-knowledge/dashpay-platform-41d19c18/*/*.md; do
case "$f" in
*/learnings/*|*/architecture/*) continue ;;
*) printf '%s\n' "### $f"; head -80 "$f" ;;
esac
done
printf '%s\n' '--- workflow files ---'
cat -n .github/workflows/release-kotlin-sdk.yml | sed -n '125,180p'
cat -n .github/workflows/release-swift-sdk.yml | sed -n '80,135p'
printf '%s\n' '--- release workflow runner and cleanup references ---'
rg -n -C 4 'runs-on|actions/checkout|clean:|persist-credentials|rm -rf|\.git|hooks|self-hosted|pull_request|permissions' \
.github/workflows/release-kotlin-sdk.yml .github/workflows/release-swift-sdk.ymlRepository: dashpay/platform Length of output: 30411 🌐 Web query:
💡 Result: In Citations:
Other (CWE-269): Improper Privilege Management Reachability: Internal · Exploitability: Moderate Remove persisted Git metadata before the credentialed checkout.
🧰 Tools🪛 zizmor (1.29.0)[warning] 150-161: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) 📍 Affects 2 files
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| # Release from a tree that is exactly the tag's content plus the | ||||||||||||||
| # persistent Cargo target cache: stale jniLibs or gradle outputs from an | ||||||||||||||
| # earlier dev build on this runner must never leak into a release AAR. | ||||||||||||||
| - name: Clean working directory while preserving Rust build cache | ||||||||||||||
| run: | | ||||||||||||||
| git reset --hard HEAD | ||||||||||||||
| git clean -ffdx \ | ||||||||||||||
| -e target/ \ | ||||||||||||||
| -e target/** | ||||||||||||||
|
Comment on lines
+165
to
+167
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Blocking: Quote the cache exclusion so cleanup covers the working tree When target/ contains multiple entries, Bash expands the unquoted target/** before invoking Git. For example, target/debug and target/release produce
Suggested change
source: ['claude'] |
||||||||||||||
|
|
||||||||||||||
| - name: Resolve built commit SHA | ||||||||||||||
| id: resolve-sha | ||||||||||||||
| run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" | ||||||||||||||
|
|
||||||||||||||
| - name: Free disk space | ||||||||||||||
| - name: Verify JDK 17 | ||||||||||||||
| run: | | ||||||||||||||
| sudo rm -rf /usr/share/dotnet /usr/local/lib/android/sdk/ndk /opt/ghc | ||||||||||||||
| df -h / | ||||||||||||||
|
|
||||||||||||||
| - name: Set up JDK 17 | ||||||||||||||
| uses: actions/setup-java@v4 | ||||||||||||||
| with: | ||||||||||||||
| distribution: temurin | ||||||||||||||
| java-version: '17' | ||||||||||||||
| JAVA_HOME_RESOLVED=$(dirname "$(dirname "$(readlink -f "$(command -v java)")")") | ||||||||||||||
| JAVA_VERSION_OUTPUT=$("$JAVA_HOME_RESOLVED/bin/java" -version 2>&1) | ||||||||||||||
| printf '%s\n' "$JAVA_VERSION_OUTPUT" | ||||||||||||||
| printf '%s\n' "$JAVA_VERSION_OUTPUT" | grep -Eq 'version "17([.]|\")' | ||||||||||||||
| echo "JAVA_HOME=$JAVA_HOME_RESOLVED" >> "$GITHUB_ENV" | ||||||||||||||
| echo "$JAVA_HOME_RESOLVED/bin" >> "$GITHUB_PATH" | ||||||||||||||
|
|
||||||||||||||
| - name: Set up Android SDK | ||||||||||||||
| uses: android-actions/setup-android@v3 | ||||||||||||||
|
|
@@ -153,26 +192,33 @@ jobs: | |||||||||||||
| with: | ||||||||||||||
| targets: aarch64-linux-android,x86_64-linux-android | ||||||||||||||
|
|
||||||||||||||
| - name: Restore cargo cache | ||||||||||||||
| uses: actions/cache@v4 | ||||||||||||||
| with: | ||||||||||||||
| path: | | ||||||||||||||
| ~/.cargo/registry | ||||||||||||||
| ~/.cargo/git | ||||||||||||||
| target | ||||||||||||||
| key: kotlin-sdk-release-cargo-${{ hashFiles('**/Cargo.lock') }} | ||||||||||||||
| restore-keys: | | ||||||||||||||
| kotlin-sdk-release-cargo- | ||||||||||||||
| kotlin-sdk-cargo- | ||||||||||||||
|
|
||||||||||||||
| - name: Install cargo-ndk | ||||||||||||||
| run: cargo install cargo-ndk --locked | ||||||||||||||
|
|
||||||||||||||
| - name: Install protoc v32.0 (repo-standard; apt's 3.21 breaks tenderdash-proto) | ||||||||||||||
| # No actions/cache here: the persistent runner keeps ~/.cargo and the | ||||||||||||||
| # Cargo target/ directory between runs, same as kotlin-sdk-build.yml. | ||||||||||||||
|
|
||||||||||||||
| # Pinned: this runner is persistent, so an unpinned `cargo install` | ||||||||||||||
| # leaves whatever version happened to be current on the day it first ran, | ||||||||||||||
| # and every later job silently builds with it. Assert after installing so | ||||||||||||||
| # a drifted host fails here instead of somewhere in the NDK build. | ||||||||||||||
| - name: Ensure cargo-ndk v4.1.2 is installed | ||||||||||||||
| run: | | ||||||||||||||
| curl -fsSL -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v32.0/protoc-32.0-linux-x86_64.zip | ||||||||||||||
| sudo unzip -o /tmp/protoc.zip -d /usr/local 'bin/protoc' 'include/*' | ||||||||||||||
| set -euo pipefail | ||||||||||||||
| if ! cargo ndk --version 2>/dev/null | grep -qx 'cargo-ndk 4.1.2'; then | ||||||||||||||
| cargo install cargo-ndk --version 4.1.2 --locked --force | ||||||||||||||
| fi | ||||||||||||||
| cargo ndk --version | ||||||||||||||
| cargo ndk --version | grep -qx 'cargo-ndk 4.1.2' | ||||||||||||||
|
|
||||||||||||||
| - name: Ensure protoc v32.0 is installed (repo-standard; apt's 3.21 breaks tenderdash-proto) | ||||||||||||||
| run: | | ||||||||||||||
| set -euo pipefail | ||||||||||||||
| if ! protoc --version 2>/dev/null | grep -qx 'libprotoc 32.0'; then | ||||||||||||||
| curl -fsSL -o /tmp/protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v32.0/protoc-32.0-linux-x86_64.zip | ||||||||||||||
| sudo unzip -o /tmp/protoc.zip -d /usr/local 'bin/protoc' 'include/*' | ||||||||||||||
| fi | ||||||||||||||
| protoc --version | ||||||||||||||
| # A stale protoc earlier on PATH would shadow the one just unpacked | ||||||||||||||
| # into /usr/local; catch that here rather than in a codegen failure. | ||||||||||||||
| protoc --version | grep -qx 'libprotoc 32.0' | ||||||||||||||
|
|
||||||||||||||
| - name: Build native library (both ABIs, release profile) | ||||||||||||||
| working-directory: packages/kotlin-sdk | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Blocking: Keep release-write credentials off the shared PR runners
This moves a contents: write job onto the persistent runner used by kotlin-sdk-build.yml, whose guard admits same-repository PRs and the thepastaclaw fork. Code or a compromised dependency executed in an admitted PR can persist a Git hook, Gradle initialization script, or modified user-local executable and execute again during a subsequent release. That execution can access the release token: the job explicitly supplies GH_TOKEN to several steps, and checkout also makes Git credentials available during the job. The later git reset/git clean does not sanitize .git/hooks or the runner's home directory. release-swift-sdk.yml:37–42 has the same exposure. This grants release-writing authority beyond the acknowledged acceptance of shared build-cache integrity. Use isolated release runners, or move credentialed attachment to a fresh hosted job; independently validate builder-provided checkout SHAs before executing them in privileged downstream jobs. Setting persist-credentials: false alone does not close this boundary.
source: ['claude', 'codex']