Skip to content

Commit

Permalink
Test plugin packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
bziobrowski committed Feb 22, 2024
1 parent 9712837 commit c1168b0
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: "Package Plugin"

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: 20

- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version: "1.21"

- name: Install yarn dependencies
run: yarn install
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Build Frontend
run: yarn build
env:
NODE_OPTIONS: '--max_old_space_size=4096'

- name: Test backend
uses: magefile/mage-action@v3
with:
version: latest
args: coverage

- name: Build backend
uses: magefile/mage-action@v3
with:
version: latest
args: buildAll

- name: Get plugin metadata
id: metadata
run: |
sudo apt-get install jq
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
export GRAFANA_PLUGIN_ARTIFACT_SHA1SUM=${GRAFANA_PLUGIN_ARTIFACT}.sha1

echo "plugin-id=${GRAFANA_PLUGIN_ID}" >> $GITHUB_OUTPUT
echo "plugin-version=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_OUTPUT
echo "plugin-type=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_OUTPUT
echo "archive=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT
echo "archive-sha1sum=${GRAFANA_PLUGIN_ARTIFACT_SHA1SUM}" >> $GITHUB_OUTPUT

echo "github-tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
shell: bash

- name: Package plugin
id: package-plugin
run: |
mv dist ${{ steps.metadata.outputs.plugin-id }}
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
sha1sum ${{ steps.metadata.outputs.archive }} | cut -f1 -d' ' > ${{ steps.metadata.outputs.archive-sha1sum }}
shell: bash

- name: Archive plugin build artifacts
uses: actions/upload-artifact@v4
with:
name: grafana-questdb-datasource.zip
path: ${{ steps.metadata.outputs.archive }}
retention-days: 7
File renamed without changes.

0 comments on commit c1168b0

Please sign in to comment.