v0.1.39 #29
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Upload Release to Cloudflare R2 | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Release tag to upload (e.g. v0.1.28)' | |
| required: true | |
| jobs: | |
| upload: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download release assets | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| TAG="${{ github.event.release.tag_name || inputs.tag }}" | |
| mkdir artifacts | |
| gh release download "$TAG" \ | |
| --repo ${{ github.repository }} \ | |
| --dir ./artifacts | |
| echo "Assets:" | |
| ls -lh ./artifacts/ | |
| - name: Upload to Cloudflare R2 | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| AWS_DEFAULT_REGION: auto | |
| run: | | |
| TAG="${{ github.event.release.tag_name || inputs.tag }}" | |
| VERSION="${TAG#v}" | |
| ENDPOINT="https://a851dc5e529a04a83d87176e91cfad51.r2.cloudflarestorage.com" | |
| PUBLIC_BASE="https://pub-e99883270f2047d9a6151090f7da8a5c.r2.dev" | |
| # Upload release zip | |
| for f in ./artifacts/*.zip; do | |
| [ -f "$f" ] || continue | |
| filename=$(basename "$f") | |
| echo "Uploading $filename..." | |
| aws s3 cp "$f" "s3://ai-resource-manager/$TAG/$filename" \ | |
| --endpoint-url "$ENDPOINT" \ | |
| --no-progress | |
| echo "URL: $PUBLIC_BASE/$TAG/$filename" | |
| # Generate latest.json | |
| size=$(stat -c%s "$f") | |
| # Use release published_at if available, else current UTC time | |
| published="${{ github.event.release.published_at }}" | |
| if [ -z "$published" ]; then published=$(date -u +"%Y-%m-%dT%H:%M:%SZ"); fi | |
| node -e " | |
| const fs = require('fs'); | |
| fs.writeFileSync('latest.json', JSON.stringify({ | |
| version: '$VERSION', | |
| tag: '$TAG', | |
| filename: '$filename', | |
| size: $size, | |
| publishedAt: '$published' | |
| }, null, 2)); | |
| " | |
| done | |
| # Upload latest.json (overwrites previous, no-store prevents CDN/client caching) | |
| aws s3 cp latest.json "s3://ai-resource-manager/latest.json" \ | |
| --endpoint-url "$ENDPOINT" \ | |
| --content-type "application/json" \ | |
| --cache-control "no-store" \ | |
| --no-progress | |
| echo "latest.json updated -> $PUBLIC_BASE/latest.json" |