From 6312d9cef99348f9d6226565eb7c34773653e07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Due=C3=B1as?= Date: Thu, 17 Feb 2022 13:19:42 +0100 Subject: [PATCH] Add workflow to build/release plugins for OpenSearch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this workflow for GitHub actions, the plugin will be built and released when a new tag with the prefix 'osd-' is created. This implies that all the tags that start with that prefix will build versions for OpenSearch. This commit also updates the version of OpenSearch to the latest. It's neccesary to build the plugin with the exact dependencies for that version. Signed-off-by: Santiago DueƱas --- .github/workflows/release.yml | 98 +++++++++++++++++++++++++++++++++++ opensearch_dashboards.json | 2 +- package.json | 2 +- yarn.lock | 13 ++--- 4 files changed, 104 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/release.yml mode change 100755 => 100644 yarn.lock diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..328b296 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,98 @@ +name: release + +on: + push: + tags: + - 'osd-*.*.*' + - 'osd-*.*.*-*' + +jobs: + build: + name: Build plugin + runs-on: ubuntu-latest + outputs: + filename: ${{ steps.build_zip.outputs.filename }} + steps: + - name: Checkout plugin source code + uses: actions/checkout@v2 + with: + path: plugin + - name: Get plugin metadata + id: plugin_metadata + run: | + echo "::set-output name=name::$(node -p "(require('./plugin/package.json').name)")" + echo "::set-output name=version::$(node -p "(require('./plugin/package.json').version).match(/[.0-9]+/)[0]")" + - name: Get OpenSearch Dashboards version + id: osd_version + run: | + echo "::set-output name=version::$(node -p "(require('./plugin/opensearch_dashboards.json').opensearchDashboardsVersion).match(/[.0-9]+/)[0]")" + - name: Checkout OpenSearch Dashboards + uses: actions/checkout@v2 + with: + repository: opensearch-project/OpenSearch-Dashboards + ref: ${{ steps.osd_version.outputs.version }} + path: osd + - name: Get node and yarn versions + id: versions + run: | + echo "::set-output name=node_version::$(node -p "(require('./osd/package.json').engines.node).match(/[.0-9]+/)[0]")" + echo "::set-output name=yarn_version::$(node -p "(require('./osd/package.json').engines.yarn).match(/[.0-9]+/)[0]")" + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: ${{ steps.versions.outputs.node_version }} + - name: Setup yarn + run: | + npm uninstall -g yarn + echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}" + npm i -g yarn@${{ steps.versions.outputs.yarn_version }} + - name: Move plugin to OpenSearch Dashboards folder + run: | + mkdir -p osd/plugins + mv plugin osd/plugins + - name: Bootstrap plugin/opensearch-dashboards + run: | + cd osd/plugins/plugin + yarn osd bootstrap + - name: Build plugin + id: build_zip + run: | + cd osd/plugins/plugin + yarn build + tmp_zip_path=`ls $(pwd)/build/*.zip` + filename=${{ steps.plugin_metadata.outputs.name }}-${{ steps.plugin_metadata.outputs.version }}_${{ steps.osd_version.outputs.version }}.zip + zip_path=$(pwd)/build/$filename + mv $tmp_zip_path $zip_path + echo "::set-output name=zip_path::$zip_path" + echo "::set-output name=filename::$filename" + - name: Upload plugin artifact + uses: actions/upload-artifact@v2 + with: + name: plugin_artifact + path: ${{ steps.build_zip.outputs.zip_path }} + + release: + name: Release plugin + needs: [build] + runs-on: ubuntu-latest + steps: + - name: Get release tag + id: tag + run: | + echo ::set-output name=tag::${GITHUB_REF#refs/tags/} + shell: bash + - name: Checkout plugin source code + uses: actions/checkout@v2 + with: + path: plugin + - name: Download plugin artifact + uses: actions/download-artifact@v2 + with: + name: plugin_artifact + path: plugin/build + - name: Create release + run: | + cd plugin + gh release create ${{ steps.tag.outputs.tag }} build/${{ needs.build.outputs.filename }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/opensearch_dashboards.json b/opensearch_dashboards.json index f970427..ee66b03 100644 --- a/opensearch_dashboards.json +++ b/opensearch_dashboards.json @@ -1,7 +1,7 @@ { "id": "kbnNetwork", "version": "1.0.0", - "opensearchDashboardsVersion": "opensearchDashboards", + "opensearchDashboardsVersion": "1.2.0", "server": false, "ui": true, "requiredPlugins": [ diff --git a/package.json b/package.json index b21532e..e2153bb 100755 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "vis-network": "^7.4.0", - "randomcolor": "^0.5.0", + "randomcolor": "0.5.3", "keycharm": "^0.2.0", "moment": "^2.24.0", "vis-data": "^6.5.1", diff --git a/yarn.lock b/yarn.lock old mode 100755 new mode 100644 index aaac6b6..f1dc403 --- a/yarn.lock +++ b/yarn.lock @@ -2,11 +2,6 @@ # yarn lockfile v1 -expr-eval@2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/expr-eval/-/expr-eval-2.0.2.tgz#fa6f044a7b0c93fde830954eb9c5b0f7fbc7e201" - integrity sha512-4EMSHGOPSwAfBiibw3ndnP0AvjDWLsMvGOvWEZ2F96IGk0bIVdjQisOHxReSkE13mHcfbuCiXw+G4y0zv6N8Eg== - keycharm@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/keycharm/-/keycharm-0.2.0.tgz#fa6ea2e43b90a68028843d27f2075d35a8c3e6f9" @@ -22,10 +17,10 @@ moment@^2.24.0: resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3" integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ== -randomcolor@^0.5.0: - version "0.5.4" - resolved "https://registry.yarnpkg.com/randomcolor/-/randomcolor-0.5.4.tgz#df615b13f25b89ea58c5f8f72647f0a6f07adcc3" - integrity sha512-nYd4nmTuuwMFzHL6W+UWR5fNERGZeVauho8mrJDUSXdNDbao4rbrUwhuLgKC/j8VCS5+34Ria8CsTDuBjrIrQA== +randomcolor@0.5.3: + version "0.5.3" + resolved "https://registry.yarnpkg.com/randomcolor/-/randomcolor-0.5.3.tgz#7f90f2f2a7f6d5a52232161eeaeeaea9ac3b5815" + integrity sha1-f5Dy8qf21aUiMhYe6u6uqaw7WBU= vis-data@^6.5.1: version "6.6.1"