|
| 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 | + |
| 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 | + }); |
0 commit comments