Skip to content
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
7 changes: 7 additions & 0 deletions .github/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
paths:
- src
- android/src/main/java
- .github/actions

paths-ignore:
- 'examples/**/android/**'
75 changes: 75 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!-- START -->

# READ AND DELETE THIS SECTION BEFORE SUBMITTING PR

- **Fill out each _REQUIRED_ section**
- **Fill out _OPTIONAL_ sections, remove section if it doesn't apply to your PR**
- **Read and fill out each of the checklists below**
- **Remove this section after reading**
<!-- END -->

# Description

## One Line Summary

**REQUIRED** - Very short description that summaries the changes in this PR.

## Details

### Motivation

**REQUIRED -** Why is this code change being made? Or what is the goal of this PR? Examples: Fixes a specific bug, provides additional logging to debug future issues, feature to allow X.

### Scope

**RECOMMEND - OPTIONAL -** What is intended to be effected. What is known not to change. Example: Notifications are grouped when parameter X is set, not enabled by default.

### OPTIONAL - Other

**OPTIONAL -** Feel free to add any other sections or sub-sections that can explain your PR better.

# Testing

## Unit testing

**OPTIONAL -** Explain unit tests added, if not clear in the code.

## Manual testing

**RECOMMEND - OPTIONAL -** Explain what scenarios were tested and the environment.
Example: Tested opening a notification while the app was foregrounded, app build with Android Studio 2020.3 with a fresh install of the OneSignal example app on a Pixel 6 with Android 12.

# Affected code checklist

- [ ] Notifications
- [ ] Display
- [ ] Open
- [ ] Push Processing
- [ ] Confirm Deliveries
- [ ] Outcomes
- [ ] Sessions
- [ ] In-App Messaging
- [ ] REST API requests
- [ ] Public API changes

# Checklist

## Overview

- [ ] I have filled out all **REQUIRED** sections above
- [ ] PR does one thing
- If it is hard to explain how any codes changes are related to each other then it most likely needs to be more than one PR
- [ ] Any Public API changes are explained in the PR details and conform to existing APIs

## Testing

- [ ] I have included test coverage for these changes, or explained why they are not needed
- [ ] All automated tests pass, or I explained why that is not possible
- [ ] I have personally tested this on my device, or explained why that is not possible

## Final pass

- [ ] Code is as readable as possible.
- Simplify with less code, followed by splitting up code into well named functions and variables, followed by adding comments to the code.
- [ ] I have reviewed this PR myself, ensuring it meets each checklist item
- WIP (Work In Progress) is ok, but explain what is still in progress and what you would like feedback on. Start the PR title with "WIP" to indicate this.
25 changes: 25 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Filename (cd.yml) should match the workflow filename in Trusted Publisher setting on npmjs
name: Publish to NPM & Github
on:
pull_request:
types:
- closed
branches:
- main
- rel/**

permissions:
id-token: write # Required for OIDC
contents: write

jobs:
publish:
if: |
github.event.pull_request.merged == true &&
contains(github.event.pull_request.title, 'chore: Release')
uses: OneSignal/sdk-shared/.github/workflows/publish-npm-github.yml@main
secrets:
GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }}
with:
branch: ${{ github.event.pull_request.base.ref }}
toolchain: vite-plus
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Run Checks
on:
pull_request:
branches:
- '**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
call:
uses: OneSignal/sdk-shared/.github/workflows/wrapper-js-ci.yml@main
with:
toolchain: vite-plus
66 changes: 66 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: 'CodeQL'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches: ['main']
pull_request:
branches: ['main']
schedule:
- cron: '37 19 * * 4'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
include:
- language: actions
build-mode: none
dependency-caching: true
- language: javascript-typescript
build-mode: none
dependency-caching: true
- language: java
build-mode: none
dependency-caching: true
# Not analyzing .m (Objective-C) & .h (Objective-C header) files for now unless CodeQL supports it in the future

steps:
- name: Checkout repository
uses: actions/checkout@v6

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v4

with:
dependency-caching: ${{ matrix.dependency-caching }}
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
config-file: ./.github/codeql-config.yml

- name: Autobuild
if: matrix.build-mode == 'autobuild'
uses: github/codeql-action/autobuild@v4

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: '/language:${{matrix.language}}'
174 changes: 174 additions & 0 deletions .github/workflows/create-release-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
name: Create Release PR

on:
# For making a release pr from android / ios sdk actions
workflow_call:
secrets:
GH_PUSH_TOKEN:
required: false
description: 'GitHub token for pushing changes'
inputs:
capacitor_version:
description: 'New Capacitor plugin version (e.g., 1.1.0 or 1.1.0-beta.1)'
required: true
type: string
android_version:
description: 'New Android SDK Version (e.g., 5.7.6). Leave blank to skip.'
required: false
type: string
ios_version:
description: 'New iOS SDK Version (e.g., 5.5.0). Leave blank to skip.'
required: false
type: string
target_branch:
description: 'Target branch to create the release PR on. Defaults to main.'
required: false
type: string
default: main

# For making a release pr from the github actions
workflow_dispatch:
inputs:
capacitor_version:
description: 'New Capacitor plugin version (e.g., 1.1.0 or 1.1.0-beta.1)'
required: true
type: string
android_version:
description: 'New Android SDK Version (e.g., 5.7.6). Leave blank to skip.'
required: false
type: string
ios_version:
description: 'New iOS SDK Version (e.g., 5.5.0). Leave blank to skip.'
required: false
type: string
target_branch:
description: 'Target branch to create the release PR on. Defaults to main.'
required: false
type: string
default: main

jobs:
prep:
uses: OneSignal/sdk-shared/.github/workflows/prep-release.yml@main
secrets:
# Need this cross-repo token (sdk-shared & this repo) to perform changes

GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }}
with:
target_repo: OneSignal/OneSignal-Capacitor-SDK
version: ${{ inputs.capacitor_version }}

# Capacitor plugin: bump npm version + optional native SDK pins
update_version:
needs: prep
runs-on: macos-latest
outputs:
capacitor_from: ${{ steps.current_versions.outputs.capacitor_from }}
ios_from: ${{ steps.current_versions.outputs.ios_from }}
android_from: ${{ steps.current_versions.outputs.android_from }}

steps:
- name: Checkout
uses: actions/checkout@v5
with:
# Need repository otherwise caller would set github.repository to the caller itself (e.g. sdk-shared)
repository: OneSignal/OneSignal-Capacitor-SDK
ref: ${{ needs.prep.outputs.release_branch }}
token: ${{ secrets.GH_PUSH_TOKEN || github.token }}

- name: Setup Git User
uses: OneSignal/sdk-shared/.github/actions/setup-git-user@main

- name: Set up Vite+
uses: voidzero-dev/setup-vp@v1
with:
cache: true
run-install: true

- name: Get current native SDK versions from target branch
id: current_versions
run: |
git fetch origin ${{ inputs.target_branch }}

# Get versions from target branch (not the release branch)
CURRENT_VERSION=$(git show origin/${{ inputs.target_branch }}:package.json | jq -r .version)
ANDROID_VERSION=$(git show origin/${{ inputs.target_branch }}:android/build.gradle.kts | grep "com.onesignal:OneSignal:" | sed -E "s/.*OneSignal:([0-9.]+).*/\1/")
IOS_VERSION=$(git show origin/${{ inputs.target_branch }}:OneSignalCapacitorPlugin.podspec | grep "OneSignalXCFramework" | sed -E "s/.*'([0-9.]+)'.*/\1/")

