From 9bb7e3b303359cc11da208b1258d78beb10c87d6 Mon Sep 17 00:00:00 2001 From: Keaton Sentak Date: Thu, 22 Aug 2024 13:12:01 -0400 Subject: [PATCH] update to remove cross compiler --- .github/workflows/release-github.yml | 215 ++++++++++++++++++--------- .github/workflows/utils.sh | 6 - 2 files changed, 147 insertions(+), 74 deletions(-) diff --git a/.github/workflows/release-github.yml b/.github/workflows/release-github.yml index 3c94696f7..943bbbb87 100644 --- a/.github/workflows/release-github.yml +++ b/.github/workflows/release-github.yml @@ -1,34 +1,40 @@ -name: Build & Compile CPP SDK +name: Release to GitHub and NPM on: workflow_dispatch: - + push: + branches: + - 'main' + - 'next' + - 'next-major' + - 'proposed' + pull_request: + types: [opened, synchronize] + branches: + - 'next' + - 'proposed' env: HUSKY: 0 - jobs: - build-and-compile: - name: Build & Compile CPP SDK + release: + name: Release runs-on: ubuntu-22.04 - steps: - - name: Checkout code + - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 + repo-token: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} + persist-credentials: false - - name: Setup node + - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '20' - - - name: Install node modules - run: npm ci + node-version: 'lts/*' - name: Install C++ dependencies run: | sudo apt-get update sudo apt-get install -y \ - python3-pip \ build-essential \ cmake \ pkg-config \ @@ -55,54 +61,82 @@ jobs: sudo \ ninja-build \ dpkg - - - name: Add toolchain for GCC 9 - run: sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt-get update - - name: Install cross compilation tools + - name: Set up NPM token + env: + NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} # <-- allow npm publish for each workspace + run: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc' + + - name: Install dependencies + run: npm ci + + # Set NPM_DIST_TAGS and DOCS_TAG if applicable based on branch + - name: Set main tags + if: github.ref_name == 'main' && github.event_name != 'pull_request' run: | - sudo apt-get install -y \ - gcc-9 \ - g++-9 \ - gcc-9-arm-linux-gnueabihf \ - g++-9-arm-linux-gnueabihf \ - libc6-armhf-cross \ - libc6-dev-armhf-cross - - - name: Set up env variables for cross-compilation - run: | - echo "CC=arm-linux-gnueabihf-gcc-9" >> $GITHUB_ENV - echo "CXX=arm-linux-gnueabihf-g++-9" >> $GITHUB_ENV - echo "CFLAGS=-O2" >> $GITHUB_ENV - echo "CXXFLAGS=-O2" >> $GITHUB_ENV - echo "LDFLAGS=-L/usr/arm-linux-gnueabihf/lib" >> $GITHUB_ENV - echo "SYSROOT=/usr/arm-linux-gnueabihf" >> $GITHUB_ENV - echo "PKG_CONFIG_PATH=$SYSROOT/lib/pkgconfig" >> $GITHUB_ENV - echo "LD_LIBRARY_PATH=$SYSROOT/lib" >> $GITHUB_ENV - - - name: Install zlib from source - run: | - wget https://zlib.net/zlib-1.3.1.tar.gz - tar -xzf zlib-1.3.1.tar.gz - cd zlib-1.3.1 - ./configure --prefix=${SYSROOT} --libdir=${SYSROOT}/lib --includedir=${SYSROOT}/include - make - sudo make install - - # Verify that zlib was installed correctly - ls -l ${SYSROOT}/lib/libz.so - ls -l ${SYSROOT}/include/zlib.h + echo "NPM_DIST_TAG=latest" >> $GITHUB_ENV + echo "DOCS_TAG=latest" >> $GITHUB_ENV + + - name: Set next tags + if: github.ref_name == 'next' && github.event_name != 'pull_request' + run: | + echo "NPM_DIST_TAG=next" >> $GITHUB_ENV + echo "DOCS_TAG=next" >> $GITHUB_ENV + + - name: Set next-major tags + if: github.ref_name == 'next-major' && github.event_name != 'pull_request' + run: | + echo "NPM_DIST_TAG=next-major" >> $GITHUB_ENV + echo "DOCS_TAG=next-major" >> $GITHUB_ENV + + - name: Set feature branch tags + if: github.ref_name != 'main' && github.ref_name != 'next' && github.ref_name != 'next-major' && github.event_name != 'pull_request' + run: | + echo "NPM_DIST_TAG=test" >> $GITHUB_ENV + echo "FEATURE_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV + + - name: Set PR tags + if: github.ref_name != 'main' && github.ref_name != 'next' && github.ref_name != 'next-major' && github.event_name == 'pull_request' + run: | + echo "NPM_DIST_TAG=test" >> $GITHUB_ENV + echo "DOCS_TAG=pr-$(node ./src/js/version.mjs branch-to-prerelease ${{ github.head_ref }})" >> $GITHUB_ENV + echo "FEATURE_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV - name: Set file permissions run: | chmod -R 755 ./ chown -R $(id -u):$(id -g) ./ - - name: Install jsonref - run: pip3 install jsonref + # Perform real (When not a PR) or dry-run (When PR) semantic-release + - name: Release mono-artifact to GitHub + if: (github.ref_name != 'main' && github.event_name != 'pull_request') || github.event_name == 'workflow_dispatch' + env: + GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches + DEBUG: semantic-release:* + run: | + git config --global --add safe.directory /__w/firebolt-apis/firebolt-apis + npx semantic-release + + - name: Dry-run mono-artifact + if: (github.ref_name == 'main' && github.event_name != 'workflow_dispatch') || github.event_name == 'pull_request' + env: + GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches + run: npx semantic-release --dry-run - # - name: Generate js sdk - # run: npm run dist + - name: Build artifacts for feature branches + if: github.ref_name != 'main' && github.ref_name != 'next' && github.ref_name != 'next-major' + run: | + PRERELEASE=$(node ./src/js/version.mjs branch-to-prerelease $FEATURE_BRANCH) + node ./src/js/version.mjs latest-prerelease $PRERELEASE + npm version prerelease --preid $PRERELEASE --git-tag-version false + npm version prerelease --preid $PRERELEASE --workspaces --git-tag-version false + npm run dist + + - name: Check if semantic-release created a build + id: check_build + uses: andstor/file-existence-action@v2 + with: + files: './src/sdks/core/dist/lib/firebolt.mjs' - name: Get version from package.json run: | @@ -110,26 +144,71 @@ jobs: echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV echo "build_cpp_source=true" >> $GITHUB_ENV - # - name: Generate native sdk source - # if: env.build_cpp_source == 'true' - # run: | - # .github/workflows/utils.sh generateSource - + - name: Set cpp build source Condition + if: steps.check_build.outputs.files_exists == 'false' || (github.ref_name == 'main' && github.event_name != 'pull_request' && github.event_name != 'workflow_dispatch') + run: echo "build_cpp_source=false" >> $GITHUB_ENV + + - name: Generate native sdk source + if: env.build_cpp_source == 'true' + run: | + .github/workflows/utils.sh generateSource + - name: Clone and Install Thunder if: env.build_cpp_source == 'true' id: install_thunder run: | .github/workflows/utils.sh cloneAndInstallThunder - - # - name: Build Core SDK CPP + + - name: Build Core SDK CPP + if: env.build_cpp_source == 'true' + id: build_core_cpp + run: | + .github/workflows/utils.sh buildCoreCPPSDK $RELEASE_VERSION + + # - name: Build Manage SDK CPP # if: env.build_cpp_source == 'true' - # id: build_core_cpp + # id: build_manage_cpp # run: | - # .github/workflows/utils.sh buildCoreCPPSDK $RELEASE_VERSION - - # - name: Upload SDK artifact - # if: success() - # uses: actions/upload-artifact@v3 - # with: - # name: core-sdk - # path: firebolt-apis/src/sdks/core/build/cpp/src/*.tgz + # .github/workflows/utils.sh buildManageCPPSDK $RELEASE_VERSION + + # - name: Build Discovery SDK CPP + # if: env.build_cpp_source == 'true' + # id: build_discovery_cpp + # run: | + # .github/workflows/utils.sh buildDiscoveryCPPSDK $RELEASE_VERSION + + - name: Release Firebolt SDKs to NPM + if: steps.check_build.outputs.files_exists == 'true' && github.event_name != 'pull_request' && (github.ref_name != 'main' || github.event_name == 'workflow_dispatch') + env: + NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} # <-- Allows semantic-release to publish to npm without 2 factor auth. + run: | + npm --version + echo "NPM DIST TAG ::: " $NPM_DIST_TAG + npm publish --tag $NPM_DIST_TAG --workspaces + + - name: Dry-run Firebolt SDKs to NPM + if: steps.check_build.outputs.files_exists == 'true' && (github.ref_name == 'main' && github.event_name != 'workflow_dispatch') + env: + NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_NPM_TOKEN }} # <-- Allows semantic-release to publish to npm without 2 factor auth. + run: npm publish --tag $NPM_DIST_TAG --workspaces --dry-run + + - name: Checkout firebolt GitHub.io repository + if: steps.check_build.outputs.files_exists == 'true' + env: + GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches + run: | + cd /tmp + git clone https://rdkcentral:$GITHUB_TOKEN@github.com/rdkcentral/firebolt.git ./firebolt-docs + + - name: Release docs to GitHub.io + if: steps.check_build.outputs.files_exists == 'true' && (github.ref_name == 'main' || github.ref_name == 'next' || github.ref_name == 'next-major' || github.event_name == 'pull_request') + env: + GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_PAT }} # <-- Allows semantic-release-bot to push changes to protected branches + run: | + npm run publish:docs /tmp/firebolt-docs $DOCS_TAG + cd /tmp/firebolt-docs + git config --global user.email "you@example.com" + git config --global user.name "Your Name" + git add --all + git diff-index --quiet HEAD || git commit -m "chore: Publish $DOCS_TAG" + git push \ No newline at end of file diff --git a/.github/workflows/utils.sh b/.github/workflows/utils.sh index 3016816d2..abd8043a6 100755 --- a/.github/workflows/utils.sh +++ b/.github/workflows/utils.sh @@ -267,10 +267,6 @@ function cloneAndInstallThunder() { -DBUILD_SHARED_LIBS=ON \ -DBINDING="127.0.0.1" \ -DCMAKE_BUILD_TYPE="Debug" \ - -DCMAKE_SYSTEM_NAME=Linux \ - -DCMAKE_SYSTEM_PROCESSOR=armv7-a \ - -DCMAKE_C_COMPILER=${CC} \ - -DCMAKE_CXX_COMPILER=${CXX} \ -DCMAKE_INSTALL_PREFIX="install/usr" \ -DCMAKE_MODULE_PATH="${PWD}/install/usr/include/WPEFramework/Modules" \ -DDATA_PATH="${PWD}/install/usr/share/WPEFramework" \ @@ -278,8 +274,6 @@ function cloneAndInstallThunder() { -DPORT="55555" \ -DPROXYSTUB_PATH="${PWD}/install/usr/lib/wpeframework/proxystubs" \ -DSYSTEM_PATH="${PWD}/install/usr/lib/wpeframework/plugins" \ - -DZLIB_LIBRARY=${SYSROOT}/lib/libz.so \ - -DZLIB_INCLUDE_DIR=${SYSROOT}/include \ -DVOLATILE_PATH="tmp" && echo "Thunder configure succeeded" || exit 9999 cmake --build build/Thunder --target install && echo "Thunder Build succeeded" || exit 9999