Skip to content

Commit 4a131f8

Browse files
authored
feat: production deployment setup & basic versioning strategy (#46)
### Summary This PR introduces production setup, that will allow us to deploy the showcase to production. What's included: - mini-app release CI workflow that creates and uploads mini-apps as GitHub releases upon pushing specific git tags - `catalog-server` Vercel setup and build script that maps releases to host app - `catalog-server` deployment via manually triggered GitHub workflow - basic versioning strategy with `changesets` and compatibility-matrix that acts as a lockfile with versions - docs documenting the release process
1 parent 71dc507 commit 4a131f8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1935
-102
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "restricted",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.github/workflows/create-release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build and Deploy
2+
3+
on:
4+
push:
5+
tags:
6+
- auth-android@*.*.*
7+
- auth-ios@*.*.*
8+
- booking-android@*.*.*
9+
- booking-ios@*.*.*
10+
- dashboard-android@*.*.*
11+
- dashboard-ios@*.*.*
12+
- shopping-android@*.*.*
13+
- shopping-ios@*.*.*
14+
15+
jobs:
16+
build-and-deploy:
17+
runs-on: ubuntu-latest
18+
environment: release
19+
permissions:
20+
contents: write
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v3
25+
26+
- name: Set up Node.js
27+
uses: actions/setup-node@v3
28+
with:
29+
node-version: 18
30+
cache: yarn
31+
32+
- name: Install dependencies
33+
run: yarn install --frozen-lockfile
34+
35+
- name: Create code-signing.pem
36+
env:
37+
CODE_SIGNING_KEY: ${{ secrets.CODE_SIGNING_KEY }}
38+
run: echo "$CODE_SIGNING_KEY" > code-signing.pem
39+
40+
- name: Build
41+
run: yarn node scripts/build-miniapp.js ${{ github.ref_name }}
42+
43+
- name: Delete code-signing.pem
44+
run: rm code-signing.pem
45+
46+
- name: Release
47+
uses: ncipollo/release-action@v1
48+
with:
49+
artifacts: "build/**/*.bundle,build/**/*.map"
50+
artifactErrorsFailBuild: true
51+
skipIfReleaseExists: true
52+
name: ${{ github.ref_name }}
53+
tag: ${{ github.ref }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Deploy catalog-server
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-and-deploy:
8+
runs-on: ubuntu-latest
9+
environment: release
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
15+
- name: Install Vercel CLI
16+
run: npm install --global vercel@latest
17+
18+
- name: Deploy to Vercel
19+
env:
20+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
21+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
22+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
23+
run: vercel --token $VERCEL_TOKEN --prod

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ node_modules
1212

1313
build/
1414

15+
.vscode/
16+
1517
# Code Signing
1618
code-signing.pem
17-
code-signing.pem.pub
19+
code-signing.pem.pub
20+

RELEASING.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Super-App-Showcase Release Process
2+
3+
This document explains the detailed process of releasing the Super-App-Showcase. The release process is divided into three major sections:
4+
5+
1. Releasing Mini-Apps
6+
2. Deploying Catalog-Server
7+
3. Deploying Apps to the Stores
8+
9+
Please follow the below guidelines for each step of the process.
10+
11+
---
12+
13+
## 1. Releasing Mini-Apps
14+
15+
Mini-apps are released by creating and bumping its version via changeset. Please follow these steps to successfully release mini-apps:
16+
17+
1. **Run Changeset Version Command**: Execute the following command to create a changeset:
18+
19+
```bash
20+
yarn changeset version
21+
```
22+
23+
This assumes that the repository is correctly set up with node_modules installed and there are already some changesets ready to be used for the next version.
24+
25+
2. **Update Compatibility Matrix**: Run the script to update the compatibility matrix. This matrix keeps information on compatibility between mini-apps and the host/shell app. Here's the command to execute:
26+
27+
```bash
28+
yarn node scripts/update-compatibility-matrix.js
29+
```
30+
31+
This script goes through all the packages in the monorepo and determines their compatibility based on semantic versioning rules. It's vital to have an accurate compatibility matrix because it dictates which versions of federated dependencies are compatible with which versions of the app. It is assumed that the project uses semantic versioning for package versions.
32+
33+
3. **Create a Pull Request (PR)**: Create a PR that includes updated CHANGELOG.md from changesets, bumped version packages, and updated compatibility matrix. The PR should have "Release" in the title. Example: `Release: auth v0.0.1`.
34+
35+
4. **Release Mini-Apps**: After the PR is merged, release the mini-apps by creating and pushing git tags of the specific format: `<mini-app>-<platform>@<version>`. You can use the following command to create a tag:
36+
37+
```bash
38+
39+
40+
git push --tags
41+
```
42+
43+
In this format, `<mini-app>` represents the package name of the mini-apps in the repository (auth, booking, dashboard, shopping), `<platform>` represents either ios or android, and `<version>` represents the current version of that mini-app in its `package.json`.
44+
45+
5. **Create and Upload a Release**: When the tag is pushed, the GitHub workflow is launched for each tag pushed. This workflow creates a build of that mini-app and uploads it to GitHub Releases.
46+
47+
---
48+
49+
## 2. Deploying Catalog-Server
50+
51+
The catalog-server is manually deployed once the mini-apps have been released. It gathers URLs to the releases and deploys itself to production, exposing the mini-apps to the host app in production.
52+
53+
The catalog-server can be deployed via a manual GitHub workflow. This workflow triggers deployment on Vercel where the catalog-server is hosted. The Vercel deployment includes running a build script that reads the 'compatibility-matrix.json' file and generates URLs for iOS and Android application bundles. It organizes the generated URLs into a JSON object, separated by platform and application version, and writes this JSON object to a file named '[appName].prod.json' in the 'data' directory.
54+
55+
For the catalog-server deployment to be successful, ensure that the mini-apps are properly released on GitHub and that the compatibility matrix isn't corrupted.
56+
57+
---
58+
59+
## 3. Deploying Apps to the Stores
60+
61+
Please note, as of now the process for releasing the host app to the stores is not yet implemented. This section will be updated as soon as the implementation is done.
62+
63+
**TODO**: Implement and document the process of deploying apps to the stores.
64+
65+
---

compatibility-matrix.json

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
{
2+
"booking": {
3+
"sources": [
4+
{
5+
"name": "auth",
6+
"type": "internal",
7+
"url": "https://github.com/callstack/super-app-showcase"
8+
}
9+
],
10+
"versions": {
11+
"0.0.1": {
12+
"auth": "0.0.1"
13+
}
14+
}
15+
},
16+
"dashboard": {
17+
"sources": [
18+
{
19+
"name": "auth",
20+
"type": "internal",
21+
"url": "https://github.com/callstack/super-app-showcase"
22+
}
23+
],
24+
"versions": {
25+
"0.0.1": {
26+
"auth": "0.0.1"
27+
}
28+
}
29+
},
30+
"host": {
31+
"sources": [
32+
{
33+
"name": "auth",
34+
"type": "internal",
35+
"url": "https://github.com/callstack/super-app-showcase"
36+
},
37+
{
38+
"name": "booking",
39+
"type": "internal",
40+
"url": "https://github.com/callstack/super-app-showcase"
41+
},
42+
{
43+
"name": "dashboard",
44+
"type": "internal",
45+
"url": "https://github.com/callstack/super-app-showcase"
46+
},
47+
{
48+
"name": "shopping",
49+
"type": "internal",
50+
"url": "https://github.com/callstack/super-app-showcase"
51+
},
52+
{
53+
"name": "news",
54+
"type": "external",
55+
"url": "https://github.com/callstack/news-mini-app-showcase"
56+
}
57+
],
58+
"versions": {
59+
"0.0.1": {
60+
"auth": "0.0.1",
61+
"booking": "0.0.1",
62+
"dashboard": "0.0.1",
63+
"shopping": "0.0.1",
64+
"news": "0.0.1"
65+
}
66+
}
67+
},
68+
"shell": {
69+
"sources": [
70+
{
71+
"name": "auth",
72+
"type": "internal",
73+
"url": "https://github.com/callstack/super-app-showcase"
74+
},
75+
{
76+
"name": "booking",
77+
"type": "internal",
78+
"url": "https://github.com/callstack/super-app-showcase"
79+
},
80+
{
81+
"name": "dashboard",
82+
"type": "internal",
83+
"url": "https://github.com/callstack/super-app-showcase"
84+
},
85+
{
86+
"name": "shopping",
87+
"type": "internal",
88+
"url": "https://github.com/callstack/super-app-showcase"
89+
},
90+
{
91+
"name": "news",
92+
"type": "external",
93+
"url": "https://github.com/callstack/news-mini-app-showcase"
94+
}
95+
],
96+
"versions": {
97+
"0.0.1": {
98+
"auth": "0.0.1",
99+
"booking": "0.0.1",
100+
"dashboard": "0.0.1",
101+
"shopping": "0.0.1",
102+
"news": "0.0.1"
103+
}
104+
}
105+
},
106+
"shopping": {
107+
"sources": [
108+
{
109+
"name": "auth",
110+
"type": "internal",
111+
"url": "https://github.com/callstack/super-app-showcase"
112+
}
113+
],
114+
"versions": {
115+
"0.0.1": {
116+
"auth": "0.0.1"
117+
}
118+
}
119+
}
120+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@
3333
"packageManager": "[email protected]",
3434
"devDependencies": {
3535
"concurrently": "^7.6.0"
36+
},
37+
"dependencies": {
38+
"@changesets/cli": "^2.26.1"
3639
}
3740
}

packages/auth/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ buck-out/
2828

2929
# Bundle artifact
3030
*.jsbundle
31+
32+
# Build dir
33+
build/

packages/auth/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from './src/contexts/AuthContext';
2+
export * from './src/providers/AuthProvider';
3+
export * from './src/screens/AccountScreen';
4+
export * from './src/screens/SignInScreen';
5+
export * from './src/services/AuthService';

packages/auth/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"start": "react-native webpack-start --port 9003",
1010
"test": "jest",
1111
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
12+
"bundle": "yarn bundle:ios && yarn bundle:android",
1213
"bundle:ios": "react-native webpack-bundle --platform ios --entry-file index.js --dev false",
1314
"bundle:android": "react-native webpack-bundle --platform android --entry-file index.js --dev false"
1415
},
@@ -41,6 +42,7 @@
4142
"typescript": "4.8.4",
4243
"webpack": "^5.74.0"
4344
},
45+
"federatedModule": "auth",
4446
"jest": {
4547
"preset": "react-native",
4648
"moduleFileExtensions": [

packages/auth/webpack.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export default env => {
198198
options: {
199199
platform,
200200
devServerEnabled: Boolean(devServer),
201+
inline: true,
201202
/**
202203
* Defines which assets are scalable - which assets can have
203204
* scale suffixes: `@1x`, `@2x` and so on.
@@ -271,7 +272,7 @@ export default env => {
271272
},
272273
}),
273274
new Repack.plugins.CodeSigningPlugin({
274-
privateKeyPath: path.join('..', '..', './code-signing.pem'),
275+
privateKeyPath: path.join('..', '..', 'code-signing.pem'),
275276
outputPath: path.join('build', 'outputs', platform, 'remotes'),
276277
}),
277278
],

packages/booking/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"test": "jest",
1111
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
1212
"typecheck": "tsc",
13+
"bundle": "yarn bundle:ios && yarn bundle:android",
1314
"bundle:ios": "react-native webpack-bundle --platform ios --entry-file index.js --dev false",
1415
"bundle:android": "react-native webpack-bundle --platform android --entry-file index.js --dev false"
1516
},
@@ -49,6 +50,14 @@
4950
"typescript": "4.8.4",
5051
"webpack": "^5.74.0"
5152
},
53+
"federatedModule": "booking",
54+
"federatedDependencies": [
55+
{
56+
"name": "auth",
57+
"type": "internal",
58+
"url": "https://github.com/callstack/super-app-showcase"
59+
}
60+
],
5261
"jest": {
5362
"preset": "react-native",
5463
"moduleFileExtensions": [

packages/booking/webpack.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export default env => {
199199
options: {
200200
platform,
201201
devServerEnabled: Boolean(devServer),
202+
inline: true,
202203
/**
203204
* Defines which assets are scalable - which assets can have
204205
* scale suffixes: `@1x`, `@2x` and so on.
@@ -254,7 +255,7 @@ export default env => {
254255
shared: deps,
255256
}),
256257
new Repack.plugins.CodeSigningPlugin({
257-
privateKeyPath: path.join('..', '..', './code-signing.pem'),
258+
privateKeyPath: path.join('..', '..', 'code-signing.pem'),
258259
outputPath: path.join('build', 'outputs', platform, 'remotes'),
259260
}),
260261
],

0 commit comments

Comments
 (0)