Skip to content

Commit

Permalink
Merge pull request #2 from matrix-org/langleyd/kotlin_bindings_and_re…
Browse files Browse the repository at this point in the history
…lease_scripts

Kotlin bindings, tests, swift/kotlin CI validation and release script
  • Loading branch information
langleyd authored Aug 10, 2023
2 parents 603693b + 704131c commit b6e934e
Show file tree
Hide file tree
Showing 29 changed files with 823 additions and 95 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/android.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Validate Kotlin

on:
push:
branches: [ "main" ]
pull_request:

# Enrich gradle.properties for CI/CD
env:
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx4096m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon
ARCH: x86_64
DEVICE: Nexus 5X

jobs:
build:
runs-on: macos-latest
strategy:
matrix:
api-level: [31]
concurrency:
# When running on main, use the sha to allow all runs of this workflow to run concurrently.
# Otherwise only allow a single run of this workflow on each branch, automatically cancelling older runs.
group: ${{ github.workflow }}
cancel-in-progress: ${{ github.ref_name != 'main' }}

steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- uses: actions/setup-node@v3
with:
cache: "yarn"

- name: Setup json generation
run: "./scripts/setup.sh"

- name: Gerenate json
run: "./scripts/generateJson.sh"

- name: Setup Gradle & Build test cases
uses: gradle/gradle-build-action@v2
with:
build-root-directory: platforms/android
arguments: |
:library:assembleDebugAndroidTest ${{ env.CI_GRADLE_ARG_PROPERTIES }}
cache-read-only: false

- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: platforms/android
api-level: ${{ matrix.api-level }}
profile: ${{ env.DEVICE }}
arch: ${{ env.ARCH }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
enable-hw-keyboard: true
script: echo "Generated AVD snapshot for caching."

- uses: reactivecircus/android-emulator-runner@v2
with:
working-directory: platforms/android
api-level: ${{ matrix.api-level }}
arch: ${{ env.ARCH }}
profile: ${{ env.DEVICE }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
enable-hw-keyboard: true
script: |
./gradlew :library:connectedDebugAndroidTest ${{ env.CI_GRADLE_ARG_PROPERTIES }}
24 changes: 24 additions & 0 deletions .github/workflows/ios.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Validate Swift

on:
push:
branches: [ "main" ]
pull_request:

jobs:
build:
runs-on: macos-12

concurrency:
# When running on main, use the sha to allow all runs of this workflow to run concurrently.
# Otherwise only allow a single run of this workflow on each branch, automatically cancelling older runs.
group: ${{ github.workflow }}
cancel-in-progress: ${{ github.ref_name != 'main' }}

steps:
- uses: actions/checkout@v3
- name: Set XCode 14.2
run: sudo xcode-select -switch /Applications/Xcode_14.2.app

- name: Tests
run: exec ./platforms/ios/ios-tests.sh
79 changes: 79 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Release Automation
on:
workflow_dispatch:
inputs:
version-bump:
description: The scale of the version bump required for semver compatibility
required: true
default: patch
type: choice
options:
- patch
- minor
- major
concurrency: release


env:
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx4096m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ANDROID_SIGNING_GPG }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.ANDROID_SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }}
jobs:
release:
name: Release Bindingss for Kotlin and Swift
runs-on: ubuntu-latest
steps:
- name: 🧮 Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: 🔧 actions/setup-node@v3
with:
cache: "yarn"

- name: 🗜️ Setup
run: "./scripts/setup.sh"

- name: 🔨 Gerenate json
run: "./scripts/generateJson.sh"

- name: 👊 Bump yarn version
run: |
yarn version --no-git-tag-version --${{ github.event.inputs.version-bump }}
- name: 👊 Set the version in env
run: |
echo "NEW_VERSION=$(npm pkg get version)" >> $GITHUB_ENV
- name: 👊 Sync the version with android
run: |
./sync_android_version.sh ${{ env.NEW_VERSION }}
- name: 👊 Commit the version
run: |
git config --global user.name 'ElementRobot'
git config --global user.email '[email protected]'
git commit -am "${{ github.event.inputs.version-bump }} version bump"
git push
- name: 🛠️ Setup Java
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '11'

- name: ⬆️ Publish to Sonatype
uses: gradle/gradle-build-action@v2
with:
build-root-directory: platforms/android
arguments: publishAllPublicationsToMavenCentral
- name: 🚀 Close staging repo and release version
uses: gradle/gradle-build-action@v2
with:
build-root-directory: platforms/android
arguments: closeAndReleaseRepository
4 changes: 2 additions & 2 deletions .github/workflows/validate-json.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
cache: "yarn"

- name: Setup
run: "yarn install"
run: "./scripts/setup.sh"

- name: Gerenate json
run: "yarn start"
run: "./scripts/generateJson.sh"

- name: Validate it matches source
run: "git diff --exit-code"
94 changes: 6 additions & 88 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,94 +1,12 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
.DS_Store
## User settings
xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3

## Obj-C/Swift specific
*.hmap

## App packaging
*.ipa
*.dSYM.zip
*.dSYM

## Playgrounds
timeline.xctimeline
playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

.swiftpm
.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build/

# Accio dependency management
Dependencies/
.accio/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
.swiftpm/

*.js
node_modules
node_modules
platforms/android/.idea/
platforms/android/.gradle
platforms/android/local.properties
platforms/android/library/src/main/assets/emojibase.json
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version: 5.8
// swift-tools-version: 5.7.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Kotlin, Swift and Web bindings for emojibase json.
### Generating the emojibase.json

```
yarn install
yarn start
./scripts/setup.sh
./scripts/generateJson.sh
```
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { DATA_BY_CATEGORY } from "./emoji";
import * as fs from 'fs'

const json = JSON.stringify(DATA_BY_CATEGORY)
fs.writeFile("platforms/ios/Emojibase/Resources/emojibase.json", json, function(err) {
fs.writeFile("build/emojibase.json", json, function(err) {
if (err) {
console.log(err);
} else {
Expand Down
9 changes: 9 additions & 0 deletions platforms/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '8.0.2' apply false
id 'com.android.library' version '8.0.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.20' apply false
id 'org.jetbrains.kotlin.jvm' version '1.8.20' apply false
id 'com.google.devtools.ksp' version '1.8.20-1.0.10' apply false
id "com.vanniktech.maven.publish" version "0.25.3"
}
51 changes: 51 additions & 0 deletions platforms/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

# ===================
# Maven publishing
# ===================
SONATYPE_HOST=S01
RELEASE_SIGNING_ENABLED=true

GROUP=io.element.android
POM_ARTIFACT_ID=emojibase-bindings
VERSION_NAME=0.0.1

POM_NAME=Emojibase Bindings
POM_DESCRIPTION=Packages emojibase bindings for iOS and Android
POM_INCEPTION_YEAR=2023
POM_URL=https://github.com/matrix-org/emojibase-bindings

POM_LICENSE_NAME=The Apache Software License, Version 2.0
POM_LICENSE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENSE_DIST=repo

POM_SCM_URL=https://github.com/matrix-org/emojibase-bindings
POM_SCM_CONNECTION=scm:git:git://github.com/matrix-org/emojibase-bindings.git
POM_SCM_DEV_CONNECTION=scm:git:ssh://github.com/matrix-org/emojibase-bindings.git

POM_DEVELOPER_ID=matrixdev
POM_DEVELOPER_NAME=matrixdev
POM_DEVELOPER_URL=https://github.com/vector-im/
POM_DEVELOPER_EMAIL=[email protected]
Binary file not shown.
Loading

0 comments on commit b6e934e

Please sign in to comment.