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 #39

Merged
merged 12 commits into from
Oct 7, 2024
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": []
}
stigi marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions .changeset/popular-berries-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"magicbell-swift": minor
---

Internal: Fetching notifications from `/notifications` endpoint instead of GraphQL
8 changes: 8 additions & 0 deletions .changeset/twelve-grapes-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"magicbell-swift": major
---

Updated topic and category filtering APIs in `StorePredicate`

Previously one was able to filter for multiple topics and categories, but this functionality is now deprecated in favor of only filtering for a single topic and category.
Please reach out to us via the [Community](http://www.magicbell.com/community) if you need the previous functionality.
7 changes: 7 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@
- [ ] Bug fix <!-- fixes an issue -->
- [ ] Feature <!-- adds functionality -->
- [ ] Enhancement <!-- improves something existing -->

## Guidelines

- [ ] A [changeset] is included, or the change is not noteworthy enough to warrant one

<!-- links -->
[changeset]: https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md#i-am-in-a-single-package-repository
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 }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ Podfile.lock
# Carthage
Carthage/

# Node
node_modules/
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# MagicBell iOS 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 /integrations/mobile_push/apns.
6 changes: 5 additions & 1 deletion MagicBell.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#

require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

Pod::Spec.new do |s|
s.name = 'MagicBell'
s.version = '2.0.0'
s.version = package['version']
s.summary = 'Official MagicBell SDK for Swift'
s.description = 'Official MagicBell SDK for Swift. The notification inbox for your product.'

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-swift",
"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
42 changes: 42 additions & 0 deletions scripts/update-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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 = [
// Cocoapods instructions
{
files: 'README.md',
from: [
// Cocoapods instructions
/pod 'MagicBell', '>=\d\.\d\.\d'/g,
// Swift Package Manager instructions
/.upToNextMajor\(from: "\d\.\d\.\d"\)/g,
// Carthage instructions
/github "magicbell-io\/magicbell-swift" "\d\.\d\.\d"/g
],
to: [
`pod 'MagicBell', '>=${version}'`,
`.upToNextMajor(from: "${version}")`,
`github "magicbell-io/magicbell-swift" "${version}"`
],
},
// SDK version in Swift code
{
files: 'Source/MagicBellClient.swift',
from: /public static let version = "\d\.\d\.\d"/g,
to: `public static let 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
Loading