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
+
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 .
0 commit comments