Skip to content

Commit

Permalink
Merge pull request #52 from nomic-ai/nom-1729-next-releases
Browse files Browse the repository at this point in the history
Nom 1729 next releases
  • Loading branch information
bmschmidt authored Jul 8, 2024
2 parents c1c5317 + 16cf8a4 commit 70014fc
Showing 1 changed file with 48 additions and 10 deletions.
58 changes: 48 additions & 10 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
name: Publish @next release to npm
name: Publish to npm
on:
push:
branches:
- main
release:
types: [published]

permissions:
contents: write
packages: write
deployments: write

jobs:
publish:
publish-next:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
Expand All @@ -23,13 +26,48 @@ jobs:
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- run: npm version prerelease --preid=next
- name: Commit bumped version
- name: Get latest version and bump
run: |
# git add package.json package-lock.json
# git commit -m "Bump version to $(node -p "require('./package.json').version")"
git push
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.'
})

0 comments on commit 70014fc

Please sign in to comment.