Skip to content

Commit c914b07

Browse files
Merge upstream develop
2 parents 88e82ba + f542477 commit c914b07

10 files changed

Lines changed: 325 additions & 8 deletions

File tree

.gitlab-ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ include:
99
- local: '.gitlab/ci/deploy_server.yml'
1010
- local: '.gitlab/ci/deploy_pages.yml'
1111
- local: '.gitlab/ci/scan_dependencies.yml'
12+
- local: '.gitlab/ci/release.yml'
1213
stages:
1314
- setup
1415
- check
1516
- build
1617
- publish
1718
- deploy
19+
- release
1820
- test
1921
variables:
2022
CARGO_HOME: ${CI_PROJECT_DIR}/.cargo

.gitlab/changelog_config.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Match the SemVer tags this project releases on (v2.0.0, v2.0.0-alpha.1, ...).
2+
tag_regex: '^v\d+\.\d+\.\d+'
3+
4+
categories:
5+
feature: 🚀 Features
6+
fix: 🐛 Bug fixes
7+
enhancement: ⚡ Enhancements
8+
security: 🔒 Security
9+
deprecated: ⚠️ Deprecated
10+
breaking-change: 🚨 Breaking Changes
11+
documentation: 📚 Documentation
12+
other: 📦 Other
13+
14+
template: |
15+
{% if categories %}
16+
{% each categories %}
17+
#### {{ title }}
18+
19+
{% each entries %}
20+
- {{ title }} ({{ commit.reference }}){% if author.contributor %} by {{ author.reference }}{% end %}{% if commit.trailers.MR %} ([merge request]({{ commit.trailers.MR }})){% end %}
21+
22+
{% end %}
23+
{% end %}
24+
{% else %}
25+
No changes.
26+
{% end %}

.gitlab/ci/build_app.yml

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
app-web-image:
3030
extends: .app-build-base
31+
rules:
32+
- !reference [.app-workflow, rules]
33+
- !reference [.release-workflow, rules]
3134
image:
3235
name: moby/buildkit:rootless
3336
entrypoint: ['']
@@ -43,6 +46,8 @@ app-web-image:
4346
--local dockerfile=./apps/polycentric \
4447
--opt build-arg:EXPO_PUBLIC_POLYCENTRIC_SEED_SERVERS=$EXPO_PUBLIC_POLYCENTRIC_SEED_SERVERS \
4548
--opt build-arg:SKIP_WORKSPACE_BUILD=1 \
49+
--import-cache type=registry,ref=$CI_REGISTRY_IMAGE/app:$CI_COMMIT_SHA-cache \
50+
--export-cache type=registry,ref=$CI_REGISTRY_IMAGE/app:$CI_COMMIT_SHA-cache,mode=max \
4651
--output type=image,name=$CI_REGISTRY_IMAGE/app:$CI_COMMIT_SHA,push=true
4752
4853
.app-build-expo:
@@ -56,18 +61,44 @@ app-web-image:
5661
- apt-get update && apt-get install -y --no-install-recommends git
5762
- cd ./apps/polycentric
5863

59-
app-android-apk:
64+
# EAS builds run: manual on merge requests, automatic on the default branch and
65+
# on tags. Only the APK waits for completion (we download it); the others are
66+
# fire-and-forget.
67+
.app-eas-build:
6068
extends: .app-build-expo
69+
rules:
70+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
71+
changes:
72+
- apps/**/*
73+
- .gitlab/ci/build_app.yml
74+
- .gitlab/ci/deploy_app.yml
75+
when: manual
76+
allow_failure: true
77+
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
78+
changes:
79+
- apps/**/*
80+
- .gitlab/ci/build_app.yml
81+
- .gitlab/ci/deploy_app.yml
82+
- if: $CI_COMMIT_TAG =~ /^(v\d+\.\d+\.\d+|app-)/
83+
84+
app-android-apk:
85+
extends: .app-eas-build
6186
script:
62-
- npx eas-cli build --platform android --profile preview --non-interactive --no-wait
87+
- npx eas-cli build --platform android --profile preview --non-interactive --wait --json > eas-build.json
88+
# eas only builds remotely; download the resulting APK so it is a CI artifact.
89+
- node "$CI_PROJECT_DIR/tools/expo/download-apk.js" eas-build.json polycentric.apk
90+
artifacts:
91+
paths:
92+
- apps/polycentric/polycentric.apk
93+
- apps/polycentric/eas-build.json
94+
expire_in: 1 week
6395

6496
app-android-aab:
65-
extends: .app-build-expo
97+
extends: .app-eas-build
6698
script:
67-
- npx eas-cli build --platform android --non-interactive --no-wait
68-
when: manual
99+
- npx eas-cli build --platform android --non-interactive --no-wait ${CI_COMMIT_TAG:+--auto-submit}
69100

70101
app-ios:
71-
extends: .app-build-expo
102+
extends: .app-eas-build
72103
script:
73-
- npx eas-cli build --platform ios --non-interactive --no-wait
104+
- npx eas-cli build --platform ios --non-interactive --no-wait ${CI_COMMIT_TAG:+--auto-submit}

.gitlab/ci/build_js_sdks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ js-sdks-build:
4545
- !reference [.rs-core-workflow, rules]
4646
- !reference [.rn-sdk-workflow, rules]
4747
- !reference [.app-workflow, rules]
48+
- !reference [.release-workflow, rules]
4849

4950
.js-sdks-publish-npm:
5051
rules:

.gitlab/ci/build_rn_sdk.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ rn-android-build:
2121
- !reference [.rn-sdk-workflow, rules]
2222
- !reference [.rs-core-workflow, rules]
2323
- !reference [.app-workflow, rules]
24+
- !reference [.release-workflow, rules]
2425
cache:
2526
- key:
2627
files:
@@ -59,6 +60,7 @@ rn-android-build:
5960
- !reference [.rn-sdk-workflow, rules]
6061
- !reference [.rs-core-workflow, rules]
6162
- !reference [.app-workflow, rules]
63+
- !reference [.release-workflow, rules]
6264
tags:
6365
- macscript
6466
variables:
@@ -124,3 +126,4 @@ rn-sdk-build:
124126
- !reference [.rn-sdk-workflow, rules]
125127
- !reference [.rs-core-workflow, rules]
126128
- !reference [.app-workflow, rules]
129+
- !reference [.release-workflow, rules]

.gitlab/ci/build_rs_core.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ rs-core-uniffi-web-build:
8787
- !reference [.js-sdk-workflow, rules]
8888
- !reference [.rn-sdk-workflow, rules]
8989
- !reference [.app-workflow, rules]
90+
- !reference [.release-workflow, rules]
9091
cache:
9192
- key:
9293
files:

.gitlab/ci/build_server.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ server-build:
4747

4848
server-image:
4949
extends: .server-workflow
50+
rules:
51+
- !reference [.server-workflow, rules]
52+
- !reference [.release-workflow, rules]
5053
image:
5154
name: moby/buildkit:rootless
5255
entrypoint: ['']
@@ -60,4 +63,6 @@ server-image:
6063
--frontend dockerfile.v0 \
6164
--local context=. \
6265
--local dockerfile=./services/server \
66+
--import-cache type=registry,ref=$CI_REGISTRY_IMAGE/server:$CI_COMMIT_SHA-cache \
67+
--export-cache type=registry,ref=$CI_REGISTRY_IMAGE/server:$CI_COMMIT_SHA-cache,mode=max \
6368
--output type=image,name=$CI_REGISTRY_IMAGE/server:$CI_COMMIT_SHA,push=true

