706d282681
- Upload APK as a GitHub prerelease asset for direct .apk download (no zip wrapping like artifacts) - Remove commit comment, only comment on open PRs - Clean up existing release with same tag before creating https://claude.ai/code/session_0138kUcZaPQoQcAc7nA1KDbf
118 lines
3.8 KiB
YAML
118 lines
3.8 KiB
YAML
name: Build Benchmark APK
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'claude/**'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build-benchmark:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@v5
|
|
with:
|
|
distribution: 'zulu'
|
|
java-version: 21
|
|
|
|
- name: Cache gradle
|
|
uses: actions/cache@v5
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-
|
|
|
|
- name: Build Benchmark APK
|
|
run: ./gradlew assemblePlayBenchmark
|
|
|
|
- name: Upload APK to prerelease
|
|
id: upload
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const fs = require('fs');
|
|
const apkPath = 'amethyst/build/outputs/apk/play/benchmark/amethyst-play-universal-benchmark.apk';
|
|
const sha = context.sha.substring(0, 7);
|
|
const tag = `benchmark-${sha}`;
|
|
|
|
// Delete existing release with this tag if it exists
|
|
try {
|
|
const { data: existing } = await github.rest.repos.getReleaseByTag({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
tag
|
|
});
|
|
await github.rest.repos.deleteRelease({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
release_id: existing.id
|
|
});
|
|
await github.rest.git.deleteRef({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
ref: `tags/${tag}`
|
|
});
|
|
} catch (e) {
|
|
// Release doesn't exist yet, that's fine
|
|
}
|
|
|
|
const { data: release } = await github.rest.repos.createRelease({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
tag_name: tag,
|
|
target_commitish: context.sha,
|
|
name: `Benchmark APK (${sha})`,
|
|
body: `Auto-generated benchmark APK for commit ${context.sha}`,
|
|
prerelease: true
|
|
});
|
|
|
|
const apkData = fs.readFileSync(apkPath);
|
|
const { data: asset } = await github.rest.repos.uploadReleaseAsset({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
release_id: release.id,
|
|
name: 'amethyst-play-universal-benchmark.apk',
|
|
data: apkData,
|
|
headers: {
|
|
'content-type': 'application/vnd.android.package-archive',
|
|
'content-length': apkData.length
|
|
}
|
|
});
|
|
|
|
core.setOutput('apk-url', asset.browser_download_url);
|
|
|
|
- name: Comment on PR with APK link
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const apkUrl = `${{ steps.upload.outputs.apk-url }}`;
|
|
const body = `📦 **Benchmark APK ready!**\n\nDownload: [Play Benchmark APK](${apkUrl})`;
|
|
|
|
const branch = context.ref.replace('refs/heads/', '');
|
|
const { data: prs } = await github.rest.pulls.list({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
head: `${context.repo.owner}:${branch}`,
|
|
state: 'open'
|
|
});
|
|
|
|
for (const pr of prs) {
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: pr.number,
|
|
body
|
|
});
|
|
}
|