diff --git a/.github/actions/setup-android/action.yml b/.github/actions/setup-android/action.yml new file mode 100644 index 00000000..1e24cb23 --- /dev/null +++ b/.github/actions/setup-android/action.yml @@ -0,0 +1,17 @@ +name: Setup Android envirionment + +runs: + using: "composite" + steps: + - name: Install JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: Install NDK 21 + shell: bash + run: echo "y" | /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.3.6528147" --sdk_root=${ANDROID_SDK_ROOT} + + - name: Install Ninja + shell: bash + run: sudo apt-get install -y ninja-build diff --git a/.github/actions/setup-website/action.yml b/.github/actions/setup-website/action.yml new file mode 100644 index 00000000..465a93f1 --- /dev/null +++ b/.github/actions/setup-website/action.yml @@ -0,0 +1,19 @@ +name: Setup Website envirionment + +runs: + using: "composite" + steps: + - name: Install NodeJS 12 + uses: actions/setup-node@v1 + with: + node-version: 12.x + + - name: yarn install + shell: bash + run: yarn install --frozen-lockfile + working-directory: website + + - name: yarn build + shell: bash + run: yarn build + working-directory: website diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 722d8a20..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: CI - -on: [push, pull_request] - -jobs: - website: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup Node.js - uses: actions/setup-node@v1 - with: - node-version: 12.x - - name: Install dependencies - run: yarn install --frozen-lockfile --ignore-scripts - working-directory: website - - name: Build - run: yarn build - working-directory: website - - name: Deploy - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_branch: gh-pages - publish_dir: website/public - cname: yogalayout.com - keep_files: true - user_name: 'Yoga-bot' - user_email: 'yogabot@fb.com' - android: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Install NDK 21 - run: echo "y" | sudo /usr/local/lib/android/sdk/tools/bin/sdkmanager --install "ndk;21.0.6113669" "ndk;20.0.5594570" --sdk_root=${ANDROID_SDK_ROOT} - - name: Install dependencies - run: | - if [[ -n "${{ secrets.encrypted_d27e803291ff_iv }}" ]]; then - openssl aes-256-cbc -K ${{ secrets.encrypted_d27e803291ff_key }} -iv {{ secrets.encrypted_d27e803291ff_iv }} -in scripts/setup-keys.enc -d >> gradle.properties; - fi - sudo apt-get update - sudo apt-get install -y ninja-build - pushd $HOME - git clone --depth 1 https://github.com/facebook/buck.git - cd buck - ant - popd - echo "$HOME/buck/bin" >> $GITHUB_PATH - export PATH=$PATH:$HOME/buck/bin/ - buck --version - - name: Build - # TODO: Run the tests here again. They're currently crashing the JVM in GitHub Actions for some reason. - run: ./gradlew :yoga-layout:assembleDebug diff --git a/.github/workflows/publish-android.yml b/.github/workflows/publish-android.yml new file mode 100644 index 00000000..01dac41a --- /dev/null +++ b/.github/workflows/publish-android.yml @@ -0,0 +1,47 @@ +name: Publish Android artifacts + +on: + release: + types: + - created + workflow_dispatch: + inputs: + version: + description: 'Version to publish as' + required: true + +jobs: + publish: + name: Upload to Maven Central + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-android + + - name: Write GPG secret keyring + run: echo '${{ secrets.GPG_KEY_CONTENTS }}' | base64 -d > /tmp/secring.gpg + + - name: Update gradle.properties + workingDirectory: ./target + run: | + if [ -z "${{ inputs.version }}" ]; then + echo "VERSION_NAME=${{ inputs.version }}" >> gradle.properties + else + version = `echo "${{ github.ref }}" | sed -E 's/v(.+)/\1/'` + echo "VERSION_NAME=$version" >> gradle.properties + fi + echo "signing.secretKeyRingFile=/tmp/secring.gpg" >> gradle.properties + echo "signing.keyId=${{ secrets.SIGNING_KEY_ID }}" >> gradle.properties + echo "signing.password=${{ secrets.SIGNING_PASSWORD }}" >> gradle.properties + echo "nmavenCentralPassword=${{ secrets.SONATYPE_NEXUS_PASSWORD }}" >> gradle.properties + echo "mavenCentralUsername=${{ secrets.SONATYPE_NEXUS_USERNAME }}" >> gradle.properties + + - name: Upload Android archives + workingDirectory: ./target + + run: ./gradlew :yoga:assembleRelease publish --info + + - name: Publish release + workingDirectory: ./target + run: ./gradlew closeAndReleaseRepository diff --git a/.github/workflows/publish-website.yml b/.github/workflows/publish-website.yml new file mode 100644 index 00000000..2ae71ba2 --- /dev/null +++ b/.github/workflows/publish-website.yml @@ -0,0 +1,26 @@ +name: Publish Website artifcats + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + publish: + name: Push to GitHub Pages + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-website + + - uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_branch: gh-pages + publish_dir: website/public + cname: yogalayout.com + keep_files: true + user_name: 'Yoga-bot' + user_email: 'yogabot@fb.com' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 1231fb66..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Publish - -on: - release: - types: - - created - workflow_dispatch: - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Install dependencies - run: source scripts/android-setup.sh && installAndroidSDK - - name: Write GPG Sec Ring - run: echo '${{ secrets.GPG_KEY_CONTENTS }}' | base64 -d > /tmp/secring.gpg - - name: Update gradle.properties - run: echo -e "signing.secretKeyRingFile=/tmp/secring.gpg\nsigning.keyId=${{ secrets.SIGNING_KEY_ID }}\nsigning.password=${{ secrets.SIGNING_PASSWORD }}\nmavenCentralPassword=${{ secrets.SONATYPE_NEXUS_PASSWORD }}\nmavenCentralUsername=${{ secrets.SONATYPE_NEXUS_USERNAME }}" >> gradle.properties - - name: Upload Android Archives - run: ./gradlew :yoga:assembleRelease publish --info - - name: Release and close - run: ./gradlew closeAndReleaseRepository - - name: Clean secrets - if: always() - run: rm /tmp/secring.gpg diff --git a/.github/workflows/valiadate-android.yml b/.github/workflows/valiadate-android.yml new file mode 100644 index 00000000..3ac8d8e3 --- /dev/null +++ b/.github/workflows/valiadate-android.yml @@ -0,0 +1,38 @@ +name: Android + +on: [push, pull_request, workflow_dispatch] + +jobs: + build: + name: Build (${{ matrix.mode }}) + runs-on: ubuntu-latest + strategy: + matrix: + mode: [Debug, Release] + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-android + + - name: Build + run: ./gradlew assemble${{ matrix.mode }} + + test: + name: Unit Tests (${{ matrix.mode }}) + runs-on: ubuntu-latest + strategy: + matrix: + mode: [Debug] + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-android + + - name: Build + run: ./gradlew assemble${{ matrix.mode }} + + - name: List + run: ls -R -l /home/runner/work/yoga/yoga/java + + - name: Run Java unit tests + run: ./gradlew :yoga:test${{ matrix.mode }}UnitTest --info diff --git a/.github/workflows/validate-website.yml b/.github/workflows/validate-website.yml new file mode 100644 index 00000000..e6e6fbfd --- /dev/null +++ b/.github/workflows/validate-website.yml @@ -0,0 +1,12 @@ +name: Website + +on: [push, pull_request, workflow_dispatch] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: ./.github/actions/setup-website diff --git a/README.md b/README.md index d1d65542..dcb76a27 100644 --- a/README.md +++ b/README.md @@ -63,26 +63,8 @@ This will now only run the standalone webpack build upon install. ## Maintainer Release Guide -To publish a new release, follow these steps: +Release artifacts are published automatically when a new GitHub release is +created. The publishing workflows may also be executed manually, given a Git +Tag, to re-attempt publish. -1. Ensure you have your GPG key set up and your [OSS Sonatype](https://oss.sonatype.org/) credentials handy. -2. Add the follow entries to either your local `gradle.properties` (don't forget to revert) or your global `~/.gradle/gradle.properties`: - -``` -# You get these from https://oss.sonatype.org/#profile;User%20Token -mavenCentralRepositoryUsername= -mavenCentralRepositoryPassword= - -# You can get the keyId (in GPG 1.4 format) by running `gpg1 --list-keys`. -signing.secretKeyRingFile= -signing.keyId= -signing.password= -``` - -3. Change the `VERSION_NAME` in `gradle.properties` to a non-SNAPSHOT release. -4. Commit and land the version change. -5. Run `./gradlew publishToMaven`. -6. Run `./gradlew closeAndReleaseRepository`. -7. Change the `VERSION_NAME` in `gradle.properties` back to a new SNAPSHOT release. -8. Commit and land the version change. -9. Celebrate! You've made a release! +NPM and NuGet packages are not currently published. diff --git a/build.gradle b/build.gradle index 4bffb4fd..ff43f4a7 100644 --- a/build.gradle +++ b/build.gradle @@ -37,33 +37,6 @@ ext { targetCompatibilityVersion = JavaVersion.VERSION_1_7 } -// If you have an idea on how to avoid this, please get in touch or -// answer https://stackoverflow.com/questions/43867014/how-to-use-the-gradle-ndk-build-to-compile-for-the-host-machine. -task copyNativeLibs(type: Copy, dependsOn: ':buckBuildNative') { - from "${rootDir}/buck-out/gen/java/tests#default,shared-library-symlink-tree/" - include '*.so' - include '*.dylib' - into "$buildDir/jniLibs" -} - -task buckBuildNative(type: Exec) { - workingDir rootDir - environment BUCKVERSION: 'last' - commandLine 'buck', 'build', '//java/...' -} - -allprojects { - afterEvaluate { - tasks.withType(Test) { - dependsOn copyNativeLibs - def libDir = "${rootDir}/build/jniLibs" - systemProperty 'java.library.path', libDir - environment 'LD_LIBRARY_PATH', libDir - environment 'DYLD_LIBRARY_PATH', libDir - } - } -} - task clean(type: Delete) { delete rootProject.buildDir } diff --git a/java/build.gradle b/java/build.gradle index c77068c3..2ee343b1 100644 --- a/java/build.gradle +++ b/java/build.gradle @@ -8,6 +8,8 @@ apply plugin: 'com.android.library' +// TODO Proguard consumers + android { compileSdkVersion rootProject.compileSdkVersion buildToolsVersion rootProject.buildToolsVersion @@ -47,7 +49,7 @@ android { } test { - java.srcDirs 'tests' + java.srcDir 'tests' } } } diff --git a/scripts/publish-snapshot.sh b/scripts/publish-snapshot.sh deleted file mode 100755 index 236d8055..00000000 --- a/scripts/publish-snapshot.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash -# -# Deploy a SNAPSHOT JAR after every successful CI run To Sonatype. - -# -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the LICENSE -# file in the root directory of this source tree. -# - -set -e - -BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )" -IS_SNAPSHOT="$(grep 'VERSION_NAME=[0-9\.]\+-SNAPSHOT' "$BASEDIR/gradle.properties")" - -if [ "$IS_SNAPSHOT" == "" ]; then - echo >&2 "Skipping build. Given build doesn't appear to be a SNAPSHOT release." -else - env TERMINAL=dumb "$BASEDIR/gradlew" publish -fi diff --git a/scripts/setup-keys.enc b/scripts/setup-keys.enc deleted file mode 100644 index 89144cbf..00000000 --- a/scripts/setup-keys.enc +++ /dev/null @@ -1 +0,0 @@ -kþèçßÞ=+\Mòènýmq6©Pƒáq³Z<¦c%§Þãjô¾d«–îŠÐ(¿Š»ê9C7P`]×ùæ®#ûZŸ+¼™‡ê¹^ 7¾¹‹ôÙ*–³¬rç`LàA™1m°’0h¥n% vâù \ No newline at end of file