Skip to content

Commit

Permalink
Add workflow to build/release plugins for OpenSearch
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
sduenas authored and dlumbrer committed Feb 17, 2022
1 parent 252a78a commit 6312d9c
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 11 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "kbnNetwork",
"version": "1.0.0",
"opensearchDashboardsVersion": "opensearchDashboards",
"opensearchDashboardsVersion": "1.2.0",
"server": false,
"ui": true,
"requiredPlugins": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 4 additions & 9 deletions yarn.lock
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# yarn lockfile v1


[email protected]:
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"
Expand All @@ -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==
[email protected].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"
Expand Down

0 comments on commit 6312d9c

Please sign in to comment.