Skip to content

Commit

Permalink
Fix release plugin to follow a normal workflow dispatch workflow (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
SandersAaronD authored Jul 10, 2024
1 parent 93ee4a0 commit 6732eb8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build-plugin/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: "Grafana Build Plugin"
description: "Builds a Grafana plugin"

outputs:
version:
description: "The version of the plugin."
value: ${{ steps.metadata.outputs.plugin-version }}
archive:
description: "The path to the plugin archive (zip)."
value: ${{ steps.metadata.outputs.archive }}
Expand Down Expand Up @@ -123,7 +126,6 @@ runs:
echo "archive-sha1sum=${GRAFANA_PLUGIN_ARTIFACT_SHA1SUM}" >> $GITHUB_OUTPUT
echo "archive-url=https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive }}"
echo "archive-sha1sum-url=(https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.plugin-version }}/${{ steps.metadata.outputs.archive-sha1sum }}"
echo "github-tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
shell: bash
working-directory: ${{ inputs.working-directory }}

Expand All @@ -135,11 +137,6 @@ runs:
shell: bash
working-directory: ${{ inputs.working-directory }}

- 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
working-directory: ${{ inputs.working-directory }}

- name: Package plugin
id: package-plugin
run: |
Expand Down
23 changes: 15 additions & 8 deletions .github/workflows/release-plugin.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
name: Release

on:
push:
tags:
- "v*" # Run workflow on version tags, e.g. v1.0.0.
workflow_dispatch:
inputs:
publish:
description: 'Publish plugin'
required: true
default: 'false'
type: choice
options:
- 'true'
- 'false'

permissions:
contents: write
Expand All @@ -13,21 +21,20 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build Plugin
id: build_plugin
uses: ./.github/workflows/build-plugin
with:
policy-token: ${{ secrets.GRAFANA_ACCESS_POLICY_TOKEN }}
working-directory: grafana-aitraining-app

- name: Get version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT

# This one is untested because the plugin is still way too alpha to publish.
- name: Publish new plugin version on grafana.com
if: inputs.publish == true
env:
GCOM_TOKEN: ${{ secrets.GRAFANA_ACCESS_POLICY_TOKEN }}
VERSION: ${{ steps.get_version.outputs.VERSION }}
VERSION: ${{ steps.build_plugin.outputs.version }}
ARCHIVE_URL: ${{ steps.build_plugin.outputs.archive-url }}
ARCHIVE_SHA1SUM_URL: ${{ steps.build_plugin.outputs.archive-sha1sum-url }}
run: |
Expand Down

0 comments on commit 6732eb8

Please sign in to comment.