echo "capacitor_from=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "android_from=$ANDROID_VERSION" >> $GITHUB_OUTPUT
echo "ios_from=$IOS_VERSION" >> $GITHUB_OUTPUT

- name: Update Android SDK version
if: inputs.android_version != ''
run: |
VERSION="${{ inputs.android_version }}"

# Validate version exists on GitHub
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
"https://api.github.com/repos/OneSignal/OneSignal-Android-SDK/releases/tags/${VERSION}")


if [ -z "$RELEASE" ]; then
echo "✗ Android SDK version ${VERSION} not found"
exit 1
fi

# Update Android SDK version in build.gradle.kts
sed -i '' -E "s/(com\.onesignal:OneSignal:)[0-9.]+/\1$VERSION/" android/build.gradle.kts
echo "✓ Updated android/build.gradle.kts with Android SDK ${VERSION}"

# Only commit if there are changes
git add -A
git diff --staged --quiet && exit 0
git commit -m "Update Android SDK to ${VERSION}" && git push

- name: Update iOS SDK version
if: inputs.ios_version != ''
run: |
VERSION="${{ inputs.ios_version }}"

# Validate version exists on GitHub
RELEASE=$(curl -s -H "Authorization: token ${{ github.token }}" \
"https://api.github.com/repos/OneSignal/OneSignal-iOS-SDK/releases/tags/${VERSION}")

if [ -z "$RELEASE" ]; then
echo "✗ iOS SDK version ${VERSION} not found"
exit 1
fi

sed -i '' "s/s\.dependency 'OneSignalXCFramework', '[^']*'/s.dependency 'OneSignalXCFramework', '$VERSION'/" OneSignalCapacitorPlugin.podspec
echo "✓ Updated OneSignalCapacitorPlugin.podspec with iOS SDK ${VERSION}"

# Only commit if there are changes
git add -A
git diff --staged --quiet && exit 0
git commit -m "Update iOS SDK to ${VERSION}" && git push

- name: Update sdk version
run: |
NEW_VERSION="${{ inputs.capacitor_version }}"

# Update package.json version
npm pkg set version="$NEW_VERSION"

# Only commit if there are changes
git add -A
git diff --staged --quiet && exit 0
git commit -m "Release $NEW_VERSION" && git push

create-pr:
needs: [prep, update_version]
uses: OneSignal/sdk-shared/.github/workflows/create-release.yml@main
secrets:
# Need this cross-repo token (sdk-shared & this repo) to perform changes
GH_PUSH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }}
with:
# Need target_repo otherwise caller would set github.repository to the caller itself (e.g. sdk-shared)
target_repo: OneSignal/OneSignal-Capacitor-SDK
release_branch: ${{ needs.prep.outputs.release_branch }}
target_branch: ${{ inputs.target_branch }}
android_from: ${{ needs.update_version.outputs.android_from }}
android_to: ${{ inputs.android_version }}
ios_from: ${{ needs.update_version.outputs.ios_from }}
ios_to: ${{ inputs.ios_version }}
13 changes: 13 additions & 0 deletions .github/workflows/linear-deployed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Move Linear tickets to Deployed

on:
release:
types: [published, edited]

jobs:
linear-deployed:
uses: OneSignal/sdk-shared/.github/workflows/linear-deployed.yml@main
with:
release_body: ${{ github.event.release.body }}
secrets:
LINEAR_GITHUB_API_KEY: ${{ secrets.LINEAR_GITHUB_API_KEY }}
11 changes: 11 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Checks if the PR title follows semantic commit message conventions
name: Lint PR

on:
pull_request:
types: [opened, edited, synchronize]

jobs:
call:
uses: OneSignal/sdk-shared/.github/workflows/lint-pr-title.yml@main
secrets: inherit
Loading
Loading