Skip to content

Commit 902a1a8

Browse files
committed
Update github action
1 parent aca524f commit 902a1a8

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

.github/workflows/main.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release
33
on:
44
push:
55
tags:
6-
- 'v*'
6+
- 'v*' # Run workflow on version tags, e.g. v1.0.0.
77

88
jobs:
99
release:
@@ -26,19 +26,22 @@ jobs:
2626
- name: Sign plugin
2727
run: npx @grafana/toolkit@canary plugin:sign
2828
env:
29-
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }}
29+
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
3030

3131
- name: Get plugin information
3232
run: |
3333
sudo apt-get install jq
3434
3535
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
3636
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
37+
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
3738
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
3839
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
3940
41+
# Output to $GITHUB_ENV to be able to use the variables in next steps.
4042
echo "GRAFANA_PLUGIN_ID=${GRAFANA_PLUGIN_ID}" >> $GITHUB_ENV
4143
echo "GRAFANA_PLUGIN_VERSION=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_ENV
44+
echo "GRAFANA_PLUGIN_TYPE=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_ENV
4245
echo "GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_ENV
4346
echo "GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}" >> $GITHUB_ENV
4447
@@ -47,7 +50,6 @@ jobs:
4750
mv dist $GRAFANA_PLUGIN_ID
4851
zip $GRAFANA_PLUGIN_ARTIFACT $GRAFANA_PLUGIN_ID -r
4952
md5sum $GRAFANA_PLUGIN_ARTIFACT > $GRAFANA_PLUGIN_ARTIFACT_CHECKSUM
50-
ls
5153
5254
- name: Create release
5355
id: create_release
@@ -60,7 +62,8 @@ jobs:
6062
draft: false
6163
prerelease: false
6264

63-
- name: Upload plugin
65+
- name: Add plugin to release
66+
id: upload-plugin-asset
6467
uses: actions/upload-release-asset@v1
6568
env:
6669
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -70,7 +73,8 @@ jobs:
7073
asset_name: ${{ env.GRAFANA_PLUGIN_ARTIFACT }}
7174
asset_content_type: application/zip
7275

73-
- name: Upload plugin checksum
76+
- name: Add checksum to release
77+
id: upload-checksum-asset
7478
uses: actions/upload-release-asset@v1
7579
env:
7680
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -79,3 +83,13 @@ jobs:
7983
asset_path: ./${{ env.GRAFANA_PLUGIN_ARTIFACT_CHECKSUM }}
8084
asset_name: ${{ env.GRAFANA_PLUGIN_ARTIFACT_CHECKSUM }}
8185
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

Comments
 (0)