Merge pull request #2437 from alixander/release-d2js
ci release include d2js
This commit is contained in:
commit
2e158c203d
6 changed files with 105 additions and 17 deletions
2
.github/workflows/daily.yml
vendored
2
.github/workflows/daily.yml
vendored
|
|
@ -51,7 +51,7 @@ jobs:
|
||||||
|
|
||||||
- name: Publish nightly version to NPM
|
- name: Publish nightly version to NPM
|
||||||
if: steps.check_changes.outputs.has_changes == 'true'
|
if: steps.check_changes.outputs.has_changes == 'true'
|
||||||
run: COLOR=1 PUBLISH=1 ./make.sh js
|
run: COLOR=1 NPM_VERSION=nightly ./make.sh js
|
||||||
env:
|
env:
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN }}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
[](https://github.com/terrastruct/d2/actions/workflows/ci.yml)
|
[](https://github.com/terrastruct/d2/actions/workflows/ci.yml)
|
||||||
[](https://github.com/terrastruct/d2/actions/workflows/daily.yml)
|
[](https://github.com/terrastruct/d2/actions/workflows/daily.yml)
|
||||||
[](https://github.com/terrastruct/d2/releases)
|
[](https://github.com/terrastruct/d2/releases)
|
||||||
|
[](./CHANGELOG.md)
|
||||||
|
[](https://www.npmjs.com/package/@terrastruct/d2)
|
||||||
[](https://discord.gg/NF6X8K4eDq)
|
[](https://discord.gg/NF6X8K4eDq)
|
||||||
[](https://twitter.com/terrastruct)
|
[](https://twitter.com/terrastruct)
|
||||||
[](./LICENSE.txt)
|
[](./LICENSE.txt)
|
||||||
|
|
|
||||||
39
ci/release/release-js.sh
Executable file
39
ci/release/release-js.sh
Executable file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
cd -- "$(dirname "$0")/../.."
|
||||||
|
. "./ci/sub/lib.sh"
|
||||||
|
|
||||||
|
VERSION=""
|
||||||
|
|
||||||
|
help() {
|
||||||
|
cat <<EOF
|
||||||
|
usage: $0 --version=<version>
|
||||||
|
|
||||||
|
Publishes the d2.js to NPM.
|
||||||
|
|
||||||
|
Flags:
|
||||||
|
--version Version to publish (e.g., "0.1.2" or "nightly"). Note this is the js version, not related to the d2 version. A non-nightly version will publish to latest.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--help|-h)
|
||||||
|
help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
--version=*)
|
||||||
|
VERSION="${arg#*=}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
flag_errusage "--version is required"
|
||||||
|
fi
|
||||||
|
|
||||||
|
FGCOLOR=6 header "Publishing JavaScript package to NPM (version: $VERSION)"
|
||||||
|
|
||||||
|
sh_c "NPM_VERSION=$VERSION ./make.sh js"
|
||||||
|
|
||||||
|
FGCOLOR=2 header 'NPM publish completed'
|
||||||
|
|
@ -1,5 +1,26 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -eu
|
set -eu
|
||||||
cd -- "$(dirname "$0")/../.."
|
cd -- "$(dirname "$0")/../.."
|
||||||
|
. "./ci/sub/lib.sh"
|
||||||
|
|
||||||
|
|
||||||
|
NPM_VERSION=""
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--npm-version=*)
|
||||||
|
NPM_VERSION="${arg#*=}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$NPM_VERSION" ]; then
|
||||||
|
flag_errusage "--npm-version is required"
|
||||||
|
fi
|
||||||
|
|
||||||
./ci/sub/release/release.sh "$@"
|
./ci/sub/release/release.sh "$@"
|
||||||
|
|
||||||
|
if [ -n "$NPM_VERSION" ]; then
|
||||||
|
./ci/release/release-js.sh --version="$NPM_VERSION"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,26 +18,52 @@ fi
|
||||||
cd d2js/js
|
cd d2js/js
|
||||||
sh_c bun build.js
|
sh_c bun build.js
|
||||||
|
|
||||||
if [ "${PUBLISH:-0}" = "1" ]; then
|
if [ -n "${NPM_VERSION:-}" ]; then
|
||||||
echo "Publishing nightly version to NPM..."
|
cp package.json package.json.bak
|
||||||
|
trap 'rm -f .npmrc; mv package.json.bak package.json' EXIT
|
||||||
|
|
||||||
|
if [ "$NPM_VERSION" = "nightly" ]; then
|
||||||
|
echo "Publishing nightly version to npm..."
|
||||||
|
|
||||||
DATE_TAG=$(date +'%Y%m%d')
|
DATE_TAG=$(date +'%Y%m%d')
|
||||||
COMMIT_SHORT=$(git rev-parse --short HEAD)
|
COMMIT_SHORT=$(git rev-parse --short HEAD)
|
||||||
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
||||||
NIGHTLY_VERSION="${CURRENT_VERSION}-nightly.${DATE_TAG}.${COMMIT_SHORT}"
|
PUBLISH_VERSION="${CURRENT_VERSION}-nightly.${DATE_TAG}.${COMMIT_SHORT}"
|
||||||
|
NPM_TAG="nightly"
|
||||||
|
|
||||||
cp package.json package.json.bak
|
echo "Updating package version to ${PUBLISH_VERSION}"
|
||||||
trap 'rm -f .npmrc; mv package.json.bak package.json' EXIT
|
else
|
||||||
|
echo "Publishing official version ${NPM_VERSION} to npm..."
|
||||||
|
PUBLISH_VERSION="$NPM_VERSION"
|
||||||
|
NPM_TAG="latest"
|
||||||
|
|
||||||
echo "Updating package version to ${NIGHTLY_VERSION}"
|
echo "Setting package version to ${PUBLISH_VERSION}"
|
||||||
npm version "${NIGHTLY_VERSION}" --no-git-tag-version
|
fi
|
||||||
|
|
||||||
echo "Publishing to npm with tag 'nightly'..."
|
# Update package.json with the new version
|
||||||
|
npm version "${PUBLISH_VERSION}" --no-git-tag-version
|
||||||
|
|
||||||
|
echo "Publishing to npm with tag '${NPM_TAG}'..."
|
||||||
if [ -n "${NPM_TOKEN-}" ]; then
|
if [ -n "${NPM_TOKEN-}" ]; then
|
||||||
|
# Create .npmrc file with auth token
|
||||||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
|
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
|
||||||
trap 'rm -f .npmrc' EXIT
|
|
||||||
if npm publish --tag nightly; then
|
if npm publish --tag "$NPM_TAG"; then
|
||||||
echo "Successfully published @terrastruct/d2@${NIGHTLY_VERSION} to npm with tag 'nightly'"
|
echo "Successfully published @terrastruct/d2@${PUBLISH_VERSION} to npm with tag '${NPM_TAG}'"
|
||||||
|
|
||||||
|
# For official releases, bump the patch version
|
||||||
|
if [ "$NPM_VERSION" != "nightly" ]; then
|
||||||
|
# Restore original package.json first
|
||||||
|
mv package.json.bak package.json
|
||||||
|
|
||||||
|
echo "Bumping version to ${NPM_VERSION}"
|
||||||
|
npm version "${NPM_VERSION}" --no-git-tag-version
|
||||||
|
git add package.json
|
||||||
|
git commit -m "Bump version to ${NPM_VERSION} [skip ci]"
|
||||||
|
|
||||||
|
# Cancel the trap since we manually restored and don't want it to execute on exit
|
||||||
|
trap - EXIT
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echoerr "Failed to publish package to npm"
|
echoerr "Failed to publish package to npm"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "@terrastruct/d2",
|
"name": "@terrastruct/d2",
|
||||||
"author": "Terrastruct, Inc.",
|
"author": "Terrastruct, Inc.",
|
||||||
"description": "D2.js is a wrapper around the WASM build of D2, the modern text-to-diagram language.",
|
"description": "D2.js is a wrapper around the WASM build of D2, the modern text-to-diagram language.",
|
||||||
"version": "0.1.22",
|
"version": "0.1.23",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/terrastruct/d2.git",
|
"url": "git+https://github.com/terrastruct/d2.git",
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
"test:integration": "bun test test/integration",
|
"test:integration": "bun test test/integration",
|
||||||
"test:all": "bun run test && bun run test:integration",
|
"test:all": "bun run test && bun run test:integration",
|
||||||
"dev": "bun --watch dev-server.js",
|
"dev": "bun --watch dev-server.js",
|
||||||
"prepublishOnly": "PUBLISH=0 ./make.sh all"
|
"prepublishOnly": "NPM_VERSION= ./make.sh all"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"d2",
|
"d2",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue