Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add changeset tooling #22

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
33 changes: 33 additions & 0 deletions .github/workflows/changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Changeset
on:
push:
branches:
- main
- ullrich/add-changesets

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.BELLA_ACTION_TOKEN }}
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20

- uses: bahmutov/npm-install@v1

- name: Create release PR or publish release
uses: changesets/action@v1
with:
version: yarn changeset version
publish: yarn changeset publish
commit: 'chore: version package'
title: 'chore: version package'
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.BELLA_ACTION_TOKEN }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ output.json
google-services.json

# Android Profiling
*.hprof
*.hprof

# Node
node_modules/
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# MagicBell Android SDK

## 2.0.0

This release is mostly compatible with version 1.0.0 of the SDK. It introduces two breaking changes though. Please consult the Readme for detailed reference.

### Breaking: Updated Notification Preferences API

The shape of the returned preferences object changed and now contains categories and channels.

### Breaking: HMAC validation

Instead of being required to pass the API secret, the HMAC should be computed on backend and passed to the frontend, where it is expected as an argument on the connectUser call.
Also the MagicBellClient does not have a enableHMAC flag anymore. The behaviour whether to send an HMAC header is now defined by whether one was passed as an argument to the connectUser call.

### APNS Integration

The previous SDK was registering device tokens using the `/push_subscriptions` API endpoint. Since version 2, the SDK uses the `/integrations/mobile_push/apns`

### What's Changed

- Upgrading Android and Gradle Tooling by @stigi in https://github.com/magicbell-io/magicbell-android/pull/13
- Remove API secret in favor of explicitly passing user HMAC by @stigi in https://github.com/magicbell-io/magicbell-android/pull/14
- Notification preferences update by @stigi in https://github.com/magicbell-io/magicbell-android/pull/15
- fix: Use correct keys when parsing action URL and custom Attributes from notification response by @stigi in https://github.com/magicbell-io/magicbell-android/pull/16
- chore: Migrate from Push Subscriptions to FCM Integration by @stigi in https://github.com/magicbell-io/magicbell-android/pull/17
- chore: Bump SDK version to 2.0.0 by @stigi in https://github.com/magicbell-io/magicbell-android/pull/18

### New Contributors

- @stigi made their first contribution in https://github.com/magicbell-io/magicbell-android/pull/13

**Full Changelog**: https://github.com/magicbell-io/magicbell-android/compare/1.0.0...2.0.0
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ This repo also contains a full blown example. To run the project:
Add the dependency in your build.gradle file.
```groovy
// MagicBell SDK
implementation 'com.magicbell:magicbell-sdk:1.0.0'
implementation 'com.magicbell:magicbell-sdk:2.0.0'
// MagicBell Compose
implementation 'com.magicbell:magicbell-sdk-compose:1.0.0'
implementation 'com.magicbell:magicbell-sdk-compose:2.0.0'
```

## The MagicBell Client
Expand Down Expand Up @@ -551,7 +551,7 @@ user.preferences.update().getOrElse { }

To update a single channel you can use the provided convenience function `updateChannel`.

```swift
```kotlin
user.preferences.updateChannel("new_comment", "in_app", true).getOrElse { }
```

Expand Down
3 changes: 0 additions & 3 deletions example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0'

// MagicBell
// implementation 'com.magicbell:magicbell-sdk:2.0.0'
implementation project(":sdk") // using local dependency

// implementation 'com.magicbell:magicbell-sdk-compose:2.0.0'
implementation project(":sdk-compose") // using local dependency

// Compose
Expand Down
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "magicbell-android",
"version": "2.0.0",
"private": true,
"type": "module",
"devDependencies": {
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.8",
"replace-in-file": "^8.2.0",
"tsx": "^4.19.1"
},
"scripts": {
"changeset": "./scripts/changeset-wrapper.sh"
}
}
26 changes: 26 additions & 0 deletions scripts/changeset-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# make sure the script runs relative to the repo root
set -euo pipefail && cd "$(dirname "${BASH_SOURCE[0]}")/.."

# some helpers and error handling:
info() { printf "%s\n" "$*" >&1; }
error() { printf "%s\n" "$*" >&2; }
trap 'echo Changeset interrupted >&2; exit 2' INT TERM

# pass all arguments to changeset
./node_modules/.bin/changeset "$@"

changeset_exit=$?
if [ ${changeset_exit} -gt 0 ];
then
error "Changeset finished with error"
exit ${changeset_exit}
fi

# if first argument was `version` also run the `update-version.ts` script
args=("$@")
if [ $# -gt 0 ] && [ ${args[0]} = "version" ]
then
yarn tsx scripts/update-version.ts
fi
36 changes: 36 additions & 0 deletions scripts/update-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { replaceInFile } from 'replace-in-file';

import pkgJson from '../package.json';

const version = pkgJson.version

// Warning:
// Make sure to bundle replacements in the same file into one, otherwise the `Promise.all`
// later on can lead to race conditions, overwriting previously applied replacements

const replacements = [
{
files: 'README.md',
from: [
// Gradle instructions
/implementation 'com.magicbell:magicbell-sdk:\d\.\d\.\d'/g,
/implementation 'com.magicbell:magicbell-sdk-compose:\d\.\d\.\d'/g,
],
to: [
`implementation 'com.magicbell:magicbell-sdk:${version}'`,
`implementation 'com.magicbell:magicbell-sdk-compose:${version}'`
],
},
{
files: 'gradle-mvn-push.gradle',
from: /version = '\d\.\d\.\d'/g,
to: `version = '${version}'`,
}
]

await Promise.all(
replacements.map(options => replaceInFile(options))
).catch(e => {
process.stdout.write(`Error updating version via update-version.ts: ${e}\n`);
process.exit(1);
})
Loading