Skip to content

Commit

Permalink
[Chore] Unity project with UPM embedded structure
Browse files Browse the repository at this point in the history
Also:

- [WebGL] Added `IsVibrateSupported()` method to main `.jslib`
- [WebGL] Added `repeat` parameter to `VibrateWithPattern()` method on main `.jslib`
- [Android] Added a generic static C# class for `AndroidBuild` to get Android API level
- [C#] Refactorings to better accomplish the scene example script `VibrationExample.cs`
  • Loading branch information
mfdeveloper committed Sep 21, 2023
1 parent 49a398e commit 41975fb
Show file tree
Hide file tree
Showing 181 changed files with 4,782 additions and 1,765 deletions.
72 changes: 72 additions & 0 deletions .github/scripts/functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

# USAGE: packageVersion "[PATH]/package.json"
packageVersion() {
local PACKAGE_JSON_FILE=$1
VERSION=""
while read a b ; do
[ "$a" = '"version":' ] && { b="${b%\"*}" ; VERSION="${b#\"}" ; break ; }
done < $PACKAGE_JSON_FILE
echo $VERSION
}

githubActionsOutputs() {
CURRENT_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
echo ::set-output name=tag::$CURRENT_TAG
echo ::set-output name=commit_message::$COMMIT_MESSAGE
}

copyPackagesContent() {
shopt -s extglob dotglob
cp -rvf "Packages/$PKG_NAME/." "$PKG_ROOT"
rm -rf ./Packages
}

commitAndPush() {
# Incrementing LAST_RELEASE_TAG+1.
# Keep here just to store the history, and if need this to the future/others repositories
#
# PS: Keep in mind that not always you would like to increment the git tag version (e.g rewriting with force an existent git tag)
# [[ "$LAST_RELEASE_TAG" =~ (.*[^0-9])([0-9]+)$ ]] && LAST_RELEASE_TAG="${BASH_REMATCH[1]}$((${BASH_REMATCH[2]} + 1))";

RELEASE_VERSION=$(packageVersion "./package.json")

echo "New version: $RELEASE_VERSION"

if [[ -d "Samples" ]]; then
mv Samples Samples~
rm -f Samples.meta
fi
if [[ -d "Documentation" ]]; then
mv Documentation Documentation~
rm -f Documentation.meta
fi
git config --global user.name 'github-bot'
git config --global user.email '[email protected]'
git add .
git commit --allow-empty -am "$COMMIT_MESSAGE"

echo $RELEASE_VERSION > VERSION.md~
git add VERSION.md~
git commit -am "fix: Samples => Samples~ and commit a new version: $RELEASE_VERSION"
git push -f -u origin "$PKG_BRANCH"
}

run() {
if [ $1 == "push" ]
then
commitAndPush
elif [ $1 == "movePackagesFolder" ]
then
copyPackagesContent
elif [ $1 == "githubActionsVariables" ]
then
githubActionsOutputs
else
echo "[ERROR] INVALID SCRIPT OPERATION"
exit 1
fi
}

run $1
63 changes: 33 additions & 30 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,41 @@ name: Unity Package CI
on:
push:
branches:
- upm-android-haptics
- upm-package-embedded
repository_dispatch:
types: [on-demand-test]
env:
PKG_ROOT: ./
PKG_BRANCH: upm
PKG_NAME: com.benoitfreslon.vibration
PKG_ROOT: ./
jobs:
split-upm:
name: Split upm branch (force)
name: Create upm package branch (force)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Split package folder to upm branch
run: |
if [ "$PKG_ROOT" == "./" ]
then
git checkout -b upm
else
git subtree split -P "$PKG_ROOT" -b upm
fi
- name: Create samples~ folder
run: |
git checkout upm
if [[ -d "Samples" ]]; then
git mv Samples Samples~
rm -f Samples.meta
git config --global user.name 'github-bot'
git config --global user.email '[email protected]'
git commit -am "fix: Samples => Samples~"
fi
- name: Push changes to upm branch
uses: ad-m/github-push-action@master
with:
force: true
branch: upm
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set output git tag and commit message
id: vars
run: ./.github/scripts/functions.sh githubActionsVariables
- name: Check output git variables
env:
LAST_RELEASE_TAG: ${{ steps.vars.outputs.tag }}
COMMIT_MESSAGE: ${{ steps.vars.outputs.commit_message }}
run: |
echo $LAST_RELEASE_TAG
echo $COMMIT_MESSAGE
- name: Checkout orphan [${{ env.PKG_BRANCH }}] branch
run: |
git checkout --orphan "$PKG_BRANCH"
shopt -s extglob dotglob
rm -rf !(Packages|.github|.git|README.md|README.md.meta|LICENSE|LICENSE.meta|.|..)
ls -la ./
- name: Move ./Packages content to root
run: ./.github/scripts/functions.sh movePackagesFolder
- name: Create Samples~ and Documentation~ folders
run: ./.github/scripts/functions.sh push
env:
LAST_RELEASE_TAG: ${{ steps.vars.outputs.tag }}
COMMIT_MESSAGE: ${{ steps.vars.outputs.commit_message }}
87 changes: 84 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
Expand All @@ -14,8 +14,8 @@
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/

# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta
# Recordings can get excessive in size
/[Rr]ecordings/

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
Expand Down Expand Up @@ -59,6 +59,7 @@ sysinfo.txt
*.apk
*.aab
*.unitypackage
*.app

# Crashlytics generated file
crashlytics-build.properties
Expand All @@ -69,3 +70,83 @@ crashlytics-build.properties
# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*

# --- Jetbrains IDE's ---
#
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
1 change: 0 additions & 1 deletion MobileProjects~/Android/.idea/.name

This file was deleted.

122 changes: 0 additions & 122 deletions MobileProjects~/Android/.idea/codeStyles/Project.xml

This file was deleted.

5 changes: 0 additions & 5 deletions MobileProjects~/Android/.idea/codeStyles/codeStyleConfig.xml

This file was deleted.

Loading

0 comments on commit 41975fb

Please sign in to comment.