Skip to content

Commit 05455d8

Browse files
committed
prepare for release
1 parent 3f85421 commit 05455d8

File tree

9 files changed

+178
-11
lines changed

9 files changed

+178
-11
lines changed

.github/workflows/release.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*" # Run workflow on version tags, e.g. v1.0.0.
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Setup Node.js environment
16+
uses: actions/[email protected]
17+
with:
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-
41+
42+
- name: Install dependencies
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'
47+
48+
- name: Build and test frontend
49+
run: yarn build
50+
51+
- name: Check for backend
52+
id: check-for-backend
53+
run: |
54+
if [ -f "Magefile.go" ]
55+
then
56+
echo "::set-output name=has-backend::true"
57+
fi
58+
59+
- name: Setup Go environment
60+
if: steps.check-for-backend.outputs.has-backend == 'true'
61+
uses: actions/setup-go@v2
62+
with:
63+
go-version: "1.16"
64+
65+
- name: Test backend
66+
if: steps.check-for-backend.outputs.has-backend == 'true'
67+
uses: magefile/mage-action@v1
68+
with:
69+
version: latest
70+
args: cover
71+
72+
- name: Build backend
73+
if: steps.check-for-backend.outputs.has-backend == 'true'
74+
uses: magefile/mage-action@v1
75+
with:
76+
version: latest
77+
args: buildAll
78+
79+
- name: Sign plugin
80+
run: yarn sign
81+
env:
82+
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
83+
84+
- name: Get plugin metadata
85+
id: metadata
86+
run: |
87+
sudo apt-get install jq
88+
89+
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
90+
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
91+
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
92+
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
93+
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
94+
95+
echo "::set-output name=plugin-id::${GRAFANA_PLUGIN_ID}"
96+
echo "::set-output name=plugin-version::${GRAFANA_PLUGIN_VERSION}"
97+
echo "::set-output name=plugin-type::${GRAFANA_PLUGIN_TYPE}"
98+
echo "::set-output name=archive::${GRAFANA_PLUGIN_ARTIFACT}"
99+
echo "::set-output name=archive-checksum::${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}"
100+
101+
echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}
102+
103+
- name: Read changelog
104+
id: changelog
105+
run: |
106+
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
107+
echo "::set-output name=path::release_notes.md"
108+
109+
- name: Check package version
110+
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
111+
112+
- name: Package plugin
113+
id: package-plugin
114+
run: |
115+
mv dist ${{ steps.metadata.outputs.plugin-id }}
116+
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
117+
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
118+
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
119+
120+
- name: Lint plugin
121+
run: |
122+
git clone https://github.com/grafana/plugin-validator
123+
pushd ./plugin-validator/cmd/plugincheck
124+
go install
125+
popd
126+
plugincheck ${{ steps.metadata.outputs.archive }}
127+
128+
- name: Create release
129+
id: create_release
130+
uses: actions/create-release@v1
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
133+
with:
134+
tag_name: ${{ github.ref }}
135+
release_name: Release ${{ github.ref }}
136+
body_path: ${{ steps.changelog.outputs.path }}
137+
draft: true
138+
139+
- name: Add plugin to release
140+
id: upload-plugin-asset
141+
uses: actions/upload-release-asset@v1
142+
env:
143+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144+
with:
145+
upload_url: ${{ steps.create_release.outputs.upload_url }}
146+
asset_path: ./${{ steps.metadata.outputs.archive }}
147+
asset_name: ${{ steps.metadata.outputs.archive }}
148+
asset_content_type: application/zip
149+
150+
- name: Add checksum to release
151+
id: upload-checksum-asset
152+
uses: actions/upload-release-asset@v1
153+
env:
154+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155+
with:
156+
upload_url: ${{ steps.create_release.outputs.upload_url }}
157+
asset_path: ./${{ steps.metadata.outputs.archive-checksum }}
158+
asset_name: ${{ steps.metadata.outputs.archive-checksum }}
159+
asset_content_type: text/plain
160+
161+
- name: Publish to Grafana.com
162+
run: |
163+
echo Publish your plugin to grafana.com/plugins by opening a PR to https://github.com/grafana/grafana-plugin-repository with the following entry:
164+
echo
165+
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.package-plugin.outputs.checksum }}" } } } ] }' | jq .

dist/img/ilert-logo-icon.png

3.56 KB
Loading

0 commit comments

Comments
 (0)