ci: publish to jsr
This commit is contained in:
parent
86fefbfc02
commit
a4fadc0403
3 changed files with 32 additions and 4 deletions
7
.github/workflows/release.yaml
vendored
7
.github/workflows/release.yaml
vendored
|
@ -27,6 +27,7 @@ jobs:
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
packages: write
|
packages: write
|
||||||
|
id-token: write # The OIDC ID token is used for authentication with JSR.
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
@ -58,6 +59,12 @@ jobs:
|
||||||
GH_RELEASE: 1
|
GH_RELEASE: 1
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: node scripts/publish.js ${{ steps.find.outputs.modified }}
|
run: node scripts/publish.js ${{ steps.find.outputs.modified }}
|
||||||
|
- uses: denoland/setup-deno@v1
|
||||||
|
- name: Build packages and publish to JSR
|
||||||
|
env:
|
||||||
|
JSR: 1
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: node scripts/publish.js ${{ steps.find.outputs.modified }}
|
||||||
- name: Commit version bumps
|
- name: Commit version bumps
|
||||||
run: |
|
run: |
|
||||||
git commit -am "v${{ steps.bump.outputs.version }}"
|
git commit -am "v${{ steps.bump.outputs.version }}"
|
||||||
|
|
|
@ -607,7 +607,7 @@ if (!IS_JSR) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Promise.resolve(buildConfig.final()).then(() => {
|
Promise.resolve(buildConfig.final()).then(() => {
|
||||||
if (IS_JSR) {
|
if (IS_JSR && !process.env.CI) {
|
||||||
console.log('[i] Trying to publish with --dry-run')
|
console.log('[i] Trying to publish with --dry-run')
|
||||||
exec('deno publish --dry-run --allow-dirty --quiet', { cwd: outDir })
|
exec('deno publish --dry-run --allow-dirty --quiet', { cwd: outDir })
|
||||||
console.log('[v] All good!')
|
console.log('[v] All good!')
|
||||||
|
|
|
@ -4,7 +4,7 @@ const cp = require('child_process')
|
||||||
const stc = require('@teidesu/slow-types-compiler')
|
const stc = require('@teidesu/slow-types-compiler')
|
||||||
|
|
||||||
const IS_JSR = process.env.JSR === '1'
|
const IS_JSR = process.env.JSR === '1'
|
||||||
const MAIN_REGISTRY = IS_JSR ? 'http://jsr.test/' : 'https://registry.npmjs.org'
|
const MAIN_REGISTRY = IS_JSR ? 'https://jsr.io/' : 'https://registry.npmjs.org'
|
||||||
let REGISTRY = process.env.REGISTRY || MAIN_REGISTRY
|
let REGISTRY = process.env.REGISTRY || MAIN_REGISTRY
|
||||||
exports.REGISTRY = REGISTRY
|
exports.REGISTRY = REGISTRY
|
||||||
if (!REGISTRY.endsWith('/')) REGISTRY += '/'
|
if (!REGISTRY.endsWith('/')) REGISTRY += '/'
|
||||||
|
@ -97,7 +97,7 @@ async function publishSinglePackage(name) {
|
||||||
if (IS_JSR) {
|
if (IS_JSR) {
|
||||||
// publish to jsr
|
// publish to jsr
|
||||||
const params = process.env.JSR_TOKEN ? `--token ${process.env.JSR_TOKEN}` : ''
|
const params = process.env.JSR_TOKEN ? `--token ${process.env.JSR_TOKEN}` : ''
|
||||||
cp.execSync(`deno publish --allow-dirty ${params}`, {
|
cp.execSync(`deno publish --allow-dirty --quiet ${params}`, {
|
||||||
cwd: path.join(packageDir, 'dist/jsr'),
|
cwd: path.join(packageDir, 'dist/jsr'),
|
||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
})
|
})
|
||||||
|
@ -179,7 +179,28 @@ async function main(arg = process.argv[2]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (const pkg of arg.split(',')) {
|
let pkgs = arg.split(',')
|
||||||
|
|
||||||
|
const deps = {}
|
||||||
|
// determine the order of packages to publish
|
||||||
|
|
||||||
|
for (const pkg of pkgs) {
|
||||||
|
if (IS_JSR && JSR_EXCEPTIONS[pkg] === 'never') continue
|
||||||
|
if (!IS_JSR && JSR_EXCEPTIONS[pkg] === 'only') continue
|
||||||
|
|
||||||
|
if (IS_JSR) {
|
||||||
|
const pkgDeps = require(`../packages/${pkg}/package.json`).dependencies || {}
|
||||||
|
deps[pkg] = Object.keys(pkgDeps)
|
||||||
|
.filter((d) => d.startsWith('@mtcute/'))
|
||||||
|
.map((d) => d.slice(8))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_JSR) {
|
||||||
|
pkgs = stc.determinePublishOrder(deps)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const pkg of pkgs) {
|
||||||
try {
|
try {
|
||||||
await publishSinglePackage(pkg)
|
await publishSinglePackage(pkg)
|
||||||
publishedPkgs.push(pkg)
|
publishedPkgs.push(pkg)
|
||||||
|
|
Loading…
Reference in a new issue