-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Needs to be tested by being merged as this will run on GitHub Actions.
- Loading branch information
1 parent
39d403f
commit 28ab75e
Showing
7 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Publish Packages to NPM | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- uses: oven-sh/setup-bun@v1 | ||
|
||
- run: bun install | ||
|
||
# update npm for provenance support | ||
- run: npm --version && npm install -g npm && npm --version | ||
|
||
# make extra sure this publish wouldn’t break anything | ||
- run: bun run build check test | ||
|
||
- name: publish | ||
run: bun internals/scripts/source/publish.ts | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"dependencies": { | ||
"zod": "^3.22.5" | ||
}, | ||
"name": "@skyblock-finance/scripts", | ||
"private": true, | ||
"scripts": { | ||
"check:eslint": "bun run eslint --max-warnings=0 .", | ||
"check:prettier": "bun --bun run --cwd ../.. prettier --check internals/scripts", | ||
"fix:eslint": "bun run check:eslint --fix", | ||
"fix:prettier": "bun --bun run check:prettier --write" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { $, semver } from 'bun' | ||
import { z } from 'zod' | ||
|
||
const packagesToConsider = ['packages/schemas'] | ||
|
||
const packageJsonSchema = z.object({ name: z.string(), version: z.string() }) | ||
|
||
const getRemoteVersion = async (name: string): Promise<string | null> => { | ||
try { | ||
return await $`npm view ${name} version`.text() | ||
} catch { | ||
return null | ||
} | ||
} | ||
|
||
const toPublish: string[] = [] | ||
|
||
for (const path of packagesToConsider) { | ||
const { name, version } = packageJsonSchema.parse( | ||
await Bun.file(`./${path}/package.json`).json(), | ||
) | ||
const remoteVersion = await getRemoteVersion(name) | ||
|
||
console.info( | ||
`${path}: found package “${name}@${version}”, remote is ${remoteVersion ?? 'LIKELY UNPUBLISHED'}`, | ||
) | ||
|
||
const shouldPublish = | ||
remoteVersion === null || semver.order(version, remoteVersion) === 1 | ||
if (!shouldPublish) { | ||
console.info(`${path}: already up-to-date, skipping`) | ||
continue | ||
} | ||
|
||
console.info(`${path}: scheduled for publishing`) | ||
toPublish.push(name) | ||
} | ||
|
||
if (toPublish.length === 0) { | ||
console.warn(`nothing to publish, exiting.`) | ||
process.exit(0) | ||
} | ||
|
||
console.info(`attempting to publish ${toPublish.join(', ')}`) | ||
|
||
await $`turbo run publish-package --continue ${toPublish.map((packageName) => `--filter=${packageName}`).join(' ')}` |
This file contains 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
This file contains 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
This file contains 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