Repository navigation
feat: turn android host shell into real swarm node host #3
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
Changes from all commits
0205abb
66a4ca3
161ac55
f0afeaf
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 |
|---|---|---|
|
|
@@ -7,17 +7,34 @@ on: | |
| workflow_dispatch: | ||
| inputs: | ||
| gomtm_swarm_aar_url: | ||
| description: Optional direct download URL for a gomtm swarm AAR | ||
| description: GitHub API asset URL for gomtm-swarm-android.aar | ||
| required: false | ||
| type: string | ||
| gomtm_swarm_metadata_url: | ||
| description: GitHub API asset URL for gomtm-swarm-android.json | ||
| required: false | ||
| type: string | ||
| gomtm_swarm_aar_version: | ||
| description: Version string for the pinned gomtm swarm AAR | ||
| required: false | ||
| type: string | ||
| gomtm_swarm_aar_sha256: | ||
| description: SHA256 for the pinned gomtm swarm AAR | ||
| required: false | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| env: | ||
| RELEASE_TAG: v0.2.${{ github.run_number }} | ||
| RELEASE_TAG: v0.3.${{ github.run_number }} | ||
| GOMTM_SWARM_AAR_URL: ${{ inputs.gomtm_swarm_aar_url || vars.GOMTM_SWARM_AAR_URL }} | ||
| GOMTM_SWARM_AAR_NAME: ${{ vars.GOMTM_SWARM_AAR_NAME || 'gomtm-swarm-android.aar' }} | ||
| GOMTM_SWARM_METADATA_URL: ${{ inputs.gomtm_swarm_metadata_url || vars.GOMTM_SWARM_METADATA_URL }} | ||
| GOMTM_SWARM_AAR_VERSION: ${{ inputs.gomtm_swarm_aar_version || vars.GOMTM_SWARM_AAR_VERSION }} | ||
| GOMTM_SWARM_AAR_SHA256: ${{ inputs.gomtm_swarm_aar_sha256 || vars.GOMTM_SWARM_AAR_SHA256 }} | ||
| GOMTM_SWARM_AAR_NAME: gomtm-swarm-android.aar | ||
| GH_FALLBACK_TOKEN: ${{ github.token }} | ||
| GOMTM_RELEASE_TOKEN: ${{ secrets.GOMTM_GH_PAT }} | ||
|
Comment on lines
29
to
+37
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. 🧩 Analysis chain🌐 Web query:
💡 Result: Yes, later build steps can access a repo-write token via the environment if the job has contents: write permission and the workflow-level env exposes github.token (e.g., env: GITHUB_TOKEN: ${{ github.token }}). The github.token context provides the GITHUB_TOKEN value, which inherits the job's permissions, including contents: write for repo writes like git push or API updates. Setting it in workflow-level env makes the variable available to all steps in all jobs. Steps can then use Citations:
🏁 Script executed: cat -n .github/workflows/release.ymlRepository: codeh007/gomtm-android Length of output: 5964 Move repo-write tokens to the step that needs them.
Suggested fix env:
RELEASE_TAG: v0.3.${{ github.run_number }}
GOMTM_SWARM_AAR_URL: ${{ inputs.gomtm_swarm_aar_url || vars.GOMTM_SWARM_AAR_URL }}
GOMTM_SWARM_METADATA_URL: ${{ inputs.gomtm_swarm_metadata_url || vars.GOMTM_SWARM_METADATA_URL }}
GOMTM_SWARM_AAR_VERSION: ${{ inputs.gomtm_swarm_aar_version || vars.GOMTM_SWARM_AAR_VERSION }}
GOMTM_SWARM_AAR_SHA256: ${{ inputs.gomtm_swarm_aar_sha256 || vars.GOMTM_SWARM_AAR_SHA256 }}
GOMTM_SWARM_AAR_NAME: gomtm-swarm-android.aar
- GH_FALLBACK_TOKEN: ${{ github.token }}
- GOMTM_RELEASE_TOKEN: ${{ secrets.GOMTM_GH_PAT }}
- name: Download pinned gomtm swarm AAR and metadata
+ env:
+ GH_FALLBACK_TOKEN: ${{ github.token }}
+ GOMTM_RELEASE_TOKEN: ${{ secrets.GOMTM_GH_PAT }}
shell: bash🤖 Prompt for AI Agents |
||
|
|
||
| jobs: | ||
| release: | ||
|
|
@@ -27,19 +44,46 @@ jobs: | |
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Prepare optional gomtm swarm AAR | ||
| - name: Validate gomtm swarm AAR contract | ||
| shell: bash | ||
| run: | | ||
| mkdir -p app/libs | ||
| if [ -z "${GOMTM_SWARM_AAR_URL}" ]; then | ||
| echo "No gomtm swarm AAR configured; releasing the public host shell without a bound runtime." | ||
| exit 0 | ||
| fi | ||
| test -n "${GOMTM_SWARM_AAR_URL}" || { echo "Missing GOMTM_SWARM_AAR_URL"; exit 1; } | ||
| test -n "${GOMTM_SWARM_METADATA_URL}" || { echo "Missing GOMTM_SWARM_METADATA_URL"; exit 1; } | ||
| test -n "${GOMTM_SWARM_AAR_VERSION}" || { echo "Missing GOMTM_SWARM_AAR_VERSION"; exit 1; } | ||
| test -n "${GOMTM_SWARM_AAR_SHA256}" || { echo "Missing GOMTM_SWARM_AAR_SHA256"; exit 1; } | ||
|
|
||
| target="app/libs/${GOMTM_SWARM_AAR_NAME:-gomtm-swarm-android.aar}" | ||
| echo "Downloading optional gomtm swarm AAR to ${target}" | ||
| curl -fL --retry 3 --retry-all-errors "${GOMTM_SWARM_AAR_URL}" -o "${target}" | ||
| ls -lh app/libs | ||
| - name: Download pinned gomtm swarm AAR and metadata | ||
| shell: bash | ||
| run: | | ||
| mkdir -p app/libs dist | ||
| auth_token="${GOMTM_RELEASE_TOKEN:-${GH_FALLBACK_TOKEN}}" | ||
| curl -fsSL -H "Authorization: Bearer ${auth_token}" -H "Accept: application/octet-stream" "${GOMTM_SWARM_AAR_URL}" -o "app/libs/${GOMTM_SWARM_AAR_NAME}" | ||
| curl -fsSL -H "Authorization: Bearer ${auth_token}" -H "Accept: application/octet-stream" "${GOMTM_SWARM_METADATA_URL}" -o "dist/gomtm-swarm-android.json" | ||
| echo "${GOMTM_SWARM_AAR_SHA256} app/libs/${GOMTM_SWARM_AAR_NAME}" | sha256sum --check --strict --status | ||
| python - <<'PY' | ||
| import json | ||
| import os | ||
| from pathlib import Path | ||
| meta = json.loads(Path('dist/gomtm-swarm-android.json').read_text()) | ||
| expected_version = os.environ['GOMTM_SWARM_AAR_VERSION'] | ||
| expected_sha = os.environ['GOMTM_SWARM_AAR_SHA256'] | ||
| if meta.get('artifact') != 'gomtm-swarm-android.aar': | ||
| raise SystemExit(f"unexpected artifact: {meta.get('artifact')}") | ||
| if meta.get('version') != expected_version: | ||
| raise SystemExit(f"metadata version mismatch: {meta.get('version')} != {expected_version}") | ||
| if meta.get('sha256') != expected_sha: | ||
| raise SystemExit(f"metadata sha256 mismatch: {meta.get('sha256')} != {expected_sha}") | ||
| provenance = { | ||
| 'gomtm_swarm_aar_url': os.environ['GOMTM_SWARM_AAR_URL'], | ||
| 'gomtm_swarm_aar_version': expected_version, | ||
| 'gomtm_swarm_aar_sha256': expected_sha, | ||
| 'gomtm_swarm_metadata_url': os.environ['GOMTM_SWARM_METADATA_URL'], | ||
| 'release_tag': os.environ['RELEASE_TAG'], | ||
| 'git_commit': os.environ['GITHUB_SHA'], | ||
| } | ||
| Path('dist/gomtm-android-provenance.json').write_text(json.dumps(provenance, indent=2) + '\n') | ||
| PY | ||
| ls -lh app/libs dist | ||
|
|
||
| - name: Set up Java 17 | ||
| uses: actions/setup-java@v4 | ||
|
|
@@ -68,10 +112,13 @@ jobs: | |
| tag_name: ${{ env.RELEASE_TAG }} | ||
| name: ${{ env.RELEASE_TAG }} | ||
| body: | | ||
| Public gomtm-android release. | ||
| gomtm-android release built from a pinned gomtm swarm AAR. | ||
|
|
||
| Integration mode: | ||
| - with configured gomtm swarm AAR: bound runtime host | ||
| - without configured gomtm swarm AAR: public host shell only | ||
| files: app/build/outputs/apk/release/app-release-unsigned.apk | ||
| gomtm AAR provenance: | ||
| - version: ${{ env.GOMTM_SWARM_AAR_VERSION }} | ||
| - url: ${{ env.GOMTM_SWARM_AAR_URL }} | ||
| - sha256: ${{ env.GOMTM_SWARM_AAR_SHA256 }} | ||
| files: | | ||
| app/build/outputs/apk/release/app-release-unsigned.apk | ||
| dist/gomtm-android-provenance.json | ||
|
Comment on lines
+121
to
+123
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C3 'assembleRelease|app-release-unsigned\.apk' .github/workflows/release.yml
build_file="$(fd 'build.gradle.kts$' app | head -n1)"
[ -n "$build_file" ]
rg -n -C5 'signingConfigs|buildTypes|release' "$build_file"Repository: codeh007/gomtm-android Length of output: 960 🏁 Script executed: fd 'build.gradle.kts$' app | head -n1 | xargs cat -nRepository: codeh007/gomtm-android Length of output: 1847 Publish a signed APK here, not
🤖 Prompt for AI Agents |
||
| fail_on_unmatched_files: true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,4 @@ | ||
| Place optional prebuilt gomtm swarm AAR artifacts here. | ||
| GitHub Actions downloads the pinned `gomtm-swarm-android.aar` into this directory before Gradle runs. | ||
|
|
||
| Expected direction: | ||
| - `gomtm` produces the Android swarm AAR | ||
| - `gomtm-android` consumes it from `app/libs/` during CI or release builds | ||
|
|
||
| This directory is intentionally kept in-repo so GitHub Actions can download the AAR here before Gradle runs. | ||
| Do not commit secrets or unrelated binaries. | ||
| This repo does not treat local or ad-hoc AAR files as the public source of truth. | ||
| The public truth is the published gomtm Android swarm AAR release asset plus its pinned SHA256. |
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.
Keep the cross-repo token off the PR build steps.
GOMTM_RELEASE_TOKENis defined at workflow scope, so every later step — including the Gradle commands that run pull-request code — inherits it. That makes the cross-repo credential exfiltrable from a same-repo PR. Scope both tokens to the download step only.Suggested fix
env: GOMTM_SWARM_AAR_URL: ${{ inputs.gomtm_swarm_aar_url || vars.GOMTM_SWARM_AAR_URL }} GOMTM_SWARM_METADATA_URL: ${{ inputs.gomtm_swarm_metadata_url || vars.GOMTM_SWARM_METADATA_URL }} GOMTM_SWARM_AAR_VERSION: ${{ inputs.gomtm_swarm_aar_version || vars.GOMTM_SWARM_AAR_VERSION }} GOMTM_SWARM_AAR_SHA256: ${{ inputs.gomtm_swarm_aar_sha256 || vars.GOMTM_SWARM_AAR_SHA256 }} GOMTM_SWARM_AAR_NAME: gomtm-swarm-android.aar - GH_FALLBACK_TOKEN: ${{ github.token }} - GOMTM_RELEASE_TOKEN: ${{ secrets.GOMTM_GH_PAT }} - name: Download pinned gomtm swarm AAR and metadata + env: + GH_FALLBACK_TOKEN: ${{ github.token }} + GOMTM_RELEASE_TOKEN: ${{ secrets.GOMTM_GH_PAT }} shell: bash🤖 Prompt for AI Agents