From eb80fe9a08085c138be799e43ef2a3891fec2ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Mart=C3=ADn?= Date: Fri, 14 Feb 2025 13:21:20 +0100 Subject: [PATCH] Add publishing flows and script --- .github/workflows/publish.yaml | 19 ++++++ platforms/android/publish_android_package.sh | 61 ++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100755 platforms/android/publish_android_package.sh diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 2922465a..bb0f7d2c 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -63,3 +63,22 @@ jobs: docker_tags: | type=sha,format=short,event=branch type=semver,pattern=v{{version}} + publish_android: + needs: build_element_call + if: always() + name: Publish Android AAR + runs-on: ubuntu-latest + steps: + - name: 📥 Download artifact + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id || github.run_id }} + name: build-output + path: dist + - name: Publish AAR to GH gradle registry + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: platforms/android/publish_android_package.sh -s + + diff --git a/platforms/android/publish_android_package.sh b/platforms/android/publish_android_package.sh new file mode 100755 index 00000000..ad240c67 --- /dev/null +++ b/platforms/android/publish_android_package.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +EC_ASSETS_FOLDER=lib/src/main/assets/element-call +CURRENT_DIR=$( dirname -- "${BASH_SOURCE[0]}" ) + +pushd $CURRENT_DIR > /dev/null + +function build_assets() { + echo "Building the assets..." + pushd ../.. > /dev/null + yarn build + popd > /dev/null +} + +function copy_assets() { + if [ ! -d $EC_ASSETS_FOLDER ]; then + echo "Creating $EC_ASSETS_FOLDER..." + mkdir -p $EC_ASSETS_FOLDER + fi + + echo "Copying generated assets to the Android project..." + cp -R ../../dist/* $EC_ASSETS_FOLDER + + echo "Cleaning up copied assets..." + # Remove .gz assets as they will be marked as duplicate by the Android packaging process + rm $EC_ASSETS_FOLDER/index.html.gz 2> /dev/null + rm $EC_ASSETS_FOLDER/assets/*.gz 2> /dev/null +} + +getopts :sh opt +case $opt in + s) + echo "Using existing assets." + SKIP=1 + ;; + h) + echo "-s: will skip building the assets and just publish the library." + exit 0 + ;; +esac + +if [ -d $EC_ASSETS_FOLDER ]; then + if [ ! $SKIP ]; then + read -p "Do you want to re-build the assets (y/n, defaults to no)? " -n 1 -r + echo "" + if [[ $REPLY =~ ^[Yy]$ ]]; then + build_assets + else + echo "Using existing assets." + fi + fi + copy_assets +else + build_assets + copy_assets +fi + +echo "Publishing the Android project" +./gradlew publishAllPublicationsToGithubPackagesRepository + +popd > /dev/null \ No newline at end of file