Merge pull request #47 from nomic-ai/nom-1545-formalize-info-caching-… #3
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 | |
on: | |
push: | |
branches: | |
- main | |
release: | |
types: [published] | |
permissions: | |
contents: write | |
packages: write | |
deployments: write | |
jobs: | |
publish-next: | |
if: github.event_name == 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
- run: npm ci | |
- name: Configure Git user | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
- name: Get latest version and bump | |
run: | | |
LATEST_VERSION=$(npm view . version) | |
npm version $LATEST_VERSION --no-git-tag-version | |
npm version prerelease --preid=next | |
- run: npm publish --tag next | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | |
publish-release: | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Configure Git | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
- run: npm ci | |
- name: Update version and commit | |
run: | | |
npm version ${{ github.event.release.tag_name }} --no-git-tag-version | |
git add package.json package-lock.json | |
git commit -m "Bump version to ${{ github.event.release.tag_name }}" | |
git push | |
- run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | |
- name: Update release notes | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.rest.repos.updateRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: context.payload.release.id, | |
body: context.payload.release.body + '\n\nThis release has been published to npm.' | |
}) |