Skip to content

Commit 25475e2

Browse files
authored
Change release to trigger on version change (#16)
1 parent 8a1590e commit 25475e2

File tree

5 files changed

+81
-99
lines changed

5 files changed

+81
-99
lines changed

.github/workflows/create-release.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/npm-bump-version.yml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
npm-publish:
9+
name: Publish to NPM & GitHub Package Registry
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v2
14+
with:
15+
ref: main
16+
# limit releases to version changes - https://github.com/EndBug/version-check
17+
- name: Check version changes
18+
uses: EndBug/version-check@v1
19+
id: version_check
20+
with:
21+
file-url: https://unpkg.com/@grafana/async-query-data@latest/package.json
22+
static-checking: localIsNew
23+
24+
- name: Version update detected
25+
if: steps.version_check.outputs.changed == 'true'
26+
run: 'echo "Version change found! New version: ${{ steps.version_check.outputs.version }} (${{ steps.version_check.outputs.type }})"'
27+
28+
- name: Setup .npmrc file for NPM registry
29+
if: steps.version_check.outputs.changed == 'true'
30+
uses: actions/setup-node@v2
31+
with:
32+
node-version: '16'
33+
registry-url: 'https://registry.npmjs.org'
34+
35+
- name: Install dependencies
36+
if: steps.version_check.outputs.changed == 'true'
37+
run: yarn
38+
39+
- name: Build library
40+
if: steps.version_check.outputs.changed == 'true'
41+
run: yarn build
42+
43+
- name: Publish package to NPM
44+
if: steps.version_check.outputs.changed == 'true'
45+
run: npm publish --access public --scope grafana
46+
env:
47+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
49+
- name: Setup .npmrc file for GitHub Packages
50+
if: steps.version_check.outputs.changed == 'true'
51+
uses: actions/setup-node@v2
52+
with:
53+
node-version: '16'
54+
registry-url: 'https://npm.pkg.github.com'
55+
scope: '@grafana'
56+
57+
- name: Publish package to Github Packages
58+
if: steps.version_check.outputs.changed == 'true'
59+
run: npm publish
60+
env:
61+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
create-github-release:
63+
name: Create GitHub Release
64+
runs-on: ubuntu-latest
65+
needs: npm-publish
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v2
69+
70+
- name: Create Release Notes
71+
uses: actions/[email protected]
72+
with:
73+
github-token: ${{secrets.GITHUB_TOKEN}}
74+
script: |
75+
await github.request(`POST /repos/${{ github.repository }}/releases`, {
76+
tag_name: "${{ github.ref }}",
77+
generate_release_notes: true
78+
});

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ Want to install this repo locally?
1212
- if you get a yarn version >2:
1313
- in consumer package (ex grafana) `yarn link path-to-sdk` it should add a portal resolution to your package.json
1414

15-
## Creating a Release
15+
## Releasing
1616

17-
Creating a new release requires running the [NPM bump version action](https://github.com/grafana/grafana-async-query-data-js/actions/workflows/npm-bump-version.yml). Click `Run workflow` and specify the type of release (patch, minor, or major). The workflow will update package.json, commit and push which will trigger the [Create Release action](https://github.com/grafana/grafana-async-query-data-js/actions/workflows/create-release.yml) which publishes to npm and creates a github release with release notes.
17+
To release a new version of the package, commit the updated "version" field into main, which will trigger the [Release action](https://github.com/grafana/grafana-async-query-data-js/actions/workflows/release.yml) which publishes to npm and creates a github release with release notes.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@grafana/async-query-data",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "Async query support for Grafana",
55
"main": "dist/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)