Skip to content

Commit c7e2c4b

Browse files
authored
Update release.yml
1 parent 1b876ab commit c7e2c4b

File tree

1 file changed

+10
-119
lines changed

1 file changed

+10
-119
lines changed

.github/workflows/release.yml

+10-119
Original file line numberDiff line numberDiff line change
@@ -3,129 +3,20 @@ 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.
7+
8+
# necessary to create releases
9+
permissions:
10+
contents: write
711

812
jobs:
913
release:
1014
runs-on: ubuntu-latest
11-
env:
12-
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }}
13-
1415
steps:
15-
- uses: actions/checkout@v4
16-
17-
- name: Setup Node.js environment
18-
uses: actions/setup-node@v4
19-
with:
20-
node-version: '20'
21-
cache: 'yarn'
22-
23-
- name: Setup Go environment
24-
uses: actions/setup-go@v4
25-
with:
26-
go-version: '1.20'
27-
28-
- name: Install dependencies
29-
run: yarn install --immutable --prefer-offline
30-
31-
- name: Build and test frontend
32-
run: yarn build
33-
34-
- name: Check for backend
35-
id: check-for-backend
36-
run: |
37-
if [ -f "Magefile.go" ]
38-
then
39-
echo "::set-output name=has-backend::true"
40-
fi
41-
42-
- name: Test backend
43-
if: steps.check-for-backend.outputs.has-backend == 'true'
44-
uses: magefile/mage-action@v3
45-
with:
46-
version: latest
47-
args: coverage
48-
49-
- name: Build backend
50-
if: steps.check-for-backend.outputs.has-backend == 'true'
51-
uses: magefile/mage-action@v3
52-
with:
53-
version: latest
54-
args: buildAll
55-
56-
- name: Warn missing Grafana API key
57-
run: |
58-
echo Please generate a Grafana API key: https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/#generate-an-api-key
59-
echo Once done please follow the instructions found here: https://github.com/${{github.repository}}/blob/main/README.md#using-github-actions-release-workflow
60-
if: ${{ env.GRAFANA_API_KEY == '' }}
61-
62-
- name: Sign plugin
63-
run: yarn sign
64-
if: ${{ env.GRAFANA_API_KEY != '' }}
65-
66-
- name: Get plugin metadata
67-
id: metadata
68-
run: |
69-
sudo apt-get install jq
70-
71-
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
72-
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
73-
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
74-
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
75-
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
76-
77-
echo "plugin-id=${GRAFANA_PLUGIN_ID}" >> $GITHUB_OUTPUT
78-
echo "plugin-version=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_OUTPUT
79-
echo "plugin-type=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_OUTPUT
80-
echo "archive=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT
81-
echo "archive-checksum=${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}" >> $GITHUB_OUTPUT
82-
83-
echo "github-tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
84-
85-
- name: Read changelog
86-
id: changelog
87-
run: |
88-
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
89-
echo "path=release_notes.md" >> $GITHUB_OUTPUT
90-
91-
- name: Check package version
92-
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
93-
94-
- name: Package plugin
95-
id: package-plugin
96-
run: |
97-
mv dist ${{ steps.metadata.outputs.plugin-id }}
98-
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
99-
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
100-
echo "checksum=$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)" >> $GITHUB_OUTPUT
101-
102-
- name: Validate plugin
103-
run: |
104-
git clone https://github.com/grafana/plugin-validator
105-
pushd ./plugin-validator/pkg/cmd/plugincheck2
106-
go install
107-
popd
108-
plugincheck2 -config ./plugin-validator/config/default.yaml ${{ steps.metadata.outputs.archive }}
16+
- uses: actions/checkout@v3
10917

110-
- name: Create Github release
111-
uses: softprops/action-gh-release@v2
18+
- uses: grafana/plugin-actions/build-plugin@main
11219
with:
113-
draft: true
114-
generate_release_notes: true
115-
files: |
116-
./${{ steps.metadata.outputs.archive }}
117-
./${{ steps.metadata.outputs.archive-checksum }}
118-
body: |
119-
**This Github draft release has been created for your plugin.**
120-
121-
If you would like to submit this release to Grafana please consider the following steps:
122-
123-
- Check the Validate plugin step in the [release wourkflow](https://gihub.com/${{github.repository}}/commit/${{github.sha}}/checks/${{github.run_id}}) for any warnings that need attention
124-
- Navigate to https://grafana.com/auth/sign-in/ to sign into your account
125-
- Once logged in click **My Plugins** in the admin navigation
126-
- Click the **Submit Plugin** button
127-
- Fill in the Plugin Submission form:
128-
- 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
129-
- Paste this [.zip.md5 link](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.glugin-version }}/${{ steps.metadata.outputs.archive-checksum }}) in the MD5 field
130-
131-
Once done please remove these instructions and publish this release.
20+
# see https://grafana.com/developers/plugin-tools/publish-a-plugin/sign-a-plugin#generate-an-access-policy-token to generate it
21+
# save the value in your repository secrets
22+
policy_token: ${{ secrets.GRAFANA_ACCESS_POLICY_TOKEN }}

0 commit comments

Comments
 (0)