diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml deleted file mode 100644 index a73314a..0000000 --- a/.github/workflows/create-release.yml +++ /dev/null @@ -1,49 +0,0 @@ -on: - push: - tags: - - 'v*' - -name: Create Release - -jobs: - publish: - name: Publish to npm - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Setup environment - uses: actions/setup-node@v2.5.1 - with: - node-version: '16' - registry-url: 'https://registry.npmjs.org' - cache: 'yarn' - - - name: Install dependencies - run: yarn install --immutable - - - name: Build package - run: yarn build - - - name: Publish - run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - create-github-release: - name: Create GitHub Release - runs-on: ubuntu-latest - needs: publish - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Create Release Notes - uses: actions/github-script@v6.2.0 - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - await github.request(`POST /repos/${{ github.repository }}/releases`, { - tag_name: "${{ github.ref }}", - generate_release_notes: true - }); diff --git a/.github/workflows/npm-bump-version.yml b/.github/workflows/npm-bump-version.yml deleted file mode 100644 index 40deee4..0000000 --- a/.github/workflows/npm-bump-version.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: NPM bump version - -on: - workflow_dispatch: - inputs: - version: - description: 'Semver type of new version (major / minor / patch)' - required: true - type: choice - options: - - patch - - minor - - major - -jobs: - bump-version: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup environment - uses: actions/setup-node@v2.5.1 - with: - node-version: '16' - cache: 'yarn' - - - name: Install dependencies - run: yarn install --immutable - - - name: Build package - run: yarn build - - - name: Run tests - run: yarn test:ci - - - name: Setup Git - run: | - git config user.name 'grafanabot' - git config user.email 'bot@grafana.com' - - name: bump version - run: npm version ${{ github.event.inputs.version }} - - - name: Push latest version - run: git push origin main --follow-tags diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..acf29a6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,78 @@ +name: release +on: + push: + branches: + - main + +jobs: + npm-publish: + name: Publish to NPM & GitHub Package Registry + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + ref: main + # limit releases to version changes - https://github.com/EndBug/version-check + - name: Check version changes + uses: EndBug/version-check@v1 + id: version_check + with: + file-url: https://unpkg.com/@grafana/async-query-data@latest/package.json + static-checking: localIsNew + + - name: Version update detected + if: steps.version_check.outputs.changed == 'true' + run: 'echo "Version change found! New version: ${{ steps.version_check.outputs.version }} (${{ steps.version_check.outputs.type }})"' + + - name: Setup .npmrc file for NPM registry + if: steps.version_check.outputs.changed == 'true' + uses: actions/setup-node@v2 + with: + node-version: '16' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + if: steps.version_check.outputs.changed == 'true' + run: yarn + + - name: Build library + if: steps.version_check.outputs.changed == 'true' + run: yarn build + + - name: Publish package to NPM + if: steps.version_check.outputs.changed == 'true' + run: npm publish --access public --scope grafana + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Setup .npmrc file for GitHub Packages + if: steps.version_check.outputs.changed == 'true' + uses: actions/setup-node@v2 + with: + node-version: '16' + registry-url: 'https://npm.pkg.github.com' + scope: '@grafana' + + - name: Publish package to Github Packages + if: steps.version_check.outputs.changed == 'true' + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + create-github-release: + name: Create GitHub Release + runs-on: ubuntu-latest + needs: npm-publish + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Create Release Notes + uses: actions/github-script@v6.2.0 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + await github.request(`POST /repos/${{ github.repository }}/releases`, { + tag_name: "${{ github.ref }}", + generate_release_notes: true + }); diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 521c08a..be9f25c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,6 +12,6 @@ Want to install this repo locally? - if you get a yarn version >2: - in consumer package (ex grafana) `yarn link path-to-sdk` it should add a portal resolution to your package.json -## Creating a Release +## Releasing -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. +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. diff --git a/package.json b/package.json index 78568dd..7799e75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@grafana/async-query-data", - "version": "0.1.5", + "version": "0.1.6", "description": "Async query support for Grafana", "main": "dist/index.js", "scripts": {