mirror of
https://github.com/transloadit/uppy.git
synced 2026-01-22 18:16:26 +00:00
CI: update CDN publish after migration (#6100)
https://github.com/transloadit/api2/blob/main/docs/releases-bucket.md
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Switch CDN publishing from Edgly to S3-compatible Cloudflare R2/Bunny
with new env vars and updated upload script/workflows.
>
> - **CI/CD Workflows**
> - Replace `EDGLY_*` creds with
`AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY` and set `AWS_REGION`,
`S3_BUCKET`, `S3_ENDPOINT` in `manual-cdn.yml` and `release.yml`.
> - Use updated env when running `upload-to-cdn.js` for both normal and
`--force` uploads.
> - **Upload Script (`packages/uppy/upload-to-cdn.js`)**
> - Switch to S3-compatible client targeting Cloudflare R2 (`endpoint`,
`forcePathStyle`) and read bucket/region from env.
> - Validate required env vars (`AWS_ACCESS_KEY_ID`,
`AWS_SECRET_ACCESS_KEY`, `S3_ENDPOINT`, `S3_BUCKET`).
> - Derive version from local `package.json` when uploading local
builds; keep npm tarball path for remote versions.
> - Update comments/paths; remove all `EDGLY_*` references.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
502c3fec3d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
This commit is contained in:
parent
a25226aab2
commit
9b9e698bef
3 changed files with 40 additions and 16 deletions
12
.github/workflows/manual-cdn.yml
vendored
12
.github/workflows/manual-cdn.yml
vendored
|
|
@ -23,6 +23,10 @@ env:
|
|||
jobs:
|
||||
upload:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
AWS_REGION: auto
|
||||
S3_BUCKET: ${{ secrets.S3_BUCKET }}
|
||||
S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v6
|
||||
|
|
@ -63,13 +67,13 @@ jobs:
|
|||
env:
|
||||
PACKAGE: ${{inputs.package}}
|
||||
VERSION: ${{inputs.version}}
|
||||
EDGLY_KEY: ${{secrets.EDGLY_KEY}}
|
||||
EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
- name: Upload "${{ inputs.package }}" to CDN
|
||||
if: ${{ inputs.force }}
|
||||
run: corepack yarn workspace uppy node upload-to-cdn.js "$PACKAGE" "$VERSION" --force
|
||||
env:
|
||||
PACKAGE: ${{inputs.package}}
|
||||
VERSION: ${{inputs.version}}
|
||||
EDGLY_KEY: ${{secrets.EDGLY_KEY}}
|
||||
EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
|
|
|
|||
12
.github/workflows/release.yml
vendored
12
.github/workflows/release.yml
vendored
|
|
@ -11,6 +11,10 @@ jobs:
|
|||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
AWS_REGION: auto
|
||||
S3_BUCKET: ${{ secrets.S3_BUCKET }}
|
||||
S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }}
|
||||
outputs:
|
||||
companionWasReleased: ${{ steps.checkIfCompanionWasReleased.outputs.version }}
|
||||
published: ${{ steps.changesets.outputs.published }}
|
||||
|
|
@ -68,15 +72,15 @@ jobs:
|
|||
if: steps.changesets.outputs.published == 'true'
|
||||
run: node packages/uppy/upload-to-cdn.js uppy
|
||||
env:
|
||||
EDGLY_KEY: ${{secrets.EDGLY_KEY}}
|
||||
EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
|
||||
- name: Upload `@uppy/locales` to CDN if it was released
|
||||
if: steps.changesets.outputs.published == 'true'
|
||||
run: node packages/uppy/upload-to-cdn.js @uppy/locales
|
||||
env:
|
||||
EDGLY_KEY: ${{secrets.EDGLY_KEY}}
|
||||
EDGLY_SECRET: ${{secrets.EDGLY_SECRET}}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
|
||||
|
||||
# See also companion-deploy.yml
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// Upload Uppy releases to tlcdn.com (CDN). Copyright (c) 2018, Transloadit Ltd.
|
||||
// Upload Uppy releases to releases.transloadit.com via Cloudflare R2/BunnyCDN.
|
||||
//
|
||||
// This file:
|
||||
//
|
||||
// - Assumes EDGLY_KEY and EDGLY_SECRET are available (e.g. set via Travis secrets)
|
||||
// - Assumes the following env vars are available: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
|
||||
// AWS_REGION=auto, S3_ENDPOINT, S3_BUCKET (see the CDN migration docs for the exact values).
|
||||
// - Assumes a fully built uppy is in root dir (unless a specific tag was specified, then it's fetched from npm)
|
||||
// - Collects dist/ files that would be in an npm package release, and uploads to
|
||||
// eg. https://releases.transloadit.com/uppy/v1.0.1/uppy.css
|
||||
|
|
@ -45,8 +46,8 @@ function delay(ms) {
|
|||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
const AWS_REGION = 'us-east-1'
|
||||
const AWS_BUCKET = 'releases.transloadit.com'
|
||||
const AWS_REGION = process.env.AWS_REGION ?? 'auto'
|
||||
const AWS_BUCKET = process.env.S3_BUCKET
|
||||
|
||||
/**
|
||||
* Get remote dist/ files by fetching the tarball for the given version
|
||||
|
|
@ -130,8 +131,20 @@ async function main(packageName, version) {
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
if (!process.env.EDGLY_KEY || !process.env.EDGLY_SECRET) {
|
||||
console.error('Missing EDGLY_KEY or EDGLY_SECRET env variables, bailing')
|
||||
const requiredEnvVars = [
|
||||
'AWS_ACCESS_KEY_ID',
|
||||
'AWS_SECRET_ACCESS_KEY',
|
||||
'S3_ENDPOINT',
|
||||
'S3_BUCKET',
|
||||
]
|
||||
const missingEnvVars = requiredEnvVars.filter(
|
||||
(envVar) => !process.env[envVar],
|
||||
)
|
||||
|
||||
if (missingEnvVars.length > 0) {
|
||||
console.error(
|
||||
`Missing required env variables (${missingEnvVars.join(', ')}), bailing`,
|
||||
)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
|
|
@ -142,10 +155,13 @@ async function main(packageName, version) {
|
|||
|
||||
const s3Client = new S3Client({
|
||||
credentials: {
|
||||
accessKeyId: process.env.EDGLY_KEY,
|
||||
secretAccessKey: process.env.EDGLY_SECRET,
|
||||
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
||||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
||||
},
|
||||
region: AWS_REGION,
|
||||
endpoint: process.env.S3_ENDPOINT,
|
||||
// Cloudflare R2 requires path-style addressing when using the account endpoint.
|
||||
forcePathStyle: true,
|
||||
})
|
||||
|
||||
const remote = !!resolvedVersion
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue