This repository has been archived by the owner on Sep 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
114 lines (96 loc) · 3.35 KB
/
ci.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: ci
on:
push:
tags:
- 'v*.*.*'
env:
CONSUL_VERSION: '1.8.4'
GOLANGCI_LINT_VERSION: '1.32.2'
MAGE_VERSION: '1.10.0'
NODE_VERSION: '12.x'
YARN_VERSION: '1.21.1'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Get the version & set it in package.json
id: get_version
run: |
VERSION=${GITHUB_REF/refs\/tags\/v/}
echo ::set-output name=VERSION::${VERSION}
sed -i "s/1.0.0/${VERSION}/g" package.json
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/[email protected]
with:
node-version: ${{ env.NODE_VERSION }}
- name: Set up Go
uses: actions/[email protected]
with:
go-version: 1.15
- name: Install Consul
run: |
# Install some binaries when not running locally
if ! command -v sudo &> /dev/null
then
apt update
# procps required to execute syctl to find free ports for Consul
apt install zip unzip procps -y
fi
mkdir -p $GITHUB_WORKSPACE/bin
curl -sLo consul.zip https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
unzip consul.zip
rm -rf consul.zip
mv consul $GITHUB_WORKSPACE/bin
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
- name: Install Mage
run: |
curl -sLo mage.tar.gz https://github.com/magefile/mage/releases/download/v1.10.0/mage_1.10.0_Linux-64bit.tar.gz
tar -xvf mage.tar.gz
rm -f mage.tar.gz LICENSE
mv mage $GITHUB_WORKSPACE/bin
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v${{ env.GOLANGCI_LINT_VERSION }}
- name: Build and test frontend
run: |
yarn install
./node_modules/.bin/grafana-toolkit plugin:ci-build
- name: Build and test backend
run: |
mage -v buildAll
export CGO_ENABLED=0
mage -v lint
mage -v coverage
- name: Move results to ci folder and package distro
env:
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }}
run: |
./node_modules/.bin/grafana-toolkit plugin:ci-build --finish
./node_modules/.bin/grafana-toolkit plugin:ci-package
ls -la ./ci/jobs/package
ls -la ./ci/packages
ls -la ./ci/dist
ls -la ./ci/grafana-test-env
- name: Create release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
TODO: change me
draft: true
prerelease: false
- name: Upload plugin to release
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ci/packages/sbueringer-consul-datasource-${{ steps.get_version.outputs.VERSION }}.zip
asset_name: sbueringer-consul-datasource-${{ steps.get_version.outputs.VERSION }}.zip
asset_content_type: application/zip