Skip to content

Commit 0df6fc1

Browse files
committed
Add release github action
Removed `/dist` folder from git repository. That means that it's no longer possible to install this Grafana plugin by `git clone`. If you use `git pull` to update the plugin, you will have to change your deployment strategy of this plugin. Please refer to the official documentation: https://docs.checkmk.com/2.1.0/en/grafana.html
1 parent 70669d1 commit 0df6fc1

File tree

14 files changed

+144
-538
lines changed

14 files changed

+144
-538
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: CI
22

33
on:
44
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
510
jobs:
611
build:
712
runs-on: ubuntu-latest
@@ -22,3 +27,24 @@ jobs:
2227

2328
- name: Build and test frontend
2429
run: yarn build
30+
31+
- name: Upload package for e2e tests
32+
uses: actions/upload-artifact@v3
33+
with:
34+
name: plugin-build-result
35+
path: dist
36+
37+
e2e:
38+
runs-on: ubuntu-latest
39+
needs: build
40+
steps:
41+
- uses: actions/checkout@v3
42+
43+
- name: Download package from build job
44+
uses: actions/download-artifact@v3
45+
with:
46+
name: plugin-build-result
47+
48+
- name: run the e2e tests
49+
run: docker-compose up --exit-code-from=cypress
50+
working-directory: tests/

.github/workflows/e2e.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Setup Node.js environment
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: '14'
17+
cache: 'yarn'
18+
19+
- name: Install dependencies
20+
run: yarn install --frozen-lockfile
21+
22+
- name: Build and test frontend
23+
run: yarn build
24+
25+
- name: Get plugin metadata
26+
id: metadata
27+
run: |
28+
sudo apt-get install jq
29+
30+
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
31+
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
32+
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
33+
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
34+
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
35+
36+
echo "::set-output name=plugin-id::${GRAFANA_PLUGIN_ID}"
37+
echo "::set-output name=plugin-version::${GRAFANA_PLUGIN_VERSION}"
38+
echo "::set-output name=plugin-type::${GRAFANA_PLUGIN_TYPE}"
39+
echo "::set-output name=archive::${GRAFANA_PLUGIN_ARTIFACT}"
40+
echo "::set-output name=archive-checksum::${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}"
41+
42+
echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}
43+
44+
- name: Read changelog
45+
id: changelog
46+
run: |
47+
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
48+
echo "::set-output name=path::release_notes.md"
49+
50+
- name: Check package version
51+
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
52+
53+
- name: Package plugin
54+
id: package-plugin
55+
run: |
56+
mv dist ${{ steps.metadata.outputs.plugin-id }}
57+
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
58+
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
59+
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
60+
61+
# does not work with unsigned plugins!
62+
# - name: Lint plugin
63+
# run: |
64+
# git clone https://github.com/grafana/plugin-validator
65+
# BIN_PATH=`pwd`
66+
# pushd ./plugin-validator/pkg/cmd/plugincheck
67+
# go build -o $BIN_PATH/plugincheck
68+
# popd
69+
# ./plugincheck ${{ steps.metadata.outputs.archive }}
70+
71+
- name: Create release
72+
id: create_release
73+
uses: actions/create-release@v1
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
with:
77+
tag_name: ${{ github.ref }}
78+
release_name: Release ${{ github.ref }}
79+
body_path: ${{ steps.changelog.outputs.path }}
80+
draft: true
81+
82+
- name: Add plugin to release
83+
id: upload-plugin-asset
84+
uses: actions/upload-release-asset@v1
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
with:
88+
upload_url: ${{ steps.create_release.outputs.upload_url }}
89+
asset_path: ./${{ steps.metadata.outputs.archive }}
90+
asset_name: ${{ steps.metadata.outputs.archive }}
91+
asset_content_type: application/zip
92+
93+
- name: Add checksum to release
94+
id: upload-checksum-asset
95+
uses: actions/upload-release-asset@v1
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
with:
99+
upload_url: ${{ steps.create_release.outputs.upload_url }}
100+
asset_path: ./${{ steps.metadata.outputs.archive-checksum }}
101+
asset_name: ${{ steps.metadata.outputs.archive-checksum }}
102+
asset_content_type: text/plain

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ lib-cov
2020
coverage
2121

2222
# Compiled binary addons (https://nodejs.org/api/addons.html)
23-
# dist/
23+
dist/
2424
artifacts/
2525
work/
2626
ci/

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
[//]: # (The ci will use the first section starting with `##` as release notes.)
44

5+
## NEXT
6+
7+
* Removed `/dist` folder from git repository. That means that it's no longer
8+
possible to install this Grafana plugin by `git clone`. If you use `git pull`
9+
to update the plugin, you will have to change your deployment strategy of
10+
this plugin. Please refer to the [official documentation][1]
11+
12+
[1]: https://docs.checkmk.com/2.1.0/en/grafana.html
13+
514
## 2.0.1
615

716
* README.md already states that at least Grafana 8.0.0 is required, now the

DEVELOPMENT.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ yarn upgrade --latest
4545

4646
## Release
4747

48-
TBD
49-
48+
* create pull request:
49+
* adapt version in package.json to `X.Y.Z`
50+
* add section in CHANGELOG.md: `## X.Y.Z`
51+
* merge pull request into main branch
52+
* tag commit in the main branch with `vX.Y.Z`
53+
* save release draft on github
5054

5155
## E2E Tests
5256
There are serval ways to run the e2e tests.

0 commit comments

Comments
 (0)