@@ -15,10 +15,35 @@ jobs:
15
15
- name : Setup Node.js environment
16
16
uses : actions/setup-node@v2.1.2
17
17
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-
19
41
20
42
- 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'
22
47
23
48
- name : Build plugin
24
49
run : yarn build
28
53
env :
29
54
GRAFANA_API_KEY : ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
30
55
31
- - name : Get plugin information
56
+ - name : Get plugin metadata
57
+ id : metadata
32
58
run : |
33
59
sudo apt-get install jq
34
60
@@ -38,18 +64,19 @@ jobs:
38
64
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
39
65
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
40
66
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}"
47
72
48
73
- name : Package plugin
74
+ id : package-plugin
49
75
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)"
53
80
54
81
- name : Create release
55
82
id : create_release
69
96
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
70
97
with :
71
98
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 }}
74
101
asset_content_type : application/zip
75
102
76
103
- name : Add checksum to release
@@ -80,16 +107,25 @@ jobs:
80
107
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
81
108
with :
82
109
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 }}
85
112
asset_content_type : text/plain
86
113
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
88
120
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 }};
90
126
91
127
- name : Publish to Grafana.com
92
128
run : |
93
129
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
130
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 .
0 commit comments