Skip to content

Commit 53f6b4f

Browse files
committed
Update release.yml
1 parent 44cc3eb commit 53f6b4f

File tree

1 file changed

+56
-85
lines changed

1 file changed

+56
-85
lines changed

.github/workflows/release.yml

Lines changed: 56 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,34 @@
1+
permissions:
2+
contents: write
3+
14
name: Release
25

36
on:
47
push:
58
tags:
6-
- "v*.*.*" # Run workflow on version tags, e.g. v1.0.0.
9+
- 'v*' # Run workflow on version tags, e.g. v1.0.0.
710

811
jobs:
912
release:
1013
runs-on: ubuntu-latest
11-
14+
env:
15+
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
1216
steps:
13-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v3
1418

1519
- name: Setup Node.js environment
16-
uses: actions/setup-node@v2.1.2
20+
uses: actions/setup-node@v3
1721
with:
18-
node-version: "14.x"
22+
node-version: '16'
23+
cache: 'yarn'
1924

2025
- name: Setup Go environment
21-
uses: actions/setup-go@v2
22-
with:
23-
go-version: "1.15"
24-
25-
- name: Get yarn cache directory path
26-
id: yarn-cache-dir-path
27-
run: echo "::set-output name=dir::$(yarn cache dir)"
28-
29-
- name: Cache yarn cache
30-
uses: actions/cache@v2
31-
id: cache-yarn-cache
32-
with:
33-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
34-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
35-
restore-keys: |
36-
${{ runner.os }}-yarn-
37-
38-
- name: Cache node_modules
39-
id: cache-node-modules
40-
uses: actions/cache@v2
26+
uses: actions/setup-go@v3
4127
with:
42-
path: node_modules
43-
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
44-
restore-keys: |
45-
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
28+
go-version: '1.19'
4629

4730
- name: Install dependencies
48-
run: yarn install --frozen-lockfile;
49-
if: |
50-
steps.cache-yarn-cache.outputs.cache-hit != 'true' ||
51-
steps.cache-node-modules.outputs.cache-hit != 'true'
31+
run: yarn install --immutable --prefer-offline
5232

5333
- name: Build and test frontend
5434
run: yarn build
@@ -58,27 +38,32 @@ jobs:
5838
run: |
5939
if [ -f "Magefile.go" ]
6040
then
61-
echo "::set-output name=has-backend::true"
41+
echo "has-backend=true" >> $GITHUB_OUTPUT
6242
fi
6343
6444
- name: Test backend
6545
if: steps.check-for-backend.outputs.has-backend == 'true'
66-
uses: magefile/mage-action@v1
46+
uses: magefile/mage-action@v2
6747
with:
6848
version: latest
6949
args: coverage
7050

7151
- name: Build backend
7252
if: steps.check-for-backend.outputs.has-backend == 'true'
73-
uses: magefile/mage-action@v1
53+
uses: magefile/mage-action@v2
7454
with:
7555
version: latest
7656
args: buildAll
7757

58+
- name: Warn missing Grafana API key
59+
run: |
60+
echo Please generate a Grafana API key: https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/#generate-an-api-key
61+
echo Once done please follow the instructions found here: https://github.com/${{github.repository}}/blob/main/README.md#using-github-actions-release-workflow
62+
if: ${{ env.GRAFANA_API_KEY == '' }}
63+
7864
- name: Sign plugin
7965
run: yarn sign
80-
env:
81-
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
66+
if: ${{ env.GRAFANA_API_KEY != '' }}
8267

