Skip to content

Commit 77c2a52

Browse files
build: Migrates to grafana plugin actions
1 parent aa23253 commit 77c2a52

File tree

2 files changed

+18
-126
lines changed

2 files changed

+18
-126
lines changed

.github/workflows/is-compatible.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: Latest Grafana API compatibility check
2-
on: [pull_request]
1+
name: Compatibility check
2+
on: [push]
33

44
jobs:
55
compatibilitycheck:
@@ -9,10 +9,13 @@ jobs:
99
- uses: actions/setup-node@v3
1010
with:
1111
node-version: '20'
12-
cache: 'yarn'
1312
- name: Install dependencies
14-
run: yarn install --immutable --prefer-offline
13+
run: npm install
1514
- name: Build plugin
16-
run: yarn build
15+
run: npm run build
1716
- name: Compatibility check
18-
run: npx @grafana/levitate@latest is-compatible --path src/module.ts --target @grafana/data,@grafana/ui,@grafana/runtime
17+
uses: grafana/plugin-actions/is-compatible@v1
18+
with:
19+
module: './src/module.ts'
20+
comment-pr: 'yes'
21+
fail-if-incompatible: 'no'

.github/workflows/release.yml

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

88
jobs:
99
release:
10+
permissions:
11+
id-token: write
12+
contents: write
13+
attestations: write
1014
runs-on: ubuntu-latest
11-
env:
12-
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
1315
steps:
14-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1517

16-
- name: Setup Node.js environment
17-
uses: actions/setup-node@v3
18+
- uses: grafana/plugin-actions/build-plugin@main
1819
with:
19-
node-version: '20'
20-
cache: 'yarn'
21-
22-
- name: Setup Go environment
23-
uses: actions/setup-go@v3
24-
with:
25-
go-version: '1.21'
26-
27-
- name: Install dependencies
28-
run: yarn install --immutable --prefer-offline
29-
30-
- name: Build and test frontend
31-
run: yarn build
32-
33-
- name: Check for backend
34-
id: check-for-backend
35-
run: |
36-
if [ -f "Magefile.go" ]
37-
then
38-
echo "has-backend=true" >> $GITHUB_OUTPUT
39-
fi
40-
41-
- name: Test backend
42-
if: steps.check-for-backend.outputs.has-backend == 'true'
43-
uses: magefile/mage-action@v1
44-
with:
45-
version: latest
46-
args: coverage
47-
48-
- name: Build backend
49-
if: steps.check-for-backend.outputs.has-backend == 'true'
50-
uses: magefile/mage-action@v1
51-
with:
52-
version: latest
53-
args: buildAll
54-
55-
- name: Warn missing Grafana API key
56-
run: |
57-
echo Please generate a Grafana API key: https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/#generate-an-api-key
58-
echo Once done please follow the instructions found here: https://github.com/${{github.repository}}/blob/main/README.md#using-github-actions-release-workflow
59-
if: ${{ env.GRAFANA_API_KEY == '' }}
60-
61-
- name: Sign plugin
62-
run: yarn sign
63-
if: ${{ env.GRAFANA_API_KEY != '' }}
64-
65-
- name: Get plugin metadata
66-
id: metadata
67-
run: |
68-
sudo apt-get install jq
69-
70-
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
71-
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
72-
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
73-
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
74-
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
75-
76-
echo "plugin-id=${GRAFANA_PLUGIN_ID}" >> $GITHUB_OUTPUT
77-
echo "plugin-version=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_OUTPUT
78-
echo "plugin-type=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_OUTPUT
79-
echo "archive=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT
80-
echo "archive-checksum=${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}" >> $GITHUB_OUTPUT
81-
82-
echo "github-tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
83-
84-
- name: Read changelog
85-
id: changelog
86-
run: |
87-
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
88-
echo "path=release_notes.md" >> $GITHUB_OUTPUT
89-
90-
- name: Check package version
91-
run: if [ "v${{ steps.metadata.outputs.plugin-version }}" != "${{ steps.metadata.outputs.github-tag }}" ]; then printf "\033[0;31mPlugin version doesn't match tag name\033[0m\n"; exit 1; fi
92-
93-
- name: Package plugin
94-
id: package-plugin
95-
run: |
96-
mv dist ${{ steps.metadata.outputs.plugin-id }}
97-
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
98-
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
99-
echo "checksum=$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)" >> $GITHUB_OUTPUT
100-
101-
- name: Validate plugin
102-
run: |
103-
git clone https://github.com/grafana/plugin-validator
104-
pushd ./plugin-validator/pkg/cmd/plugincheck2
105-
go install
106-
popd
107-
plugincheck2 -config ./plugin-validator/config/default.yaml ${{ steps.metadata.outputs.archive }}
108-
109-
- name: Create Github release
110-
uses: softprops/action-gh-release@v1
111-
with:
112-
draft: true
113-
generate_release_notes: true
114-
files: |
115-
./${{ steps.metadata.outputs.archive }}
116-
./${{ steps.metadata.outputs.archive-checksum }}
117-
body: |
118-
**This Github draft release has been created for your plugin.**
119-
120-
_Note: if this is the first release for your plugin please consult the [distributing-your-plugin section](https://github.com/${{github.repository}}/blob/main/README.md#distributing-your-plugin) of the README_
121-
122-
If you would like to submit this release to Grafana please consider the following steps:
123-
124-
- Check the Validate plugin step in the [release workflow](https://github.com/${{github.repository}}/commit/${{github.sha}}/checks/${{github.run_id}}) for any warnings that need attention
125-
- Navigate to https://grafana.com/auth/sign-in/ to sign into your account
126-
- Once logged in click **My Plugins** in the admin navigation
127-
- Click the **Submit Plugin** button
128-
- Fill in the Plugin Submission form:
129-
- Paste this [.zip asset link](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive }}) in the Plugin URL field
130-
- Paste this [.zip.md5 link](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive-checksum }}) in the MD5 field
131-
132-
Once done please remove these instructions and publish this release.
20+
policy_token: ${{ secrets.GRAFANA_ACCESS_POLICY_TOKEN }}
21+
attestation: true

0 commit comments

Comments
 (0)