-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pipeline step to upload packaged plugin to Factry Portal
- Loading branch information
Arnaud Van der Poorten
committed
Jul 16, 2024
1 parent
219cf5b
commit 56a01b1
Showing
4 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
name: "Grafana Build Plugin" | ||
description: "Builds a Grafana plugin" | ||
|
||
# steps copied from https://github.com/grafana/plugin-actions/blob/release/build-plugin/action.yml | ||
# with added outputs for metadata | ||
|
||
inputs: | ||
token: | ||
description: "Token for the repository. Can be passed in using `{{ secrets.GITHUB_TOKEN }}`." | ||
required: false | ||
default: "${{ github.token }}" | ||
policy_token: | ||
description: "Grafana access policy token. https://grafana.com/developers/plugin-tools/publish-a-plugin/sign-a-plugin#generate-an-access-policy-token" | ||
required: false | ||
default: "" | ||
outputs: | ||
plugin-id: | ||
description: "The plugin id" | ||
value: ${{ steps.metadata.outputs.plugin-id }} | ||
plugin-version: | ||
description: "The plugin version" | ||
value: ${{ steps.metadata.outputs.plugin-version }} | ||
plugin-type: | ||
description: "The plugin type" | ||
value: ${{ steps.metadata.outputs.plugin-type }} | ||
archive: | ||
description: "The plugin archive" | ||
value: ${{ steps.metadata.outputs.archive }} | ||
archive-sha1sum: | ||
description: "The plugin archive sha1sum" | ||
value: ${{ steps.metadata.outputs.archive-sha1sum }} | ||
github-tag: | ||
description: "The github tag" | ||
value: ${{ steps.metadata.outputs.github-tag }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup Go environment | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.21" | ||
|
||
- name: Setup node environment | ||
uses: ./.github/actions/pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
shell: bash | ||
|
||
- name: Build and test frontend | ||
run: pnpm run build | ||
shell: bash | ||
|
||
- name: Check for backend | ||
id: check-for-backend | ||
run: | | ||
if [ -f "Magefile.go" ] | ||
then | ||
echo "has-backend=true" >> $GITHUB_OUTPUT | ||
fi | ||
shell: bash | ||
|
||
- name: Test backend | ||
if: steps.check-for-backend.outputs.has-backend == 'true' | ||
uses: magefile/mage-action@v2 | ||
with: | ||
version: latest | ||
args: coverage | ||
|
||
- name: Build backend | ||
if: steps.check-for-backend.outputs.has-backend == 'true' | ||
uses: magefile/mage-action@v2 | ||
with: | ||
version: latest | ||
args: buildAll | ||
|
||
- name: Warn missing Grafana access policy token | ||
run: | | ||
echo Please generate a Grafana access policy token: https://grafana.com/developers/plugin-tools/publish-a-plugin/sign-a-plugin#generate-an-access-policy-token | ||
echo Once done please follow the instructions found here: https://github.com/${{github.repository}}/blob/main/README.md#using-github-actions-release-workflow | ||
if: ${{ inputs.policy_token == '' }} | ||
shell: bash | ||
|
||
- name: Sign plugin | ||
run: pnpm sign | ||
shell: bash | ||
env: | ||
GRAFANA_ACCESS_POLICY_TOKEN: ${{ inputs.policy_token }} | ||
GRAFANA_API_KEY: ${{ inputs.grafana_token }} | ||
if: ${{ inputs.policy_token != '' }} | ||
|
||
- name: Get plugin metadata | ||
id: metadata | ||
run: | | ||
sudo apt-get install jq | ||
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id) | ||
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version) | ||
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type) | ||
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip | ||
export GRAFANA_PLUGIN_ARTIFACT_SHA1SUM=${GRAFANA_PLUGIN_ARTIFACT}.sha1 | ||
echo "plugin-id=${GRAFANA_PLUGIN_ID}" >> $GITHUB_OUTPUT | ||
echo "plugin-version=${GRAFANA_PLUGIN_VERSION}" >> $GITHUB_OUTPUT | ||
echo "plugin-type=${GRAFANA_PLUGIN_TYPE}" >> $GITHUB_OUTPUT | ||
echo "archive=${GRAFANA_PLUGIN_ARTIFACT}" >> $GITHUB_OUTPUT | ||
echo "archive-sha1sum=${GRAFANA_PLUGIN_ARTIFACT_SHA1SUM}" >> $GITHUB_OUTPUT | ||
echo "github-tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Read changelog | ||
id: changelog | ||
run: | | ||
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md | ||
echo "path=release_notes.md" >> $GITHUB_OUTPUT | ||
shell: bash | ||
|
||
- name: Check package version | ||
run: if [ "v${{ steps.metadata.outputs.plugin-version }}" != "${{ steps.metadata.outputs.github-tag }}" ]; then printf "\033[0;31mPlugin version doesn't match tag name. The tag should be v${{ steps.metadata.outputs.plugin-version }} \033[0m\n"; exit 1; fi | ||
shell: bash | ||
|
||
- name: Package plugin | ||
id: package-plugin | ||
run: | | ||
mv dist ${{ steps.metadata.outputs.plugin-id }} | ||
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r | ||
sha1sum ${{ steps.metadata.outputs.archive }} | cut -f1 -d' ' > ${{ steps.metadata.outputs.archive-sha1sum }} | ||
shell: bash | ||
|
||
- name: Validate plugin | ||
run: | | ||
git clone https://github.com/grafana/plugin-validator | ||
pushd ./plugin-validator/pkg/cmd/plugincheck2 | ||
go install | ||
popd | ||
plugincheck2 -config ./plugin-validator/config/default.yaml ${{ steps.metadata.outputs.archive }} | ||
shell: bash | ||
|
||
- name: Create Github release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: true | ||
generate_release_notes: true | ||
token: ${{ inputs.token }} | ||
files: | | ||
./${{ steps.metadata.outputs.archive }} | ||
./${{ steps.metadata.outputs.archive-sha1sum }} | ||
body: | | ||
**This Github draft release has been created for your plugin.** | ||
_Note: if this is the first release for your plugin please consult the [distributing-your-plugin section](https://github.com/${{github.repository}}/blob/main/README.md#distributing-your-plugin) of the README_ | ||
If you would like to submit this release to Grafana please consider the following steps: | ||
- Check the Validate plugin step in the [release workflow](https://github.com/${{github.repository}}/commit/${{github.sha}}/checks/${{github.run_id}}) for any warnings that need attention | ||
- Navigate to https://grafana.com/auth/sign-in/ to sign into your account | ||
- Once logged in click **My Plugins** in the admin navigation | ||
- Click the **Submit Plugin** button | ||
- Fill in the Plugin Submission form: | ||
- Paste this [.zip asset link](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive }}) in the Plugin URL field | ||
- Paste this [.zip.sha1 link](https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive-sha1sum }}) in the SHA1 field | ||
Once done please remove these instructions and publish this release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
# Changelog | ||
|
||
## v2.0.3-beta | ||
|
||
- Added automatic publishing to Factry Portal | ||
|
||
## v2.0.2 | ||
|
||
### Changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters