Publish to npm
and crates.io
#1
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: Publish to `npm` and `crates.io` | |
on: | |
workflow_run: | |
workflows: ["Parse top repositories"] | |
types: | |
- completed | |
jobs: | |
npm_publish: | |
if: ${{ github.ref == 'refs/heads/main' }} | |
runs-on: ubuntu-latest | |
outputs: | |
type: ${{ steps.npm_publish.outputs.type }} | |
package_version: ${{ steps.npm_publish.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- run: npm install | |
- run: npm run test-ci | |
- run: cd ./test-npm-package && npm test; cd .. | |
- uses: JS-DevTools/npm-publish@v1 | |
id: npm_publish | |
with: | |
token: ${{ secrets.NPM_TOKEN }} | |
crates_io_publish: | |
runs-on: ubuntu-latest | |
needs: npm_publish | |
if: ${{ needs.npm_publish.outputs.type != 'none' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
override: true | |
- run: npm install | |
- run: npm run test-ci | |
- run: npx tree-sitter generate --abi 14 | |
- run: cargo test | |
- uses: katyo/publish-crates@v2 | |
with: | |
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
args: --allow-dirty | |
badge_update: | |
runs-on: ubuntu-latest | |
needs: | |
- npm_publish | |
- crates_io_publish | |
steps: | |
- name: Update crates.io badge | |
uses: RubbaBoy/[email protected] | |
with: | |
NAME: crates_io_version | |
LABEL: "crates.io" | |
STATUS: ${{ needs.npm_publish.outputs.package_version }} | |
COLOR: green | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update npm badge | |
uses: RubbaBoy/[email protected] | |
with: | |
NAME: npm_version | |
LABEL: "npm" | |
STATUS: ${{ needs.npm_publish.outputs.package_version }} | |
COLOR: green | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |