|
| 1 | +name: Upload to S3 |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - '*/agent.json' |
| 8 | + - '*/extension.json' |
| 9 | + - '*/icon.svg' |
| 10 | + - '.github/workflows/**' |
| 11 | + - '*.schema.json' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + name: Build Registry |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Install uv |
| 26 | + uses: astral-sh/setup-uv@v7 |
| 27 | + |
| 28 | + - name: Build registry |
| 29 | + run: uv run --with jsonschema .github/workflows/build_registry.py |
| 30 | + |
| 31 | + - name: Upload artifacts |
| 32 | + uses: actions/upload-artifact@v4 |
| 33 | + with: |
| 34 | + name: registry |
| 35 | + path: dist/ |
| 36 | + |
| 37 | + upload-s3: |
| 38 | + name: Upload to S3 |
| 39 | + needs: build |
| 40 | + runs-on: ubuntu-latest |
| 41 | + |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - name: Download artifacts |
| 46 | + uses: actions/download-artifact@v4 |
| 47 | + with: |
| 48 | + name: registry |
| 49 | + path: dist/ |
| 50 | + |
| 51 | + - name: List dist contents |
| 52 | + run: ls -la dist/ |
| 53 | + |
| 54 | + - name: Configure AWS CLI for R2 |
| 55 | + run: | |
| 56 | + aws configure set aws_access_key_id "${{ secrets.S3_ACCESS_KEY_ID }}" |
| 57 | + aws configure set aws_secret_access_key "${{ secrets.S3_SECRET_ACCESS_KEY }}" |
| 58 | + aws configure set default.region auto |
| 59 | +
|
| 60 | + - name: Generate version string |
| 61 | + id: version |
| 62 | + run: echo "version=v$(date +%Y.%m.%d)-$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT" |
| 63 | + |
| 64 | + - name: Upload versioned snapshot |
| 65 | + env: |
| 66 | + S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }} |
| 67 | + S3_BUCKET: ${{ secrets.S3_BUCKET }} |
| 68 | + run: | |
| 69 | + aws s3 sync dist/ "s3://${S3_BUCKET}/${{ steps.version.outputs.version }}/" \ |
| 70 | + --endpoint-url "${S3_ENDPOINT}" \ |
| 71 | + --cache-control "public, max-age=31536000, immutable" |
| 72 | +
|
| 73 | + - name: Upload to latest |
| 74 | + env: |
| 75 | + S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }} |
| 76 | + S3_BUCKET: ${{ secrets.S3_BUCKET }} |
| 77 | + run: | |
| 78 | + aws s3 sync dist/ "s3://${S3_BUCKET}/latest/" \ |
| 79 | + --endpoint-url "${S3_ENDPOINT}" \ |
| 80 | + --cache-control "public, max-age=300" \ |
| 81 | + --delete |
| 82 | +
|
| 83 | + - name: Print CDN URLs |
| 84 | + env: |
| 85 | + S3_BUCKET: ${{ secrets.S3_BUCKET }} |
| 86 | + run: | |
| 87 | + echo "## Uploaded to S3" >> "$GITHUB_STEP_SUMMARY" |
| 88 | + echo "" >> "$GITHUB_STEP_SUMMARY" |
| 89 | + echo "Versioned: \`${{ steps.version.outputs.version }}/\`" >> "$GITHUB_STEP_SUMMARY" |
| 90 | + echo "Latest: \`latest/\`" >> "$GITHUB_STEP_SUMMARY" |
0 commit comments