8368
- name: Get plugin metadata
8469
id: metadata
@@ -91,19 +76,19 @@ jobs:
9176
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
9277
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
9378
94-
echo "::set-output name=plugin-id::${GRAFANA_PLUGIN_ID}"
95-
echo "::set-output name=plugin-version::${GRAFANA_PLUGIN_VERSION}"
96-
echo "::set-output name=plugin-type::${GRAFANA_PLUGIN_TYPE}"
97-
echo "::set-output name=archive::${GRAFANA_PLUGIN_ARTIFACT}"
98-
echo "::set-output name=archive-checksum::${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}"
79+
echo "plugin-id=${GRAFANA_PLUGIN_ID}" >> $GITHUB_OUTPUT
80+
echo "plugin-version=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_OUTPUT
81+
echo "plugin-type=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_OUTPUT
82+
echo "archive=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT
83+
echo "archive-checksum=${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}" >> $GITHUB_OUTPUT
9984
100-
echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}
85+
echo "github-tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
10186
10287
- name: Read changelog
10388
id: changelog
10489
run: |
10590
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
106-
echo "::set-output name=path::release_notes.md"
91+
echo "path=release_notes.md" >> $GITHUB_OUTPUT
10792
10893
- name: Check package version
10994
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
@@ -114,51 +99,37 @@ jobs:
11499
mv dist ${{ steps.metadata.outputs.plugin-id }}
115100
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
116101
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
117-
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
102+
echo "checksum=$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)" >> $GITHUB_OUTPUT
118103
119-
- name: Lint plugin
104+
- name: Validate plugin
120105
run: |
121106
git clone https://github.com/grafana/plugin-validator
122-
pushd ./plugin-validator/pkg/cmd/plugincheck
107+
pushd ./plugin-validator/pkg/cmd/plugincheck2
123108
go install
124109
popd
125-
plugincheck ${{ steps.metadata.outputs.archive }}
110+
plugincheck2 -config ./plugin-validator/config/default.yaml ${{ steps.metadata.outputs.archive }}
126111
127-
- name: Create release
128-
id: create_release
129-
uses: actions/create-release@v1
130-
env:
131-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
- name: Create Github release
113+
uses: softprops/action-gh-release@v1
132114
with:
133-
tag_name: ${{ github.ref }}
134-
release_name: Release ${{ github.ref }}
135-
body_path: ${{ steps.changelog.outputs.path }}
136115
draft: true
137-
138-
- name: Add plugin to release
139-
id: upload-plugin-asset
140-
uses: actions/upload-release-asset@v1
141-
env:
142-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
143-
with:
144-
upload_url: ${{ steps.create_release.outputs.upload_url }}
145-
asset_path: ./${{ steps.metadata.outputs.archive }}
146-
asset_name: ${{ steps.metadata.outputs.archive }}
147-
asset_content_type: application/zip
148-
149-
- name: Add checksum to release
150-
id: upload-checksum-asset
151-
uses: actions/upload-release-asset@v1
152-
env:
153-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
154-
with:
155-
upload_url: ${{ steps.create_release.outputs.upload_url }}
156-
asset_path: ./${{ steps.metadata.outputs.archive-checksum }}
157-
asset_name: ${{ steps.metadata.outputs.archive-checksum }}
158-
asset_content_type: text/plain
159-
160-
- name: Publish to Grafana.com
161-
run: |
162-
echo A draft release has been created for your plugin. Please review and publish it. Then submit your plugin to grafana.com/plugins by opening a PR to https://github.com/grafana/grafana-plugin-repository with the following entry:
163-
echo
164-
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": "https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive }}", "md5": "${{ steps.package-plugin.outputs.checksum }}" } } } ] }' | jq .
116+
generate_release_notes: true
117+
files: |
118+
./${{ steps.metadata.outputs.archive }}
119+
./${{ steps.metadata.outputs.archive-checksum }}
120+
body: |
121+
**This Github draft release has been created for your plugin.**
122+
123+
_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_
124+
125+
If you would like to submit this release to Grafana please consider the following steps:
126+
127+
- 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
128+
- Navigate to https://grafana.com/auth/sign-in/ to sign into your account
129+
- Once logged in click **My Plugins** in the admin navigation
130+
- Click the **Submit Plugin** button
131+
- Fill in the Plugin Submission form:
132+
- 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
133+
- 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
134+
135+
Once done please remove these instructions and publish this release.

0 commit comments

Comments
 (0)