Skip to content

Commit

Permalink
fix: add release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mesak committed Jul 8, 2023
1 parent 1cf3b19 commit 526ea13
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 11 deletions.
129 changes: 129 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# This is a basic workflow to help you get started with Actions

name: release

# Controls when the workflow will run
on:
# Triggers the workflow on push tag events but only for the "main" branch
push:
tags:
- 'v*.*.*' # Run workflow on version tags, e.g. v1.0.0.

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
release:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Set Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

- name: Cache yarn cache
uses: actions/cache@v2
id: cache-yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build and test frontend
run: yarn build

- name: Sign plugin
run: yarn sign
env:
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.

- 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_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
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-checksum=${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}" >> $GITHUB_OUTPUT
- name: Read changelog
id: changelog
run: |
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
echo "path=release_notes.md" >> $GITHUB_OUTPUT
- name: Package plugin
id: package-plugin
run: |
cp README.md dist/README.md
mv dist ${{ steps.metadata.outputs.plugin-id }}
zip ${{ steps.metadata.outputs.archive }} ${{ steps.metadata.outputs.plugin-id }} -r
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
echo "checksum=$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)" >> $GITHUB_OUTPUT
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: ${{ steps.changelog.outputs.path }}
#draft: true
draft: false

- name: Add plugin to release
id: upload-plugin-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ steps.metadata.outputs.archive }}
asset_name: ${{ steps.metadata.outputs.archive }}
asset_content_type: application/zip

- name: Add checksum to release
id: upload-checksum-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ steps.metadata.outputs.archive-checksum }}
asset_name: ${{ steps.metadata.outputs.archive-checksum }}
asset_content_type: text/plain
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog

## 1.1.0 (Unreleased)
## 1.0.3 (release)

add workflow

## 1.0.2 (release)

release file modify

## 1.0.1 (Unreleased)

Add Some Options

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Arnaud Marchand
Copyright (c) 2023 Mesak

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Image Save Panel Plugin for Grafana

[![Marketplace](https://img.shields.io/badge/dynamic/json?logo=grafana&color=F47A20&label=marketplace&prefix=v&query=%24.items%5B%3F%28%40.slug%20%3D%3D%20%22mesak-imagesave-panel%22%29%5D.version&url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins)](https://grafana.com/grafana/plugins/mesak-imagesave-panel)
[![Downloads](https://img.shields.io/badge/dynamic/json?logo=grafana&color=F47A20&label=downloads&query=%24.items%5B%3F%28%40.slug%20%3D%3D%20%22mesak-imagesave-panel%22%29%5D.downloads&url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins)](https://grafana.com/grafana/plugins/mesak-imagesave-panel)

[![GitHub release (latest by date)](https://img.shields.io/github/v/release/mesak/grafana-imagesave-panel?color=brightgreen&logo=github&label=latest)](https://github.com/mesak/grafana-imagesave-panel)
[![License](https://img.shields.io/github/license/mesak/grafana-imagesave-panel)](https://github.com/mesak/grafana-imagesave-panel/blob/master/LICENSE)

This plugin is a panel plugin for Grafana that allows you to save image to grafana.

## Installation
Expand All @@ -23,3 +29,4 @@ This plugin directly stores image data in Grafana Database, allowing for quick a
## Screenshots

![Screenshot](https://raw.githubusercontent.com/mesak/grafana-imagesave-panel/main/src/img/screenshot.jpg)

7 changes: 0 additions & 7 deletions build.sh

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mesak-imagesave-panel",
"version": "1.0.2",
"version": "1.0.3",
"description": "Image Save Panel Plugin for Grafana",
"scripts": {
"build": "grafana-toolkit plugin:build",
Expand Down
1 change: 0 additions & 1 deletion release/mesak-imagesave-panel.sha1

This file was deleted.

Binary file removed release/mesak-imagesave-panel.zip
Binary file not shown.

0 comments on commit 526ea13

Please sign in to comment.