Skip to content

Commit

Permalink
Merge pull request #6 from nomic-ai/11-06-introduce_release_please_an…
Browse files Browse the repository at this point in the history
…d_next_release_flows

introduce release please and next release flows
  • Loading branch information
RLesser authored Nov 6, 2024
2 parents 1e68696 + 4921340 commit e8d1b5b
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/publish-next.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish Next Tag Version

on:
push:
branches:
- main

jobs:
publish-next-tag-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "18"
registry-url: "https://registry.npmjs.org"

- name: Install dependencies
run: npm ci

- name: Install release-please
run: npm install -g release-please

- name: Determine next version and update package.json
run: |
# Determine next version
OUTPUT=$(release-please release-pr --dry-run --token=${{ secrets.GITHUB_TOKEN }} --repo-url=${{ github.repository }} --default-branch=main)
NEXT_VERSION=$(echo "$OUTPUT" | grep "chore(main): release atlas" | sed 's/.*atlas //')
echo "Next version: $NEXT_VERSION"
# Count existing pre-releases
NEXT_VERSION_COUNT=$(npm view . versions --json | jq "[.[] | select(startswith(\"$NEXT_VERSION-next.\"))] | length")
echo "Number of existing pre-releases: $NEXT_VERSION_COUNT"
# Create final version string
FINAL_VERSION="${NEXT_VERSION}-next.${NEXT_VERSION_COUNT}"
echo "Final version: $FINAL_VERSION"
# Update package.json
npm version $FINAL_VERSION --no-git-tag-version
npm publish --tag=next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39 changes: 39 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

name: Release Please

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
release-type: node

# The logic below handles the npm publication:
- uses: actions/checkout@v3
# these if statements ensure that a publication only occurs when
# a new release is created:
if: ${{ steps.release.outputs.release_created }}

- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: "https://registry.npmjs.org"
if: ${{ steps.release.outputs.release_created }}

- run: npm ci
if: ${{ steps.release.outputs.release_created }}

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
if: ${{ steps.release.outputs.release_created }}

0 comments on commit e8d1b5b

Please sign in to comment.