Skip to content

Commit 88cbf7f

Browse files
committed
add build scripts
1 parent b042f3d commit 88cbf7f

File tree

11 files changed

+1607
-18
lines changed

11 files changed

+1607
-18
lines changed

.github/workflows/README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# GitHub Actions Workflows
2+
3+
This directory contains GitHub Actions workflows for automated CI/CD.
4+
5+
## Workflows
6+
7+
### `release.yml` - Release Automation
8+
9+
**Trigger**: Push version tags (e.g., `v1.0.0`)
10+
11+
**Actions**:
12+
1. Checkout code
13+
2. Setup Node.js 20 with npm cache
14+
3. Install dependencies
15+
4. Run tests (`npm run test:ci`)
16+
5. Run linter (`npm run lint`)
17+
6. Type check (`npm run typecheck`)
18+
7. Build plugin (`npm run build`)
19+
8. Sign plugin if `GRAFANA_ACCESS_POLICY_TOKEN` secret exists
20+
9. Create distribution package (`npm run package`)
21+
10. Create GitHub Release with artifacts
22+
11. Upload artifacts with 90-day retention
23+
24+
**Outputs**:
25+
- GitHub Release with release notes
26+
- `cybertec-pev-panel.zip` - Signed plugin package
27+
- `MANIFEST.txt` - Signature verification file
28+
- Full `dist/` directory artifacts
29+
30+
**Setup Requirements**:
31+
32+
To enable plugin signing, add the `GRAFANA_ACCESS_POLICY_TOKEN` secret:
33+
1. Go to Repository Settings → Secrets and variables → Actions
34+
2. Click "New repository secret"
35+
3. Name: `GRAFANA_ACCESS_POLICY_TOKEN`
36+
4. Value: Token from [Grafana Cloud Portal](https://grafana.com/orgs)
37+
38+
### Other Workflows
39+
40+
- `ci.yml` - Continuous integration for pull requests
41+
- `bundle-stats.yml` - Bundle size analysis
42+
- `is-compatible.yml` - Grafana version compatibility check
43+
- `cp-update.yml` - Dependency updates
44+
45+
## Creating a Release
46+
47+
1. Update version in `src/plugin.json`
48+
2. Commit changes: `git commit -am "Release v1.2.0"`
49+
3. Create and push tag:
50+
```bash
51+
git tag v1.2.0
52+
git push origin main --tags
53+
```
54+
4. GitHub Actions will automatically build and create the release
55+
56+
## Local Testing
57+
58+
Test the release process locally:
59+
60+
```bash
61+
# Clean previous builds
62+
npm run clean
63+
64+
# Run full build pipeline
65+
npm run build
66+
67+
# Create distribution package
68+
npm run package
69+
70+
# Sign plugin (requires GRAFANA_ACCESS_POLICY_TOKEN env var)
71+
export GRAFANA_ACCESS_POLICY_TOKEN=your_token
72+
npm run sign
73+
```
74+
75+
## Workflow Maintenance
76+
77+
All workflows use:
78+
- Node.js 20 (LTS)
79+
- Ubuntu latest runner
80+
- npm for package management
81+
- Node.js scripts (work on all platforms)

.github/workflows/release.yml

Lines changed: 86 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,98 @@
1-
# This GitHub Action automates the process of building Grafana plugins.
2-
# (For more information, see https://github.com/grafana/plugin-actions/blob/main/build-plugin/README.md)
1+
# GitHub Action for building and releasing Grafana plugin
2+
# Produces signed plugin artifacts on version tags
33
name: Release
44

55
on:
66
push:
77
tags:
8-
- 'v*' # Run workflow on version tags, e.g. v1.0.0.
8+
- 'v*' # Run workflow on version tags, e.g. v1.0.0
99

10-
permissions: read-all
10+
permissions:
11+
contents: write # Required for creating releases
1112

1213
jobs:
1314
release:
14-
permissions:
15-
contents: write
1615
runs-on: ubuntu-latest
16+
1717
steps:
18-
- uses: actions/checkout@v5
18+
- name: Checkout code
19+
uses: actions/checkout@v4
1920
with:
20-
persist-credentials: false
21-
22-
- uses: grafana/plugin-actions/build-plugin@build-plugin/v1.0.2
23-
# Uncomment to enable plugin signing
24-
# (For more info on how to generate the access policy token see https://grafana.com/developers/plugin-tools/publish-a-plugin/sign-a-plugin#generate-an-access-policy-token)
25-
#with:
26-
# Make sure to save the token in your repository secrets
27-
#policy_token: $
28-
# Usage of GRAFANA_API_KEY is deprecated, prefer `policy_token` option above
29-
#grafana_token: $
21+
fetch-depth: 0
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
32+
- name: Run tests
33+
run: npm run test:ci
34+
35+
- name: Run linter
36+
run: npm run lint
37+
38+
- name: Type check
39+
run: npm run typecheck
40+
41+
- name: Build plugin
42+
run: npm run build
43+
44+
- name: Sign plugin
45+
if: ${{ secrets.GRAFANA_ACCESS_POLICY_TOKEN != '' }}
46+
env:
47+
GRAFANA_ACCESS_POLICY_TOKEN: ${{ secrets.GRAFANA_ACCESS_POLICY_TOKEN }}
48+
run: npm run sign
49+
50+
- name: Create distribution package
51+
run: npm run package
52+
53+
- name: Get plugin metadata
54+
id: metadata
55+
run: |
56+
echo "version=$(node -p "require('./src/plugin.json').info.version")" >> $GITHUB_OUTPUT
57+
echo "id=$(node -p "require('./src/plugin.json').id")" >> $GITHUB_OUTPUT
58+
echo "name=$(node -p "require('./src/plugin.json').name")" >> $GITHUB_OUTPUT
59+
60+
- name: Create Release
61+
uses: softprops/action-gh-release@v1
62+
with:
63+
name: Release ${{ github.ref_name }}
64+
draft: false
65+
prerelease: false
66+
generate_release_notes: true
67+
files: |
68+
cybertec-pev-panel.zip
69+
dist/MANIFEST.txt
70+
body: |
71+
## ${{ steps.metadata.outputs.name }} ${{ github.ref_name }}
72+
73+
### Installation
74+
75+
#### Via grafana-cli (after publication)
76+
```bash
77+
grafana-cli plugins install ${{ steps.metadata.outputs.id }}
78+
```
79+
80+
#### Manual Installation
81+
1. Download `cybertec-pev-panel.zip`
82+
2. Extract to your Grafana plugins directory
83+
3. Restart Grafana
84+
85+
### Verification
86+
The plugin is signed with Grafana's official signing tool. You can verify the signature by checking the `MANIFEST.txt` file included in the release.
87+
88+
### Changes
89+
See the automatically generated release notes below for details.
90+
91+
- name: Upload artifacts
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: plugin-artifacts-${{ github.ref_name }}
95+
path: |
96+
cybertec-pev-panel.zip
97+
dist/**/*
98+
retention-days: 90

0 commit comments

Comments
 (0)