Skip to content

Commit 86abcf7

Browse files
Merge upstream develop
2 parents 8249003 + 38a15c3 commit 86abcf7

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

apps/polycentric/app.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { ExpoConfig, ConfigContext } from 'expo/config';
22

3+
const { version: PKG_VERSION } = require('./package.json');
4+
35
const IS_DEV = process.env.APP_VARIANT === 'dev';
46

57
const NAME = IS_DEV ? 'Polycentric Dev' : 'Polycentric';
@@ -9,7 +11,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
911
...config,
1012
name: NAME,
1113
slug: 'polycentric',
12-
version: process.env.APP_VERSION ?? '0.0.1',
14+
version: process.env.APP_VERSION ?? PKG_VERSION ?? '0.0.1',
1315
orientation: 'default',
1416
icon: './src/common/assets/images/app-icons/android-icon-foreground.png',
1517
scheme: 'polycentric',

tools/expo/resolve-version.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,44 @@
11
#!/usr/bin/env node
2-
// Resolves the app version for EAS builds and prints it to stdout.
2+
// Resolves the app version for EAS builds, writes it into
3+
// apps/polycentric/package.json, and prints it to stdout.
34
//
45
// * On a SemVer release tag (e.g. v2.0.0-alpha.1) -> that version
56
// (2.0.0-alpha.1).
67
// * Otherwise -> the latest GitLab release version with the patch bumped
78
// (e.g. latest 2.0.0 -> 2.0.1), so develop/MR builds sit one patch ahead
89
// of the last release.
910
//
11+
// The version is baked into package.json (not just exported as APP_VERSION)
12+
// because EAS evaluates app.config.ts on a remote build worker that does not
13+
// receive the CI runner's environment variables. app.config.ts reads the
14+
// version from package.json, which travels with the project upload.
15+
//
1016
// Reads CI_COMMIT_TAG, CI_API_V4_URL, CI_PROJECT_ID and CI_JOB_TOKEN.
1117

18+
const fs = require('fs');
19+
const path = require('path');
20+
21+
const PKG_PATH = path.join(
22+
__dirname,
23+
'..',
24+
'..',
25+
'apps',
26+
'polycentric',
27+
'package.json',
28+
);
29+
30+
const apply = (version) => {
31+
const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
32+
pkg.version = version;
33+
fs.writeFileSync(PKG_PATH, `${JSON.stringify(pkg, null, 2)}\n`);
34+
process.stdout.write(version);
35+
};
36+
1237
const tag = process.env.CI_COMMIT_TAG || '';
1338
const tagMatch = tag.match(/^v(\d+\.\d+\.\d+.*)$/);
1439

1540
if (tagMatch) {
16-
process.stdout.write(tagMatch[1]);
41+
apply(tagMatch[1]);
1742
} else {
1843
const api = process.env.CI_API_V4_URL;
1944
const projectId = process.env.CI_PROJECT_ID;
@@ -41,6 +66,6 @@ if (tagMatch) {
4166
} catch {
4267
// Fall back to the default below.
4368
}
44-
process.stdout.write(bumpPatch(latest));
69+
apply(bumpPatch(latest));
4570
})();
4671
}

0 commit comments

Comments
 (0)