Fix publishing (#1338)
Automated package publish had gotten broken because we lost all our git tags/releases. We fixed that, but also: * made releases come from huppy instead of david * swtiched from node's `execSync` to our `exec` for more debuggable output * cleaned up some of the scripts a little this diff has a lot of whitespace changes so you're best off reviewing it with whitespace changes hidden: https://github.com/tldraw/tldraw/pull/1338/files?diff=split&w=1
This commit is contained in:
parent
2a36d6342c
commit
a8910e5491
6 changed files with 90 additions and 74 deletions
9
.github/workflows/publish-canary.yml
vendored
9
.github/workflows/publish-canary.yml
vendored
|
@ -12,6 +12,13 @@ jobs:
|
||||||
runs-on: ubuntu-latest-16-cores-open
|
runs-on: ubuntu-latest-16-cores-open
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: tldraw-repo-sync token
|
||||||
|
id: tldraw-repo-sync
|
||||||
|
uses: getsentry/action-github-app-token@v2
|
||||||
|
with:
|
||||||
|
app_id: ${{ secrets.HUPPY_APP_ID }}
|
||||||
|
private_key: ${{ secrets.HUPPY_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
|
@ -33,5 +40,5 @@ jobs:
|
||||||
- name: Publish Canary Packages
|
- name: Publish Canary Packages
|
||||||
run: yarn tsx ./scripts/publish-canary.ts
|
run: yarn tsx ./scripts/publish-canary.ts
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
9
.github/workflows/publish-manual.yml
vendored
9
.github/workflows/publish-manual.yml
vendored
|
@ -13,6 +13,13 @@ jobs:
|
||||||
runs-on: ubuntu-latest-16-cores-open
|
runs-on: ubuntu-latest-16-cores-open
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: tldraw-repo-sync token
|
||||||
|
id: tldraw-repo-sync
|
||||||
|
uses: getsentry/action-github-app-token@v2
|
||||||
|
with:
|
||||||
|
app_id: ${{ secrets.HUPPY_APP_ID }}
|
||||||
|
private_key: ${{ secrets.HUPPY_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
@ -32,5 +39,5 @@ jobs:
|
||||||
- name: Publish
|
- name: Publish
|
||||||
run: yarn tsx ./scripts/publish-manual.ts
|
run: yarn tsx ./scripts/publish-manual.ts
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
11
.github/workflows/publish-new.yml
vendored
11
.github/workflows/publish-new.yml
vendored
|
@ -15,10 +15,17 @@ jobs:
|
||||||
runs-on: ubuntu-latest-16-cores-open
|
runs-on: ubuntu-latest-16-cores-open
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: tldraw-repo-sync token
|
||||||
|
id: tldraw-repo-sync
|
||||||
|
uses: getsentry/action-github-app-token@v2
|
||||||
|
with:
|
||||||
|
app_id: ${{ secrets.HUPPY_APP_ID }}
|
||||||
|
private_key: ${{ secrets.HUPPY_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GH_TOKEN }}
|
token: ${{ github.token }}
|
||||||
|
|
||||||
- name: Prepare repository
|
- name: Prepare repository
|
||||||
# Fetch full git history and tags for auto
|
# Fetch full git history and tags for auto
|
||||||
|
@ -40,5 +47,5 @@ jobs:
|
||||||
- name: Publish
|
- name: Publish
|
||||||
run: yarn tsx ./scripts/publish-new.ts
|
run: yarn tsx ./scripts/publish-new.ts
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
GH_TOKEN: ${{ github.token }}
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { execSync } from 'child_process'
|
import { exec } from './lib/exec'
|
||||||
import { pathToFileURL } from 'url'
|
|
||||||
import { getLatestVersion, publish, setAllVersions } from './lib/publishing'
|
import { getLatestVersion, publish, setAllVersions } from './lib/publishing'
|
||||||
|
|
||||||
const sha = execSync('git rev-parse --short HEAD').toString().trim()
|
async function main() {
|
||||||
|
const sha = (await exec('git', ['rev-parse', 'HEAD'])).trim().slice(0, 12)
|
||||||
|
|
||||||
async function setCanaryVersions(bump: 'major' | 'minor' | 'patch') {
|
async function setCanaryVersions(bump: 'major' | 'minor' | 'patch') {
|
||||||
const latestVersion = getLatestVersion()
|
const latestVersion = getLatestVersion()
|
||||||
|
|
||||||
const nextVersion = latestVersion.prerelease.length
|
const nextVersion = latestVersion.prerelease.length
|
||||||
|
@ -14,11 +14,10 @@ async function setCanaryVersions(bump: 'major' | 'minor' | 'patch') {
|
||||||
const versionString = `${nextVersion.major}.${nextVersion.minor}.${nextVersion.patch}-canary.${sha}`
|
const versionString = `${nextVersion.major}.${nextVersion.minor}.${nextVersion.patch}-canary.${sha}`
|
||||||
|
|
||||||
setAllVersions(versionString)
|
setAllVersions(versionString)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
||||||
// module was called directly
|
// module was called directly
|
||||||
const bumpType = execSync('auto version').toString().trim() as 'major' | 'minor' | 'patch' | ''
|
const bumpType = (await exec('auto', ['version'])).trim() as 'major' | 'minor' | 'patch' | ''
|
||||||
|
|
||||||
console.log('bumpType', bumpType)
|
console.log('bumpType', bumpType)
|
||||||
if (bumpType === '') {
|
if (bumpType === '') {
|
||||||
|
@ -31,3 +30,5 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||||
throw new Error('Invalid bump type provided')
|
throw new Error('Invalid bump type provided')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
import { pathToFileURL } from 'url'
|
|
||||||
import { publish } from './lib/publishing'
|
import { publish } from './lib/publishing'
|
||||||
|
|
||||||
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
// This expects the package.json files to be in the correct state.
|
||||||
// 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.
|
||||||
// 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.
|
||||||
// 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.
|
// Generate a npm automation token and run this with the NPM_TOKEN env var set.
|
||||||
publish()
|
publish()
|
||||||
}
|
|
||||||
|
|
|
@ -1,25 +1,23 @@
|
||||||
import { Auto } from '@auto-it/core'
|
import { Auto } from '@auto-it/core'
|
||||||
import { execSync } from 'child_process'
|
|
||||||
import { parse } from 'semver'
|
import { parse } from 'semver'
|
||||||
import { pathToFileURL } from 'url'
|
import { exec } from './lib/exec'
|
||||||
import { getLatestVersion, publish, setAllVersions } from './lib/publishing'
|
import { getLatestVersion, publish, setAllVersions } from './lib/publishing'
|
||||||
|
|
||||||
const auto = new Auto({
|
async function main() {
|
||||||
|
const auto = new Auto({
|
||||||
plugins: ['npm'],
|
plugins: ['npm'],
|
||||||
baseBranch: 'main',
|
baseBranch: 'main',
|
||||||
owner: 'tldraw',
|
owner: 'tldraw',
|
||||||
repo: 'tldraw-lite',
|
repo: 'tldraw-lite',
|
||||||
verbose: true,
|
verbose: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
||||||
// module was called directly
|
// module was called directly
|
||||||
const currentBranch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim()
|
const currentBranch = (await exec('git', ['rev-parse', '--abbrev-ref', 'HEAD'])).toString().trim()
|
||||||
if (currentBranch !== 'main') {
|
if (currentBranch !== 'main') {
|
||||||
throw new Error('Must be on main branch to publish')
|
throw new Error('Must be on main branch to publish')
|
||||||
}
|
}
|
||||||
|
|
||||||
;(async () => {
|
|
||||||
await auto.loadConfig()
|
await auto.loadConfig()
|
||||||
const bump = await auto.getVersion()
|
const bump = await auto.getVersion()
|
||||||
if (!bump) {
|
if (!bump) {
|
||||||
|
@ -33,9 +31,7 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||||
|
|
||||||
const [prereleaseTag, prereleaseNumber] = latestVersion.prerelease
|
const [prereleaseTag, prereleaseNumber] = latestVersion.prerelease
|
||||||
if (prereleaseTag && typeof prereleaseNumber !== 'number') {
|
if (prereleaseTag && typeof prereleaseNumber !== 'number') {
|
||||||
throw new Error(
|
throw new Error(`Invalid prerelease format in version ${latestVersion}, expected e.g. -alpha.1`)
|
||||||
`Invalid prerelease format in version ${latestVersion}, expected e.g. -alpha.1`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we're in prerelease mode, don't bump the version, only the prerelease number
|
// if we're in prerelease mode, don't bump the version, only the prerelease number
|
||||||
|
@ -48,7 +44,7 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||||
setAllVersions(nextVersion)
|
setAllVersions(nextVersion)
|
||||||
|
|
||||||
// stage the changes
|
// stage the changes
|
||||||
execSync('git add lerna.json bublic/packages/*/package.json', { stdio: 'inherit' })
|
await exec('git', ['add', 'lerna.json', 'bublic/packages/*/package.json'])
|
||||||
|
|
||||||
// this creates a new commit
|
// this creates a new commit
|
||||||
await auto.changelog({
|
await auto.changelog({
|
||||||
|
@ -57,13 +53,14 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
||||||
})
|
})
|
||||||
|
|
||||||
// create and push a new tag
|
// create and push a new tag
|
||||||
execSync(`git tag -f v${nextVersion}`, { stdio: 'inherit' })
|
await exec('git', ['tag', '-f', `v${nextVersion}`])
|
||||||
execSync('git push --follow-tags', { stdio: 'inherit' })
|
await exec('git', ['push', '--follow-tags'])
|
||||||
|
|
||||||
// create a release on github
|
// create a release on github
|
||||||
await auto.runRelease({ useVersion: nextVersion })
|
await auto.runRelease({ useVersion: nextVersion })
|
||||||
|
|
||||||
// finally, publish the packages [IF THIS STEP FAILS, RUN THE `publish-manual.ts` script locally]
|
// finally, publish the packages [IF THIS STEP FAILS, RUN THE `publish-manual.ts` script locally]
|
||||||
await publish()
|
await publish()
|
||||||
})()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in a new issue