Skip to content

Commit d42127d

Browse files
committed
Update GitHub workflows
1 parent 3ddbadc commit d42127d

File tree

4 files changed

+104
-40
lines changed

4 files changed

+104
-40
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
node-version: [12.x]
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Setup Node.js environment
17+
uses: actions/setup-node@v2.1.2
18+
with:
19+
node-version: ${{ matrix.node-version }}
20+
21+
- name: Get yarn cache directory path
22+
id: yarn-cache-dir-path
23+
run: echo "::set-output name=dir::$(yarn cache dir)"
24+
25+
- name: Cache yarn cache
26+
uses: actions/cache@v2
27+
id: cache-yarn-cache
28+
with:
29+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
30+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
31+
restore-keys: |
32+
${{ runner.os }}-yarn-
33+
34+
- name: Cache node_modules
35+
id: cache-node-modules
36+
uses: actions/cache@v2
37+
with:
38+
path: node_modules
39+
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
40+
restore-keys: |
41+
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
42+
43+
- name: Install dependencies
44+
run: yarn install --frozen-lockfile
45+
46+
- name: Build and test
47+
run: yarn build

.github/workflows/release.yml

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,35 @@ jobs:
1515
- name: Setup Node.js environment
1616
uses: actions/setup-node@v2.1.2
1717
with:
18-
node-version: 12.x
18+
node-version: '12.x'
19+
20+
- name: Get yarn cache directory path
21+
id: yarn-cache-dir-path
22+
run: echo "::set-output name=dir::$(yarn cache dir)"
23+
24+
- name: Cache yarn cache
25+
uses: actions/cache@v2
26+
id: cache-yarn-cache
27+
with:
28+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
29+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-yarn-
32+
33+
- name: Cache node_modules
34+
id: cache-node-modules
35+
uses: actions/cache@v2
36+
with:
37+
path: node_modules
38+
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
39+
restore-keys: |
40+
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
1941
2042
- name: Install dependencies
21-
run: yarn install
43+
run: yarn install --frozen-lockfile;
44+
if: |
45+
steps.cache-yarn-cache.outputs.cache-hit != 'true' ||
46+
steps.cache-node-modules.outputs.cache-hit != 'true'
2247
2348
- name: Build plugin
2449
run: yarn build
@@ -28,7 +53,8 @@ jobs:
2853
env:
2954
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
3055

31-
- name: Get plugin information
56+
- name: Get plugin metadata
57+
id: metadata
3258
run: |
3359
sudo apt-get install jq
3460
@@ -38,18 +64,19 @@ jobs:
3864
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
3965
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
4066
41-
# Output to $GITHUB_ENV to be able to use the variables in next steps.
42-
echo "GRAFANA_PLUGIN_ID=${GRAFANA_PLUGIN_ID}" >> $GITHUB_ENV
43-
echo "GRAFANA_PLUGIN_VERSION=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_ENV
44-
echo "GRAFANA_PLUGIN_TYPE=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_ENV
45-
echo "GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_ENV
46-
echo "GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}" >> $GITHUB_ENV
67+
echo "::set-output name=plugin-id::${GRAFANA_PLUGIN_ID}"
68+
echo "::set-output name=plugin-version::${GRAFANA_PLUGIN_VERSION}"
69+
echo "::set-output name=plugin-type::${GRAFANA_PLUGIN_TYPE}"
70+
echo "::set-output name=archive::${GRAFANA_PLUGIN_ARTIFACT}"
71+
echo "::set-output name=archive-checksum::${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}"
4772
4873
- name: Package plugin
74+
id: package-plugin
4975
run: |
50-
mv dist $GRAFANA_PLUGIN_ID
51-
zip $GRAFANA_PLUGIN_ARTIFACT $GRAFANA_PLUGIN_ID -r
52-
md5sum $GRAFANA_PLUGIN_ARTIFACT > $GRAFANA_PLUGIN_ARTIFACT_CHECKSUM
76+
mv dist ${{ steps.metadata.outputs.plugin-id }}
77+
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
78+
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
79+
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
5380
5481
- name: Create release
5582
id: create_release
@@ -69,8 +96,8 @@ jobs:
6996
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7097
with:
7198
upload_url: ${{ steps.create_release.outputs.upload_url }}
72-
asset_path: ./${{ env.GRAFANA_PLUGIN_ARTIFACT }}
73-
asset_name: ${{ env.GRAFANA_PLUGIN_ARTIFACT }}
99+
asset_path: ./${{ steps.metadata.outputs.archive }}
100+
asset_name: ${{ steps.metadata.outputs.archive }}
74101
asset_content_type: application/zip
75102

