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 : Build backend
27
+ run : mage -v buildAll
28
+
29
+ - name : Sign plugin
30
+ run : npx @grafana/toolkit@canary plugin:sign
31
+ env :
32
+ GRAFANA_API_KEY : ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
33
+
34
+ - name : Get plugin information
35
+ run : |
36
+ sudo apt-get install jq
37
+
38
+ export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
39
+ export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
40
+ export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
41
+ export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
42
+ export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
43
+
44
+ # Output to $GITHUB_ENV to be able to use the variables in next steps.
45
+ echo "GRAFANA_PLUGIN_ID=${GRAFANA_PLUGIN_ID}" >> $GITHUB_ENV
46
+ echo "GRAFANA_PLUGIN_VERSION=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_ENV
47
+ echo "GRAFANA_PLUGIN_TYPE=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_ENV
48
+ echo "GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_ENV
49
+ echo "GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}" >> $GITHUB_ENV
50
+
51
+ - name : Package plugin
52
+ run : |
53
+ mv dist $GRAFANA_PLUGIN_ID
54
+ zip $GRAFANA_PLUGIN_ARTIFACT $GRAFANA_PLUGIN_ID -r
55
+ md5sum $GRAFANA_PLUGIN_ARTIFACT > $GRAFANA_PLUGIN_ARTIFACT_CHECKSUM
56
+
57
+ - name : Create release
58
+ id : create_release
59
+ uses : actions/create-release@v1
60
+ env :
61
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
62
+ with :
63
+ tag_name : ${{ github.ref }}
64
+ release_name : Release ${{ github.ref }}
65
+ draft : false
66
+ prerelease : false
67
+
68
+ - name : Add plugin to release
69
+ id : upload-plugin-asset
70
+ uses : actions/upload-release-asset@v1
71
+ env :
72
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
73
+ with :
74
+ upload_url : ${{ steps.create_release.outputs.upload_url }}
75
+ asset_path : ./${{ env.GRAFANA_PLUGIN_ARTIFACT }}
76
+ asset_name : ${{ env.GRAFANA_PLUGIN_ARTIFACT }}
77
+ asset_content_type : application/zip
78
+
79
+ - name : Add checksum to release
80
+ id : upload-checksum-asset
81
+ uses : actions/upload-release-asset@v1
82
+ env :
83
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
84
+ with :
85
+ upload_url : ${{ steps.create_release.outputs.upload_url }}
86
+ asset_path : ./${{ env.GRAFANA_PLUGIN_ARTIFACT_CHECKSUM }}
87
+ asset_name : ${{ env.GRAFANA_PLUGIN_ARTIFACT_CHECKSUM }}
88
+ asset_content_type : text/plain
89
+
90
+ - name : Get checksum
91
+ run : |
92
+ echo "GRAFANA_PLUGIN_CHECKSUM=$(cat ./${{ env.GRAFANA_PLUGIN_ARTIFACT_CHECKSUM }} | cut -d' ' -f1)" >> $GITHUB_ENV
93
+
94
+ - name : Publish to Grafana.com
95
+ run : |
96
+ echo Publish your plugin to grafana.com/plugins by opening a PR to https://github.com/grafana/grafana-plugin-repository with the following entry:
97
+ echo
98
+ 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