v5.0.29 #42
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish NPM Package | |
| on: | |
| release: | |
| types: [published] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| publish-harper-npm-package: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| harper-version: ${{ steps.version-components.outputs.version }} | |
| steps: | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: latest | |
| registry-url: 'https://registry.npmjs.org' | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Get release build | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release download ${{ github.event.release.tag_name }} --pattern "harper-*.tgz" | |
| - name: Get version components | |
| id: version-components | |
| uses: matt-usurp/validate-semver@7bbc9584679de1aeef57aa531504ab00438481ab # v2.1.0 | |
| with: | |
| version: ${{ github.event.release.tag_name }} | |
| - name: Set package tag | |
| id: package-tag | |
| # Once we have our first full, non-beta release, turn this back on: | |
| # run: | | |
| # if [[ "${{ steps.version-components.outputs.prerelease }}" == '' ]]; then | |
| # echo "packageTag=latest" >> "$GITHUB_OUTPUT" | |
| # else | |
| # echo "packageTag=next" >> "$GITHUB_OUTPUT" | |
| # fi | |
| # and get rid of this hard coded latest tagging: | |
| run: | | |
| echo "packageTag=latest" >> "$GITHUB_OUTPUT" | |
| - name: Publish package to NPM registry | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm publish --access=public --tag=${{ steps.package-tag.outputs.packageTag }} harper-*.tgz | |
| publish-harperfast-npm-package: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| harper-version: ${{ steps.version-components.outputs.version }} | |
| steps: | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | |
| with: | |
| node-version: latest | |
| registry-url: 'https://registry.npmjs.org' | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Get release build | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release download ${{ github.event.release.tag_name }} --pattern "harper-*.tgz" | |
| - name: Get version components | |
| id: version-components | |
| uses: matt-usurp/validate-semver@7bbc9584679de1aeef57aa531504ab00438481ab # v2.1.0 | |
| with: | |
| version: ${{ github.event.release.tag_name }} | |
| - name: Rename package to '@harperfast/harper' | |
| run: | | |
| mkdir package | |
| tar -xvf harper-${{ steps.version-components.outputs.version }}.tgz -C package --strip-components=1 | |
| pushd package | |
| npm pkg set name=@harperfast/harper | |
| popd | |
| tar -czvf harperfast-harper-${{ steps.version-components.outputs.version }}.tgz package | |
| - name: Set package tag | |
| id: package-tag | |
| # Once we have our first full, non-beta release, turn this back on: | |
| # run: | | |
| # if [[ "${{ steps.version-components.outputs.prerelease }}" == '' ]]; then | |
| # echo "packageTag=latest" >> "$GITHUB_OUTPUT" | |
| # else | |
| # echo "packageTag=next" >> "$GITHUB_OUTPUT" | |
| # fi | |
| # and get rid of this hard coded latest tagging: | |
| run: | | |
| echo "packageTag=latest" >> "$GITHUB_OUTPUT" | |
| - name: Publish package to NPM registry | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm publish --access=public --tag=${{ steps.package-tag.outputs.packageTag }} harperfast-harper-*.tgz | |
| send-slack-message-on-success: | |
| if: success() && !cancelled() | |
| needs: | |
| - publish-harperfast-npm-package | |
| - publish-harper-npm-package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send Slack published notification | |
| uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3 | |
| with: | |
| method: chat.postMessage | |
| token: ${{ secrets.SLACK_BOT_TOKEN }} | |
| payload: | | |
| { | |
| "channel": "#development-ci", | |
| "text": "Harper v${{ needs.publish-harper-npm-package.outputs.harper-version }} has been published to NPM", | |
| "blocks": [ | |
| { | |
| "type": "header", | |
| "text": { | |
| "type": "plain_text", | |
| "text": "Harper v${{ needs.publish-harper-npm-package.outputs.harper-version }} release" | |
| } | |
| }, | |
| { | |
| "type": "context", | |
| "elements": [ | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Status*" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": ":white_check_mark: Published to :npm:" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "<https://www.npmjs.com/package/harper/v/${{ needs.publish-harper-npm-package.outputs.harper-version }}|harper@${{ needs.publish-harper-npm-package.outputs.harper-version }}>" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "<https://www.npmjs.com/package/@harperfast/harperfast/v/${{ needs.publish-harperfast-npm-package.outputs.harper-version }}|@harperfast/harper@${{ needs.publish-harperfast-npm-package.outputs.harper-version }}>" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| send-slack-message-on-failure: | |
| if: failure() && !cancelled() | |
| needs: | |
| - publish-harperfast-npm-package | |
| - publish-harper-npm-package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3 | |
| with: | |
| method: chat.postMessage | |
| token: ${{ secrets.SLACK_BOT_TOKEN }} | |
| payload: | | |
| { | |
| "channel": "#development-ci", | |
| "text": "Harper v${{ needs.publish-harper-npm-package.outputs.harper-version }} NPM publish failed", | |
| "blocks": [ | |
| { | |
| "type": "header", | |
| "text": { | |
| "type": "plain_text", | |
| "text": "Harper v${{ needs.publish-harper-npm-package.outputs.harper-version }} release" | |
| } | |
| }, | |
| { | |
| "type": "context", | |
| "elements": [ | |
| { | |
| "type": "mrkdwn", | |
| "text": "*Status*" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": ":x: Failed to publish to :npm:" | |
| }, | |
| { | |
| "type": "mrkdwn", | |
| "text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Workflow run ${{ github.run_id }}>" | |
| } | |
| ] | |
| } | |
| ] | |
| } |