Umutuzgur/sc 23256/pwt native code package simple #152
This file contains 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: release-canary | |
on: | |
pull_request: | |
types: | |
- labeled | |
jobs: | |
publish: | |
if: ${{ github.event.label.name == 'build' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
# Setup .npmrc file to publish to npm | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '18.x' | |
registry-url: 'https://registry.npmjs.org' | |
# Extract the dynamic value from the canary label if present | |
- name: Extract dynamic value from canary label | |
id: extract-canary | |
run: | | |
if [[ "${GITHUB_EVENT_LABEL_NAME}" == canary:* ]]; then | |
CANARY_TAG="${GITHUB_EVENT_LABEL_NAME#canary:}" | |
echo "CANARY_TAG=${CANARY_TAG}" >> $GITHUB_ENV | |
fi | |
env: | |
GITHUB_EVENT_LABEL_NAME: ${{ github.event.label.name }} | |
# Ensure that the README is published with the package | |
- run: rm -f packages/cli/README.md && cp README.md packages/cli | |
- run: echo "PR_VERSION=0.0.0-pr.${{github.event.pull_request.number}}.$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- run: npm ci | |
- run: npm version ${{ env.PR_VERSION }} --workspace packages/cli | |
# Publish to npm with the additional tag if CANARY_TAG is set | |
- run: | | |
npm publish --workspace packages/cli --tag experimental | |
if [[ -n "${{ env.CANARY_TAG }}" ]]; then | |
npm dist-tag add checkly@${{ env.PR_VERSION }} ${{ env.CANARY_TAG }} | |
fi | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: PR Preview Release Published | |
hide_and_recreate: true | |
hide_classify: "OUTDATED" | |
message: | | |
🎉 Experimental release successfully published [on npm](https://npmjs.com/package/checkly/v/${{env.PR_VERSION}}) | |
``` | |
npm install checkly@${{env.PR_VERSION}} | |
``` |