7.7.0 #591
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 Package to npmjs | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| validate-tag: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions-ecosystem/action-regex-match@v2 | |
| id: tag-match | |
| with: | |
| text: ${{ github.event.release.tag_name }} | |
| regex: '^\d+\.\d+\.\d+$' | |
| - run: echo "Please create tag for release with format like 4.0.1" && exit 1 | |
| if: ${{ steps.tag-match.outputs.match == '' }} | |
| # Old create-checkly versions still look for the tag with a `v` prefix. | |
| # We can automatically push the necessary tag to keep those working. | |
| - name: Create tag for old create-checkly versions | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| github.rest.git.createRef({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| ref: 'refs/tags/v${{ github.event.release.tag_name }}', | |
| sha: context.sha | |
| }) | |
| # Build package and publish a prerelease | |
| prerelease: | |
| needs: validate-tag | |
| permissions: | |
| id-token: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| # Setup .npmrc file to publish to npm | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Upgrade npm for trusted publishing support | |
| run: | | |
| npm install -g npm@latest | |
| echo "npm version: $(npm --version)" | |
| # Ensure that the README is published with the package | |
| - run: rm -f packages/cli/README.md && cp README.md packages/cli | |
| - run: npm ci | |
| - name: Add SHORT_SHA env property with commit short sha | |
| run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
| - name: Set version and publish prerelease for 'cli' package | |
| run: | | |
| npm --no-git-tag-version version ${{ github.event.release.tag_name }}-prerelease-${{ env.SHORT_SHA }} --workspace packages/cli | |
| npm publish --provenance --workspace packages/cli --tag prerelease | |
| - name: Set version and publish prerelease for 'create-cli' package | |
| run: | | |
| npm --no-git-tag-version version ${{ github.event.release.tag_name }}-prerelease-${{ env.SHORT_SHA }} --workspace packages/create-cli | |
| npm publish --provenance --workspace packages/create-cli --tag prerelease | |
| - name: Output prerelease packages versions | |
| run: | | |
| npm pkg get version --workspace packages/cli | |
| npm pkg get version --workspace packages/create-cli | |
| - name: Save LLM rules as an artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: llm-rules-prerelease | |
| if-no-files-found: error | |
| path: packages/cli/dist/ai-context/* | |
| # Slack failure alert | |
| - name: Slack Failure Notification | |
| if: ${{ failure() }} | |
| uses: rtCamp/action-slack-notify@v2 | |
| env: | |
| SLACK_USERNAME: Checkly Github Bot | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
| SLACK_CHANNEL: cli | |
| SLACK_ICON: https://github.com/checkly.png?size=48 | |
| SLACK_COLOR: ${{ job.status }} | |
| SLACK_TITLE: ':red_circle: NPM prerelease failed' | |
| SLACK_MESSAGE: by ${{ github.actor }} | |
| SLACK_FOOTER: '' | |
| # Slack success alert | |
| - name: Slack Success Notification | |
| if: ${{ success() }} | |
| uses: rtCamp/action-slack-notify@v2 | |
| env: | |
| SLACK_USERNAME: Checkly Github Bot | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
| SLACK_CHANNEL: cli | |
| SLACK_ICON: https://github.com/checkly.png?size=48 | |
| SLACK_COLOR: ${{ job.status }} | |
| SLACK_TITLE: ':white_check_mark: NPM prerelease succeeded' | |
| SLACK_MESSAGE: by ${{ github.actor }} | |
| SLACK_FOOTER: '' | |
| # Publish package to NPM | |
| release: | |
| runs-on: ubuntu-latest | |
| environment: production | |
| needs: prerelease | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| ref: main | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Upgrade npm for trusted publishing support | |
| run: | | |
| npm install -g npm@latest | |
| echo "npm version: $(npm --version)" | |
| # Ensure that the README is published with the package | |
| - run: rm -f packages/cli/README.md && cp README.md packages/cli | |
| - run: npm ci | |
| - name: Set version and publish 'cli' package | |
| run: | | |
| npm --no-git-tag-version version ${{ github.event.release.tag_name }} --workspace packages/cli | |
| npm publish --provenance --workspace packages/cli | |
| - name: Set version and publish 'create-cli' package | |
| run: | | |
| npm --no-git-tag-version version ${{ github.event.release.tag_name }} --workspace packages/create-cli | |
| npm publish --provenance --workspace packages/create-cli | |
| - name: Output final packages versions | |
| run: | | |
| npm pkg get version --workspace packages/cli | |
| npm pkg get version --workspace packages/create-cli | |
| - name: Save LLM rules as an artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: llm-rules-release | |
| if-no-files-found: error | |
| path: packages/cli/dist/ai-context/* | |
| # Slack failure alert | |
| - name: Slack Failure Notification | |
| if: ${{ failure() }} | |
| uses: rtCamp/action-slack-notify@v2 | |
| env: | |
| SLACK_USERNAME: Checkly Github Bot | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
| SLACK_CHANNEL: cli | |
| SLACK_ICON: https://github.com/checkly.png?size=48 | |
| SLACK_COLOR: ${{ job.status }} | |
| SLACK_TITLE: ':red_circle: NPM publish failed' | |
| SLACK_MESSAGE: by ${{ github.actor }} | |
| SLACK_FOOTER: '' | |
| # Slack success alert | |
| - name: Slack Success Notification | |
| if: ${{ success() }} | |
| uses: rtCamp/action-slack-notify@v2 | |
| env: | |
| SLACK_USERNAME: Checkly Github Bot | |
| SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | |
| SLACK_CHANNEL: cli | |
| SLACK_ICON: https://github.com/checkly.png?size=48 | |
| SLACK_COLOR: ${{ job.status }} | |
| SLACK_TITLE: ':white_check_mark: NPM publish succeeded' | |
| SLACK_MESSAGE: by ${{ github.actor }} | |
| SLACK_FOOTER: '' | |
| # Attach checkly.rules.md to the GitHub Release and mark it as latest | |
| finalize-release: | |
| runs-on: ubuntu-latest | |
| needs: release | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Download LLM rules artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: llm-rules-release | |
| path: llm-rules-release | |
| - name: Upload checkly.rules.md to GitHub Release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: gh release upload ${{ github.event.release.tag_name }} llm-rules-release/checkly.rules.md --repo ${{ github.repository }} | |
| - name: Mark release as latest if version is highest | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| CURRENT_LATEST=$(gh release list --repo ${{ github.repository }} --json tagName,isLatest --jq '.[] | select(.isLatest) | .tagName') | |
| NEW_TAG=${{ github.event.release.tag_name }} | |
| if [ -z "$CURRENT_LATEST" ] || [ "$(printf '%s\n%s' "$CURRENT_LATEST" "$NEW_TAG" | sort -V | tail -n1)" = "$NEW_TAG" ]; then | |
| echo "Marking $NEW_TAG as latest (current latest: ${CURRENT_LATEST:-none})" | |
| gh release edit "$NEW_TAG" --latest --repo ${{ github.repository }} | |
| else | |
| echo "Skipping: $NEW_TAG is not newer than current latest $CURRENT_LATEST" | |
| fi |