Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit b182994

Browse files
authored
Setup Github actions to automatically build and release the plugin (#21)
1 parent 223cd17 commit b182994

File tree

4 files changed

+116
-1
lines changed

4 files changed

+116
-1
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Build Prerelease Version
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
build-prerelease:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Get Package Version
12+
id: package-version
13+
uses: martinbeentjes/npm-get-version-action@master
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v2
16+
with:
17+
node-version: '14.18.2'
18+
- name: Update Version
19+
run: npm version ${{ steps.package-version.outputs.current-version}}-${{ github.run_number }} --no-git-tag-version
20+
- name: Install Plugin Frontend
21+
run: |
22+
yarn install --frozen-lockfile
23+
yarn build
24+
- name: Setup Go
25+
uses: actions/setup-go@v2
26+
with:
27+
go-version: '1.17.3'
28+
- name: Install Go Dependencies
29+
run: |
30+
go mod tidy
31+
- name: Install Plugin Backend
32+
uses: magefile/mage-action@v1
33+
with:
34+
version: latest
35+
args: -v
36+
- uses: papeloto/action-zip@v1
37+
with:
38+
files: dist/
39+
dest: novatec-dashboardsync-datasource.zip
40+
- uses: "marvinpinto/action-automatic-releases@latest"
41+
with:
42+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
43+
automatic_release_tag: "latest"
44+
prerelease: true
45+
title: "Development Build ${{ steps.package-version.outputs.current-version}}-${{ github.run_number }}"
46+
files: |
47+
novatec-dashboardsync-datasource.zip
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build Release Version
2+
on:
3+
push:
4+
tags:
5+
- 'v*.*.*'
6+
jobs:
7+
build-release:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Set Release Version
12+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
13+
- name: Set up Node.js
14+
uses: actions/setup-node@v2
15+
with:
16+
node-version: '14.18.2'
17+
- name: Update Version
18+
run: npm version ${{ env.RELEASE_VERSION }} --no-git-tag-version
19+
- name: Commit files
20+
run: |
21+
git config --local user.email "1217782+github-actions[bot]@users.noreply.github.com"
22+
git config --local user.name "github-actions[bot]"
23+
git add package.json
24+
git commit -m "[skip ci] Update version to latest release version"
25+
- name: Push changes
26+
uses: ad-m/github-push-action@master
27+
with:
28+
github_token: ${{ secrets.GITHUB_TOKEN }}
29+
branch: main
30+
- name: Install Plugin Frontend
31+
run: |
32+
yarn install --frozen-lockfile
33+
yarn build
34+
- name: Setup Go
35+
uses: actions/setup-go@v2
36+
with:
37+
go-version: '1.17.3'
38+
- name: Install Go Dependencies
39+
run: |
40+
go mod tidy
41+
- name: Install Plugin Backend
42+
uses: magefile/mage-action@v1
43+
with:
44+
version: latest
45+
args: -v
46+
- uses: papeloto/action-zip@v1
47+
with:
48+
files: dist/
49+
dest: novatec-dashboardsync-datasource.zip
50+
- uses: "marvinpinto/action-automatic-releases@latest"
51+
with:
52+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
53+
automatic_release_tag: "v${{ env.RELEASE_VERSION }}"
54+
prerelease: false
55+
title: "Version ${{ env.RELEASE_VERSION }}"
56+
files: |
57+
novatec-dashboardsync-datasource.zip

Magefile.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//+build mage
1+
//go:build mage
2+
// +build mage
23

34
package main
45

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ docker-compose up
7474

7575
Under datasources the Grafana Dashboard Plugin Sync should be available now
7676

77+
## Releasing the Plugin
78+
79+
The release process of the plugin is automated using Github Actions.
80+
On each push to the `main` branch, a new prerelease is created and the corresponding commit is tagged "latest".
81+
Old prereleases will be deleted.
82+
83+
To create a normal release, the commit that is used as the basis for the release must be tagged with the following format: `v*.*.*`.
84+
After that, the release is built and created with the version number extracted from the tag.
85+
Furthermore, a new commit is created, which sets the current version in the `main` branch to the version that has been released.
86+
7787
## Learn more
7888

7989
- [Build a data source backend plugin tutorial](https://grafana.com/tutorials/build-a-data-source-backend-plugin)

0 commit comments

Comments
 (0)