Skip to content

Commit d7653f6

Browse files
committed
add release workflow
1 parent b311c2c commit d7653f6

2 files changed

Lines changed: 173 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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/setup-node@v2.1.2
17+
with:
18+
node-version: '12.x'
19+
20+
- name: Setup Go environment
21+
uses: actions/setup-go@v2
22+
with:
23+
go-version: '1.14'
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
41+
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-
46+
47+
- 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'
52+
53+
- name: Build and test frontend
54+
run: yarn dev # build release builds broken, see #17
55+
56+
- name: Check for backend
57+
id: check-for-backend
58+
run: |
59+
if [ -f "Magefile.go" ]
60+
then
61+
echo "::set-output name=has-backend::true"
62+
fi
63+
64+
- name: Test backend
65+
if: steps.check-for-backend.outputs.has-backend == 'true'
66+
uses: magefile/mage-action@v1
67+
with:
68+
version: latest
69+
args: coverage
70+
71+
- name: Build backend
72+
if: steps.check-for-backend.outputs.has-backend == 'true'
73+
uses: magefile/mage-action@v1
74+
with:
75+
version: latest
76+
args: buildAll
77+
78+
- name: Sign plugin
79+
run: yarn run grafana-toolkit plugin:sign
80+
env:
81+
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
82+
83+
- name: Get plugin metadata
84+
id: metadata
85+
run: |
86+
sudo apt-get install jq
87+
88+
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
89+
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
90+
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
91+
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
92+
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
93+
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}"
99+
100+
echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}
101+
102+
- name: Read changelog
103+
id: changelog
104+
run: |
105+
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
106+
echo "::set-output name=path::release_notes.md"
107+
108+
- name: Check package version
109+
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
110+
111+
- name: Package plugin
112+
id: package-plugin
113+
run: |
114+
mv dist ${{ steps.metadata.outputs.plugin-id }}
115+
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
116+
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)"
118+
119+
- name: Lint plugin
120+
run: |
121+
git clone https://github.com/grafana/plugin-validator
122+
pushd ./plugin-validator/cmd/plugincheck
123+
go install
124+
popd
125+
plugincheck ${{ steps.metadata.outputs.archive }}
126+
127+
- name: Create release
128+
id: create_release
129+
uses: actions/create-release@v1
130+
env:
131+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
with:
133+
tag_name: ${{ github.ref }}
134+
release_name: Release ${{ github.ref }}
135+
body_path: ${{ steps.changelog.outputs.path }}
136+
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 Publish 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": "${{ steps.upload-plugin-asset.outputs.browser_download_url }}", "md5": "${{ steps.package-plugin.outputs.checksum }}" } } } ] }' | jq .

CHANGELOG.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
# v1.2.0
1+
# Changelog
2+
3+
## v1.2.0
24

35
- **improvement** Add support for dashboard variable queries (@ggranberry #38)
46
- **bug fix** Properly scope variables, fixes repeated panel queries (@retzkek #41)
57

6-
# v1.1.4
8+
## v1.1.4
79

810
- **improvement** Use templateSrv to interpolate timeFrom and timeTo variables. (@carvid #31)
911
- **bug fix** Fix error in isRFC3339_ISO6801 when field is non-string (@ricochet1k #32, @retzkek #33)
1012

11-
# v1.1.3
13+
## v1.1.3
1214

1315
- use `QueryField` component for a nicer query editing experience (@michaelneale #24)
1416
- packaging, documentation, and testing improvements (@michaelneale #27, @retzkek #29)
1517
- **DEPRECATED**: no more Grafana 6 releases
1618

17-
# v1.1.2
19+
## v1.1.2
1820

1921
- Fix aliases in Grafana 7
2022

21-
# v1.1.1
23+
## v1.1.1
2224

2325
- Fixes error when null field in response
2426

25-
# v1.1.0
27+
## v1.1.0
2628

2729
- **BREAKING**: top-level `data` should no longer be included in data paths
2830
- support multiple data paths, comma-separated
2931

30-
# v1.0.0
32+
## v1.0.0
3133

3234
Initial release, basic support for tabular and timeseries data and annotations.

0 commit comments

Comments
 (0)