Skip to content

Commit 2f790df

Browse files
Merge upstream develop
2 parents a144310 + eb0268f commit 2f790df

3 files changed

Lines changed: 81 additions & 30 deletions

File tree

.gitlab/ci/release.yml

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -82,34 +82,7 @@ release-publish-npm:
8282
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc
8383
- pnpm install --frozen-lockfile
8484
script:
85-
- VERSION="${CI_COMMIT_TAG#v}"
86-
- echo "Publishing @polycentric packages at version ${VERSION}"
87-
# Keep prereleases (e.g. 2.0.0-alpha.1) off the `latest` dist-tag.
88-
- |
89-
DIST_TAG=latest
90-
if echo "$VERSION" | grep -q '-'; then
91-
DIST_TAG=$(echo "$VERSION" | sed -E 's/.*-([a-zA-Z]+).*/\1/')
92-
[ "$DIST_TAG" = "$VERSION" ] && DIST_TAG=next
93-
fi
94-
echo "Using npm dist-tag: ${DIST_TAG}"
95-
# Bump every @polycentric package to the release version.
96-
- pnpm -r --filter "@polycentric/*" exec npm version "${VERSION}" --no-git-tag-version --allow-same-version
97-
# Publish to the GitLab registry and to public npm. pnpm topologically
98-
# orders the packages and rewrites workspace:* -> ${VERSION} on publish.
99-
- |
100-
FILTERS="--filter @polycentric/rs-core-uniffi-web --filter @polycentric/js-storage-sqlite --filter @polycentric/js-core --filter @polycentric/js-browser --filter @polycentric/js-node --filter @polycentric/react-native"
101-
102-
echo "Publishing to the GitLab package registry"
103-
pnpm config set @polycentric:registry "https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/"
104-
pnpm $FILTERS -r publish --no-git-checks --access public --tag "$DIST_TAG"
105-
106-
if [ -n "$NPM_TOKEN" ]; then
107-
echo "Publishing to public npm (registry.npmjs.org)"
108-
pnpm config set @polycentric:registry "https://registry.npmjs.org/"
109-
pnpm $FILTERS -r publish --no-git-checks --access public --tag "$DIST_TAG"
110-
else
111-
echo "NPM_TOKEN is not set; skipping public npm publish" >&2
112-
fi
85+
- .gitlab/ci/scripts/npm_publish.sh
11386

11487
#################
11588
# rs-core crate #

.gitlab/ci/scripts/npm_publish.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Publishes every @polycentric package to the GitLab package registry and,
4+
# when NPM_TOKEN is set, to public npm. Packages are published one at a time
5+
# so a version that already exists is skipped instead of aborting the whole
6+
# release (and blocking the packages ordered after it), keeping re-runs
7+
# idempotent.
8+
#
9+
# Env:
10+
# CI_COMMIT_TAG release tag, e.g. v2.0.2 (the leading "v" is stripped)
11+
# CI_SERVER_HOST GitLab host for the project package registry
12+
# CI_PROJECT_ID GitLab project id for the project package registry
13+
# NPM_TOKEN public npm auth token; public publish is skipped if unset
14+
set -euo pipefail
15+
16+
cd "$(dirname "$0")/../../.."
17+
18+
VERSION="${CI_COMMIT_TAG#v}"
19+
echo "Publishing @polycentric packages at version ${VERSION}"
20+
21+
# Keep prereleases (e.g. 2.0.0-alpha.1) off the `latest` dist-tag.
22+
DIST_TAG=latest
23+
if echo "$VERSION" | grep -q '-'; then
24+
DIST_TAG=$(echo "$VERSION" | sed -E 's/.*-([a-zA-Z]+).*/\1/')
25+
[ "$DIST_TAG" = "$VERSION" ] && DIST_TAG=next
26+
fi
27+
echo "Using npm dist-tag: ${DIST_TAG}"
28+
29+
# Bump every @polycentric package to the release version.
30+
pnpm -r --filter "@polycentric/*" exec npm version "${VERSION}" --no-git-tag-version --allow-same-version
31+
32+
# Topological order; pnpm rewrites workspace:* -> ${VERSION} on publish.
33+
PACKAGES="@polycentric/rs-core-uniffi-web @polycentric/js-storage-sqlite @polycentric/js-core @polycentric/js-browser @polycentric/js-node @polycentric/react-native"
34+
35+
publish_all() {
36+
registry_url="$1"
37+
registry_label="$2"
38+
echo "Publishing to ${registry_label} (${registry_url})"
39+
pnpm config set @polycentric:registry "${registry_url}"
40+
for pkg in $PACKAGES; do
41+
set +e
42+
output=$(pnpm -r --filter "$pkg" publish --no-git-checks --access public --tag "$DIST_TAG" 2>&1)
43+
status=$?
44+
set -e
45+
echo "$output"
46+
if [ "$status" -ne 0 ]; then
47+
if echo "$output" | grep -qiE 'cannot publish over|previously published|already been taken|EPUBLISHCONFLICT|already exists'; then
48+
echo "==> ${pkg} is already published at ${VERSION} on ${registry_label}; skipping."
49+
else
50+
echo "==> ${pkg} failed to publish to ${registry_label}." >&2
51+
exit "$status"
52+
fi
53+
fi
54+
done
55+
}
56+
57+
publish_all "https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" "the GitLab package registry"
58+
59+
if [ -n "${NPM_TOKEN:-}" ]; then
60+
publish_all "https://registry.npmjs.org/" "public npm"
61+
else
62+
echo "NPM_TOKEN is not set; skipping public npm publish" >&2
63+
fi

Cargo.lock

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)