|
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 |
3 | 3 | name: Release |
4 | 4 |
|
5 | 5 | on: |
6 | 6 | push: |
7 | 7 | 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 |
9 | 9 |
|
10 | | -permissions: read-all |
| 10 | +permissions: |
| 11 | + contents: write # Required for creating releases |
11 | 12 |
|
12 | 13 | jobs: |
13 | 14 | release: |
14 | | - permissions: |
15 | | - contents: write |
16 | 15 | runs-on: ubuntu-latest |
| 16 | + |
17 | 17 | steps: |
18 | | - - uses: actions/checkout@v5 |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v4 |
19 | 20 | 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