@guardian/bridget 8.7.2 → 8.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +76 -0
  2. package/package.json +5 -2
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # Bridget
2
+ This repo contains the thrift definitions defining the API between native layers (iOS, Android) and [Webview](https://github.com/guardian/dotcom-rendering).
3
+
4
+ The repo is also responsible for generating and publishing packages to be used by iOS, Android and the Webview.
5
+
6
+ ## Thrift definitions
7
+ `native.thrift` are the functions to be implemented by iOS and Android. The webview will be able to call these functions with the specified arguments.
8
+
9
+ ## Generated packages
10
+ The Swift and TypeScript packages are generated and published using this [GitHub action](.github/workflows/release.yml).
11
+
12
+ - The TypeScript package can be installed from [NPM](https://www.npmjs.com/package/@guardian/bridget)
13
+ - Swift package can be installed with Swift Package Manager from [GitHub](https://github.com/guardian/mobile-apps-thrift-swift)
14
+
15
+ For Android, Java interfaces for Bridget services are generated at build time [in the Bridget module](https://github.com/guardian/android-news-app/blob/ffe36dbeb4a6c75709dba526a9b0e707a8f982a5/bridget/build.gradle.kts#L24-L31).
16
+
17
+
18
+ ## Adding a new function
19
+ 1. Define the function in `native.thrift` if it needs to be implemented in Swift & Kotlin
20
+ 2. Make sure to add a comment above the function to document what it does. It's a good idea to add the version it was available from too (this will be a minor update to the latest tag)
21
+ 3. Run `npx changeset` to create a changeset file describing your changes and the version bump type
22
+ 4. Make a pull request. It would be good to get a review from all teams who would need to implement or call the function. e.g. Android, iOS and apps-rendering
23
+ 5. Merging into main will trigger the Changesets action to create or update a "Version Packages" PR
24
+ 6. When the "Version Packages" PR is merged, the workflow will automatically publish the new packages
25
+ 7. If you don't see the published packages, start by inspecting the GitHub action run
26
+ 8. Bump the version in your repo (iOS, Android or apps-rendering) and implement the function or make the function call. Make sure the function is always available in the current environment. This can be done by checking the thrift version number of the webView or native layer
27
+
28
+ ## Releasing Bridget
29
+
30
+ Bridget is released by the [`release.yml`](.github/workflows/release.yml) GitHub Action. The repository uses:
31
+
32
+ - **npm trusted publishing**: No NPM_TOKEN needed. Publishing to npm is authenticated via GitHub's OIDC token. See [npm's trusted publishing docs](https://docs.npmjs.com/trusted-publishers) for more information.
33
+ - **GitHub App authentication**: The workflow uses a GitHub App to publish Swift and Android packages. This requires:
34
+ - `APP_ID` (repository variable)
35
+ - `GH_APP_PRIVATE_KEY` (repository secret)
36
+
37
+ The GitHub App needs read/write permissions for the [`guardian/bridget-swift`](https://github.com/guardian/bridget-swift) and [`guardian/bridget-android`](https://github.com/guardian/bridget-android) repositories.
38
+
39
+ ## Testing a prerelease
40
+
41
+ You can use prereleases to test a new version of the models across web, Android and iOS without making a full release.
42
+
43
+ To do this, create a new prerelease in the GitHub releases UI (or [click here](https://github.com/guardian/bridget/releases/new?prerelease=true)). The tag is used as the version. For example, once the prerelease workflow has finished running for a prerelease created with tag `v0.0.0-2024-02-16`:
44
+
45
+ * install from `npm`: `npm install @guardian/bridget@v0.0.0-2024-02-16`
46
+ * find the `swift` package: `https://github.com/guardian/bridget-swift/tree/v0.0.0-2024-02-16`
47
+ * find the `android` package: `https://github.com/guardian/bridget-android/tree/v0.0.0-2024-02-16`
48
+
49
+ **Note:** The prerelease workflow is part of the same [`release.yml`](.github/workflows/release.yml) workflow file and also uses npm trusted publishing.
50
+
51
+ ### GitHub Action fails with "Authentication failed"
52
+
53
+ This is likely caused by an issue with the GitHub App credentials. To fix this:
54
+ 1. Check that the `GH_APP_PRIVATE_KEY` repository secret is valid and hasn't expired
55
+ 2. Verify that the `APP_ID` repository variable is correct
56
+ 3. Ensure the GitHub App has the necessary read/write permissions for the bridget-swift and bridget-android repositories
57
+
58
+ **Note:** updating secrets and variables requires admin permissions on the repository.
59
+
60
+ ### Setting the version bump
61
+
62
+ Versions are managed by [Changesets](https://github.com/changesets/changesets). When you make changes that require a version bump:
63
+
64
+ 1. Run `npx changeset` in your local repository
65
+ 2. Select the type of version bump (patch, minor, or major)
66
+ 3. Provide a description of the changes
67
+ 4. Commit the generated changeset file (in `.changeset/`) with your pull request
68
+
69
+ When your PR is merged to main, the Changesets GitHub Action will:
70
+ - Create or update a "Version Packages" PR that includes all pending changesets
71
+ - When you merge that PR, the workflow will automatically publish the new version
72
+
73
+ For more information, see the [Changesets documentation](https://github.com/changesets/changesets/blob/main/docs/intro-to-using-changesets.md).
74
+
75
+ ## About the name
76
+ The name Bridget was chosen out of a list of a dozen suggestions, containing mostly bridge related puns.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guardian/bridget",
3
- "version": "8.7.2",
3
+ "version": "8.7.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,5 +10,8 @@
10
10
  "author": "",
11
11
  "license": "ISC",
12
12
  "type": "commonjs",
13
- "types": "index.d.ts"
13
+ "types": "index.d.ts",
14
+ "repository": {
15
+ "url": "https://github.com/guardian/bridget"
16
+ }
14
17
  }