-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
129 additions
and
39 deletions.
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
dist/ | ||
scripts/ |
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,30 @@ | ||
name: Release | ||
|
||
# on: | ||
# workflow_dispatch: | ||
# inputs: | ||
# version: | ||
# description: 'npm version. E.g. "2.0.0"' | ||
# required: true | ||
on: | ||
push: | ||
branches: [zh-release] | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
|
||
- run: npm ci | ||
# - run: ./scripts/release.js ${{ github.event.inputs.version }} | ||
- run: ./scripts/release.js 2.0.0-beta.1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_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,98 @@ | ||
#!/usr/bin/env node | ||
|
||
const exec = require("node:child_process").execSync; | ||
const fs = require("node:fs"); | ||
const path = require("node:path"); | ||
|
||
const exitWithError = (message) => { | ||
console.error(message); | ||
process.exit(1); | ||
}; | ||
|
||
if (!process.env.CI) { | ||
exitWithError("The script should only be run in CI"); | ||
} | ||
|
||
/* | ||
* Check that the git working directory is clean | ||
*/ | ||
if (exec("git status --porcelain").length) { | ||
exitWithError( | ||
"Make sure the git working directory is clean before releasing" | ||
); | ||
} | ||
|
||
/* | ||
* Check that the version is valid. Also extract the dist-tag from the version. | ||
*/ | ||
const [version, distTag] = (() => { | ||
const [, , v] = process.argv; | ||
const match = v.match( | ||
/^(?:[0-9]+\.){2}(?:[0-9]+)(?:-(dev|alpha|beta|rc)\.[0-9]+)?$/ | ||
); | ||
if (!match) { | ||
exitWithError(`Invalid version: ${v || "<empty>"}`); | ||
} | ||
|
||
return [v, match[1] || "latest"]; | ||
})(); | ||
|
||
/* | ||
* Get the current version | ||
*/ | ||
const currentVersion = JSON.parse( | ||
fs.readFileSync("package.json", "utf-8") | ||
).version; | ||
console.log( | ||
`Releasing with version: ${currentVersion} -> ${version} and dist-tag: ${distTag}` | ||
); | ||
|
||
/* | ||
* Update version in CHANGELOG.md | ||
*/ | ||
console.log("Updating CHANGELOG.md and bumping versions"); | ||
const UNRELEASED_PLACEHOLDER = "[Unreleased]"; | ||
fs.writeFileSync( | ||
"CHANGELOG.md", | ||
fs | ||
.readFileSync("CHANGELOG.md", "utf8") | ||
.replace( | ||
`# ${UNRELEASED_PLACEHOLDER}`, | ||
`# ${UNRELEASED_PLACEHOLDER}\n\n# ${version}` | ||
) | ||
); | ||
|
||
/* | ||
* Bump npm versions | ||
*/ | ||
exec("git add CHANGELOG.md"); | ||
exec(`npm version ${version} --workspaces --force`); | ||
exec("git add **/package.json"); | ||
exec(`npm version ${version} --include-workspace-root --force`); | ||
|
||
/* | ||
* Build Quill package | ||
*/ | ||
console.log("Building Quill"); | ||
exec("npm run build:quill"); | ||
|
||
/* | ||
* Publish Quill package | ||
*/ | ||
console.log("Publishing Quill"); | ||
const distFolder = "packages/quill/dist"; | ||
if ( | ||
JSON.parse(fs.readFileSync(path.join(distFolder, "package.json"), "utf-8")) | ||
.version !== version | ||
) { | ||
exitWithError("Version mismatch between package.json and dist/package.json"); | ||
} | ||
exec(`npm publish --tag ${distTag} --dry-run`, { cwd: distFolder }); | ||
|
||
/* | ||
* Create GitHub release | ||
*/ | ||
const prereleaseFlag = distTag === "latest" ? "--latest" : " --prerelease"; | ||
exec( | ||
`gh release create v${version} ${prereleaseFlag} -t "Version ${version}" --draft` | ||
); |
This file was deleted.
Oops, something went wrong.