3.1.4 release prep #40
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |