-
Notifications
You must be signed in to change notification settings - Fork 5
99 lines (99 loc) · 3.61 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
permissions:
# Write permissions required to create a release
# Ref: https://stackoverflow.com/a/69941765
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 'lts/*'
# Ref: https://github.com/actions/cache/blob/main/examples.md#node---yarn
- name: Get yarn cache path
id: yarn-cache-path
run: echo "::set-output name=path::$(yarn cache dir)"
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-path.outputs.path }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# Not recommended to cache node_modules
# Ref: https://github.com/actions/cache/blob/main/examples.md#node---npm
- run: yarn install --frozen-lockfile
- run: yarn build
- uses: actions/setup-go@v4
with:
go-version: 'stable'
# `mage format` would reformat files
- name: gofmt check
run: test -z "$(gofmt -l pkg)"
#- uses: magefile/mage-action@v2
# with:
# args: lint
- uses: golangci/golangci-lint-action@v3
with:
version: 'latest'
working-directory: pkg
- uses: magefile/mage-action@v2
with:
args: test
- uses: magefile/mage-action@v2
with:
args: buildall
- name: Sign plugin
run: yarn sign
env:
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }}
- name: Get version
id: version
run: |
import json
import re
version = json.load(open('dist/plugin.json'))['info']['version']
# Verify the other version strings match (until they can be eliminated)
assert version == json.load(open('package.json'))['version']
version2 = None
for line in open('pkg/plugin/client.go'):
match = re.search('VERSION\s*=\s*"(\d+\.\d+\.\d+)"', line)
if match:
version2 = match.group(1)
break
assert version == version2
print(f'::set-output name=version::{version}')
shell: python
- name: Compare version and Github tag
run: |
[ "${{ steps.version.outputs.version }}" = "${GITHUB_REF#refs/tags/}" ] || { echo 'plugin version and github tag mismatch'; exit 1; }
- name: Package plugin
run: |
mv dist sentinelone-dataset-datasource
zip -r sentinelone-dataset-datasource-${{ steps.version.outputs.version }}.zip sentinelone-dataset-datasource
sha256sum sentinelone-dataset-datasource-${{ steps.version.outputs.version }}.zip >SHA256SUMS
- name: Validate plugin
run: |
# Avoid a git clone within another checkout
pushd ~
git clone https://github.com/grafana/plugin-validator
pushd plugin-validator/pkg/cmd/plugincheck2
go install
popd
popd
plugincheck2 sentinelone-dataset-datasource-${{ steps.version.outputs.version }}.zip
- name: Generate changelog
run: awk '/^## / {s++} s==1 {print} s==2 {exit}' CHANGELOG.md | tail -n+2 > RELEASE_CHANGELOG.md
- uses: softprops/action-gh-release@v1
with:
draft: true
body_path: RELEASE_CHANGELOG.md
files: |
sentinelone-dataset-datasource-${{ steps.version.outputs.version }}.zip
SHA256SUMS
# TODO Consider automating the grafana.com publish process here