tldraw/scripts/publish-manual.ts
Mitja Bezenšek beb0bca5fe
Uploading the static assets to R2 bucket (#3921)
Uploads all the folders inside `./assets` folder to a new R2 bucket
called `cdn`. Uses the package version as the prefix, so that we can
host multiple versions of the assets.

### Change Type

<!--  Please select a 'Scope' label ️ -->

- [ ] `sdk` — Changes the tldraw SDK
- [ ] `dotcom` — Changes the tldraw.com web app
- [ ] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [x] `internal` — Does not affect user-facing stuff

<!--  Please select a 'Type' label ️ -->

- [ ] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [ ] `improvement` — Improving existing features
- [ ] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [x] `tools` — Changes to infrastructure, CI, internal scripts,
debugging tools, etc.
- [ ] `dunno` — I don't know


### Test Plan

1. Add a step-by-step description of how to test your PR here.
2.

- [ ] Unit Tests
- [ ] End to end tests

### Release Notes

- Upload our static assets (fonts, icons, embed-icons, translations) to
a R2 bucket so that we can move away from using unpkg and start using
our own cdn.
2024-06-14 12:25:42 +00:00

25 lines
944 B
TypeScript

import { appendFileSync } from 'fs'
import { exec } from './lib/exec'
import { getLatestVersion, publish } from './lib/publishing'
import { uploadStaticAssets } from './upload-static-assets'
// This expects the package.json files to be in the correct state.
// You might want to run this locally after a failed publish attempt on CI.
// Or if you need to hotfix a package it might be desirable to run this.
// Generate a npm automation token and run this with the NPM_TOKEN env var set.
async function main() {
const latestVersionInBranch = await getLatestVersion()
const latestVersionOnNpm = (await exec('npm', ['show', 'tldraw', 'version'])).trim()
const isLatestVersion = latestVersionInBranch.format() === latestVersionOnNpm
if (process.env.GITHUB_OUTPUT) {
appendFileSync(process.env.GITHUB_OUTPUT, `is_latest_version=${isLatestVersion}\n`)
}
await uploadStaticAssets(latestVersionInBranch.version)
await publish()
}
main()