|
| 1 | +name: Build and Release Plugin |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + branch: |
| 7 | + description: Branch to build from |
| 8 | + default: main |
| 9 | + version: |
| 10 | + description: Version tag (e.g., v1.0.0). Leave empty to use run number |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + create-release: |
| 14 | + description: Create a GitHub release |
| 15 | + default: true |
| 16 | + type: boolean |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + name: Build Plugin |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + ref: ${{ github.event.inputs.branch || 'main' }} |
| 30 | + fetch-depth: 0 |
| 31 | + |
| 32 | + - name: Set up Node.js |
| 33 | + uses: actions/setup-node@v4 |
| 34 | + with: |
| 35 | + node-version: '20' |
| 36 | + cache: 'npm' |
| 37 | + |
| 38 | + - name: Set up Go |
| 39 | + uses: actions/setup-go@v5 |
| 40 | + with: |
| 41 | + go-version: '1.24' |
| 42 | + cache-dependency-path: go.sum |
| 43 | + |
| 44 | + - name: Install dependencies |
| 45 | + run: npm ci |
| 46 | + |
| 47 | + - name: Build frontend |
| 48 | + run: npm run build |
| 49 | + |
| 50 | + - name: Install Mage |
| 51 | + run: | |
| 52 | + go install github.com/magefile/mage@latest |
| 53 | + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH |
| 54 | +
|
| 55 | + - name: Build backend |
| 56 | + run: mage build:backend |
| 57 | + |
| 58 | + - name: Verify build artifacts |
| 59 | + run: | |
| 60 | + echo "Checking dist folder contents:" |
| 61 | + ls -lah dist/ |
| 62 | + echo "" |
| 63 | + echo "Checking for required files:" |
| 64 | + test -f dist/plugin.json && echo "✓ plugin.json exists" || echo "✗ plugin.json missing" |
| 65 | + test -f dist/module.js && echo "✓ module.js exists" || echo "✗ module.js missing" |
| 66 | + test -f dist/gpx_clickhouse_linux_amd64 && echo "✓ Linux AMD64 binary exists" || echo "✗ Linux AMD64 binary missing" |
| 67 | +
|
| 68 | + - name: Create release archive |
| 69 | + run: | |
| 70 | + cd dist |
| 71 | + zip -r ../grafana-clickhouse-datasource.zip . |
| 72 | + cd .. |
| 73 | + ls -lh grafana-clickhouse-datasource.zip |
| 74 | +
|
| 75 | + - name: Upload build artifacts |
| 76 | + uses: actions/upload-artifact@v4 |
| 77 | + with: |
| 78 | + name: plugin-dist |
| 79 | + path: | |
| 80 | + dist/ |
| 81 | + grafana-clickhouse-datasource.zip |
| 82 | + retention-days: 30 |
| 83 | + |
| 84 | + - name: Create GitHub Release |
| 85 | + if: ${{ github.event.inputs.create-release == 'true' }} |
| 86 | + uses: softprops/action-gh-release@v1 |
| 87 | + with: |
| 88 | + files: grafana-clickhouse-datasource.zip |
| 89 | + tag_name: ${{ github.event.inputs.version || format('v{0}-build-{1}', github.event.inputs.branch || 'main', github.run_number) }} |
| 90 | + name: Release ${{ github.event.inputs.version || format('{0}-build-{1}', github.event.inputs.branch || 'main', github.run_number) }} |
| 91 | + body: | |
| 92 | + ## ClickHouse Datasource Plugin Build |
| 93 | + |
| 94 | + **Branch:** ${{ github.event.inputs.branch || 'main' }} |
| 95 | + **Commit:** ${{ github.sha }} |
| 96 | + **Build Number:** ${{ github.run_number }} |
| 97 | + |
| 98 | + ### Installation Instructions |
| 99 | + |
| 100 | + 1. Download the `grafana-clickhouse-datasource.zip` file |
| 101 | + 2. Extract it to your Grafana plugins directory: |
| 102 | + ```bash |
| 103 | + unzip grafana-clickhouse-datasource.zip -d /var/lib/grafana/plugins/grafana-clickhouse-datasource/ |
| 104 | + ``` |
| 105 | + 3. Restart Grafana |
| 106 | + |
| 107 | + **Note:** You may need to allow unsigned plugins in your `grafana.ini`: |
| 108 | + ```ini |
| 109 | + [plugins] |
| 110 | + allow_loading_unsigned_plugins = grafana-clickhouse-datasource |
| 111 | + ``` |
| 112 | + draft: false |
| 113 | + prerelease: false |
| 114 | + |
0 commit comments