.gitlab/ci/release.yml

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
.release-workflow:
2+
rules:
3+
# Only fire on SemVer release tags, e.g. v2.0.0 or v2.0.0-alpha.1.
4+
# NOTE: intentionally has no trailing `when: never` so it can be safely
5+
# `!reference`d into the build jobs' rule lists without short-circuiting them.
6+
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+/
7+
when: always
8+
9+
################
10+
# Android APK #
11+
################
12+
13+
release-android-apk:
14+
extends: .release-workflow
15+
stage: publish
16+
image: alpine:latest
17+
needs:
18+
- job: app-android-apk
19+
artifacts: true
20+
before_script:
21+
- apk add --no-cache curl
22+
script:
23+
- |
24+
APK_PACKAGE_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/polycentric-android/${CI_COMMIT_TAG}/polycentric-${CI_COMMIT_TAG}.apk"
25+
echo "Uploading APK to ${APK_PACKAGE_URL}"
26+
curl -fsSL --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file apps/polycentric/polycentric.apk "$APK_PACKAGE_URL"
27+
echo "APK_PACKAGE_URL=${APK_PACKAGE_URL}" > apk.env
28+
artifacts:
29+
reports:
30+
dotenv: apk.env
31+
32+
####################
33+
# Container images #
34+
####################
35+
36+
.release-tag-image:
37+
extends: .release-workflow
38+
stage: release
39+
image:
40+
name: gcr.io/go-containerregistry/crane:debug
41+
entrypoint: ['']
42+
script:
43+
- crane auth login $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
44+
- crane tag $CI_REGISTRY_IMAGE/$IMAGE:$CI_COMMIT_SHA $CI_COMMIT_TAG
45+
46+
release-tag-app-image:
47+
extends: .release-tag-image
48+
variables:
49+
IMAGE: app
50+
needs:
51+
- job: app-web-image
52+
artifacts: false
53+
54+
release-tag-server-image:
55+
extends: .release-tag-image
56+
variables:
57+
IMAGE: server
58+
needs:
59+
- job: server-image
60+
artifacts: false
61+
62+
##########################
63+
# JS SDKs + React Native #
64+
##########################
65+
66+
release-publish-npm:
67+
extends: .release-workflow
68+
stage: publish
69+
image: node:24-slim
70+
needs:
71+
- job: rs-core-uniffi-web-build
72+
artifacts: true
73+
- job: js-sdks-build
74+
artifacts: true
75+
- job: rn-sdk-build
76+
artifacts: true
77+
before_script:
78+
- apt-get update && apt-get install -y --no-install-recommends git
79+
- npm install -g pnpm@10.19.0
80+
- pnpm config set @polycentric:registry https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/
81+
- echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" >> ~/.npmrc
82+
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc
83+
- pnpm install --frozen-lockfile
84+
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
113+
114+
#################
115+
# rs-core crate #
116+
#################
117+
118+
release-publish-rs-core:
119+
extends: .release-workflow
120+
stage: publish
121+
image: $RUST_IMAGE
122+
variables:
123+
GIT_DEPTH: '1'
124+
script:
125+
- VERSION="${CI_COMMIT_TAG#v}"
126+
# Bump the crate versions and give the path dependency a version so the
127+
# crates package cleanly.
128+
- sed -i "s/^version = \".*\"/version = \"${VERSION}\"/" packages/rs-common/Cargo.toml packages/rs-core/Cargo.toml
129+
- sed -i "s#path = \"../rs-common\" }#path = \"../rs-common\", version = \"${VERSION}\" }#" packages/rs-core/Cargo.toml
130+
- mkdir -p target/package
131+
- cargo package -p polycentric-common --no-verify --allow-dirty || true
132+
- cargo package -p polycentric-core --no-verify --allow-dirty || true
133+
# Fall back to a source tarball if cargo could not package the crate.
134+
- |
135+
if ! ls target/package/*.crate >/dev/null 2>&1; then
136+
echo "cargo package produced no .crate; falling back to a source tarball" >&2
137+
tar czf "target/package/polycentric-core-${VERSION}.crate" packages/rs-core packages/rs-common
138+
fi
139+
- |
140+
BASE_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/polycentric-rs-core/${VERSION}"
141+
for crate in target/package/*.crate; do
142+
fname=$(basename "$crate")
143+
echo "Uploading ${fname}"
144+
curl -fsSL --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "$crate" "${BASE_URL}/${fname}"
145+
done
146+
echo "RS_CORE_PACKAGE_URL=${BASE_URL}/polycentric-core-${VERSION}.crate" > rs-core.env
147+
artifacts:
148+
reports:
149+
dotenv: rs-core.env
150+
151+
#############
152+
# Changelog #
153+
#############
154+
155+
release-changelog:
156+
extends: .release-workflow
157+
stage: publish
158+
image: alpine:latest
159+
before_script:
160+
- apk add --no-cache curl jq
161+
script:
162+
- 'curl -H "PRIVATE-TOKEN: $CI_API_TOKEN" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/changelog?version=$CI_COMMIT_TAG" | jq -r .notes > release_notes.md'
163+
- cat release_notes.md
164+
artifacts:
165+
paths:
166+
- release_notes.md
167+
expire_in: 1 week
168+
169+
#############################
170+
# Create the GitLab Release #
171+
#############################
172+
173+
release:
174+
extends: .release-workflow
175+
stage: release
176+
image: registry.gitlab.com/gitlab-org/release-cli:latest
177+
script:
178+
- echo "Creating release"
179+
needs:
180+
- job: release-changelog
181+
artifacts: true
182+
- job: release-android-apk
183+
artifacts: true
184+
- job: release-publish-rs-core
185+
artifacts: false
186+
- job: release-publish-npm
187+
artifacts: false
188+
- job: release-tag-app-image
189+
artifacts: false
190+
- job: release-tag-server-image
191+
artifacts: false
192+
release:
193+
tag_name: $CI_COMMIT_TAG
194+
name: '$CI_COMMIT_TAG'
195+
ref: '$CI_COMMIT_SHA'
196+
description: release_notes.md
197+
assets:
198+
links:
199+
- name: 'Android APK ($CI_COMMIT_TAG)'
200+
url: '$APK_PACKAGE_URL'
201+
link_type: package

apps/polycentric/eas.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
}
1717
},
1818
"submit": {
19-
"production": {}
19+
"production": {
20+
"ios": {
21+
"ascAppId": "6504881935"
22+
},
23+
"android": {
24+
"track": "internal"
25+
}
26+
}
2027
}
2128
}

0 commit comments

Comments
 (0)