Skip to content

Commit 07c4a14

Browse files
authored
Add GitHub action to sign release (#13)
1 parent f0a3ed0 commit 07c4a14

File tree

4 files changed

+105
-5
lines changed

4 files changed

+105
-5
lines changed

.github/workflows/main.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Run workflow on version tags, e.g. v1.0.0.
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Setup Node.js environment
16+
uses: actions/[email protected]
17+
with:
18+
node-version: 12.x
19+
20+
- name: Install dependencies
21+
run: yarn install
22+
23+
- name: Build plugin
24+
run: yarn build
25+
26+
- name: Sign plugin
27+
run: npx @grafana/toolkit@canary plugin:sign
28+
env:
29+
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
30+
31+
- name: Get plugin information
32+
run: |
33+
sudo apt-get install jq
34+
35+
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
36+
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
37+
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
38+
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
39+
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
40+
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
47+
48+
- name: Package plugin
49+
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
53+
54+
- name: Create release
55+
id: create_release
56+
uses: actions/create-release@v1
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
with:
60+
tag_name: ${{ github.ref }}
61+
release_name: Release ${{ github.ref }}
62+
draft: false
63+
prerelease: false
64+
65+
- name: Add plugin to release
66+
id: upload-plugin-asset
67+
uses: actions/upload-release-asset@v1
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
with:
71+
upload_url: ${{ steps.create_release.outputs.upload_url }}
72+
asset_path: ./${{ env.GRAFANA_PLUGIN_ARTIFACT }}
73+
asset_name: ${{ env.GRAFANA_PLUGIN_ARTIFACT }}
74+
asset_content_type: application/zip
75+
76+
- name: Add checksum to release
77+
id: upload-checksum-asset
78+
uses: actions/upload-release-asset@v1
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
with:
82+
upload_url: ${{ steps.create_release.outputs.upload_url }}
83+
asset_path: ./${{ env.GRAFANA_PLUGIN_ARTIFACT_CHECKSUM }}
84+
asset_name: ${{ env.GRAFANA_PLUGIN_ARTIFACT_CHECKSUM }}
85+
asset_content_type: text/plain
86+
87+
- name: Get checksum
88+
run: |
89+
echo "GRAFANA_PLUGIN_CHECKSUM=$(cat ./${{ env.GRAFANA_PLUGIN_ARTIFACT_CHECKSUM }} | cut -d' ' -f1)" >> $GITHUB_ENV
90+
91+
- name: Publish to Grafana.com
92+
run: |
93+
echo Publish your plugin to grafana.com/plugins by opening a PR to https://github.com/grafana/grafana-plugin-repository with the following entry:
94+
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 .

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## v1.0.1
4+
5+
- Signed release
6+
37
## v1.0.0
48

59
- Initial release based on Grafana 7.2.0 and Redis Data Source 1.2.0.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
"test": "grafana-toolkit plugin:test",
2222
"watch": "grafana-toolkit plugin:dev --watch"
2323
},
24-
"version": "1.0.0"
24+
"version": "1.0.1"
2525
}

src/plugin.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@
2222
"type": "page"
2323
},
2424
{
25-
"type": "dashboard",
25+
"addToNav": true,
2626
"name": "Redis CLI",
2727
"path": "dashboards/redis-cli.json",
2828
"role": "Admin",
29-
"addToNav": true
29+
"type": "dashboard"
3030
},
3131
{
32-
"type": "dashboard",
32+
"addToNav": true,
3333
"name": "Redis Overview",
3434
"path": "dashboards/redis-overview.json",
3535
"role": "Admin",
36-
"addToNav": true
36+
"type": "dashboard"
3737
},
3838
{
3939
"name": "Redis CLI Panel",
@@ -45,6 +45,7 @@
4545
"name": "Redis Labs",
4646
"url": "https://oss.redislabs.com"
4747
},
48+
"description": "Redis Application",
4849
"keywords": ["redis", "timeseries", "plugin"],
4950
"links": [
5051
{

0 commit comments

Comments
 (0)