76103
- name: Add checksum to release
@@ -80,16 +107,25 @@ jobs:
80107
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81108
with:
82109
upload_url: ${{ steps.create_release.outputs.upload_url }}
83-
asset_path: ./${{ env.GRAFANA_PLUGIN_ARTIFACT_CHECKSUM }}
84-
asset_name: ${{ env.GRAFANA_PLUGIN_ARTIFACT_CHECKSUM }}
110+
asset_path: ./${{ steps.metadata.outputs.archive-checksum }}
111+
asset_name: ${{ steps.metadata.outputs.archive-checksum }}
85112
asset_content_type: text/plain
86113

87-
- name: Get checksum
114+
- name: Setup Go environment
115+
uses: actions/setup-go@v2
116+
with:
117+
go-version: '1.14.12'
118+
119+
- name: Lint plugin
88120
run: |
89-
echo "GRAFANA_PLUGIN_CHECKSUM=$(cat ./${{ env.GRAFANA_PLUGIN_ARTIFACT_CHECKSUM }} | cut -d' ' -f1)" >> $GITHUB_ENV
121+
git clone https://github.com/grafana/plugin-validator;
122+
pushd ./plugin-validator/cmd/plugincheck;
123+
go install
124+
popd
125+
plugincheck ${{ steps.upload-plugin-asset.outputs.browser_download_url }};
90126
91127
- name: Publish to Grafana.com
92128
run: |
93129
echo Publish your plugin to grafana.com/plugins by opening a PR to https://github.com/grafana/grafana-plugin-repository with the following entry:
94130
echo
95-
echo '{ "id": "${{ env.GRAFANA_PLUGIN_ID }}", "type": "${{ env.GRAFANA_PLUGIN_TYPE }}", "url": "https://github.com/${{ github.repository }}", "versions": [ { "version": "${{ env.GRAFANA_PLUGIN_VERSION }}", "commit": "${{ github.sha }}", "url": "https://github.com/${{ github.repository }}", "download": { "any": { "url": "${{ steps.upload-plugin-asset.outputs.browser_download_url }}", "md5": "${{ env.GRAFANA_PLUGIN_CHECKSUM }}" } } } ] }' | jq .
131+
echo '{ "id": "${{ steps.metadata.outputs.plugin-id }}", "type": "${{ steps.metadata.outputs.plugin-type }}", "url": "https://github.com/${{ github.repository }}", "versions": [ { "version": "${{ steps.metadata.outputs.plugin-version }}", "commit": "${{ github.sha }}", "url": "https://github.com/${{ github.repository }}", "download": { "any": { "url": "${{ steps.upload-plugin-asset.outputs.browser_download_url }}", "md5": "${{ steps.metadata.package-plugin.checksum }}" } } } ] }' | jq .

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[![License](https://img.shields.io/github/license/marcusolsson/grafana-jsonapi-datasource)](LICENSE)
44
[![PRs welcome!](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](#contribute)
5+
[![Build](https://github.com/marcusolsson/grafana-jsonapi-datasource/workflows/CI/badge.svg)](https://github.com/marcusolsson/grafana-jsonapi-datasource/actions?query=workflow%3A%22CI%22)
6+
[![Release](https://github.com/marcusolsson/grafana-jsonapi-datasource/workflows/Release/badge.svg)](https://github.com/marcusolsson/grafana-jsonapi-datasource/actions?query=workflow%3ARelease)
57

68
A data source plugin for loading JSON APIs into [Grafana](https://grafana.com).
79

0 commit comments

Comments
 (0)