Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BLD] JS client release to GH packages + dev releases #2173

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/release-dev-javascript-client.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we put this in .github/workflows/release-chromadb.yml instead, then we don't need to manually compute the tag name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JS client is a separate release/version from the Python release. Reusing the same tag would be challenging. However, I've made it a point to include comprehensive information in the dev release. This will allow us to pinpoint which commit and GH job built the package for bug traceability. We could potentially implement the same for the Python client.

Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: 📦 Development Release JavaScript client

on:
push:
branches:
- main

jobs:
release-dev:
strategy:
matrix:
registry: [ "https://npm.pkg.github.com" ]
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
permissions: write-all
steps:
- name: Check if tag matches the pattern
id: check-tag
run: |
# we don't necessarily need this
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "Push to main branch, releasing dev version to GH packages"
echo "NPM_SCRIPT=release_dev" >> "$GITHUB_ENV"
else
echo "The ref does not point to main, exiting workflow" # we alredy make the check above but this is a good practice
exit 1
fi
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: "16.x"
registry-url: ${{ matrix.registry }}
- name: Install dependencies
run: npm install
working-directory: ./clients/js/
- name: Dev Version
id: dev-version
run: |
set -e
# Get current version
CURRENT_VERSION=$(node -p "require('./package.json').version")
# Generate a beta tag using commit short sha and run id
COMMIT_SHA=$(git rev-parse --short HEAD)
DEV_TAG="dev.${COMMIT_SHA}-${GITHUB_RUN_ID}"
# Create full version with beta tag
BASE_VERSION=$(echo $CURRENT_VERSION | cut -f1,2 -d.)
PATCH_VERSION=$(echo $CURRENT_VERSION | cut -f3 -d.)
# bump patch version
NEW_PATCH_VERSION=$((PATCH_VERSION + 1))
NEW_VERSION="${BASE_VERSION}.${NEW_PATCH_VERSION}-${DEV_TAG}"
echo "NEW_VERSION=${NEW_VERSION}" >> "$GITHUB_ENV"
- name: Test & publish
run: npm run db:run && PORT=8001 npm run $NPM_SCRIPT
working-directory: ./clients/js/
env:
NODE_AUTH_TOKEN: ${{ matrix.registry == 'https://registry.npmjs.org' && secrets.NPM_TOKEN || secrets.GITHUB_TOKEN }}
11 changes: 7 additions & 4 deletions .github/workflows/release-javascript-client.yml
tazarov marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ name: 📦 Release JavaScript client
on:
push:
tags:
- 'js_release_*.*.*' # Match tags in the form js_release_X.Y.Z
- 'js_release_alpha_*.*.*' # Match tags in the form js_release_alpha_X.Y.Z
- 'js_release_[0-9]+\.[0-9]+\.[0-9]+' # Match tags in the form js_release_X.Y.Z
- 'js_release_alpha_[0-9]+\.[0-9]+\.[0-9]+' # Match tags in the form js_release_alpha_X.Y.Z

jobs:
release:
strategy:
matrix:
registry: [ "https://registry.npmjs.org", "https://npm.pkg.github.com" ]
runs-on: ubuntu-latest
permissions: write-all
steps:
Expand All @@ -30,12 +33,12 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
registry-url: ${{ matrix.registry }}
- name: Install dependencies
run: npm install
working-directory: ./clients/js/
- name: Test & publish
run: npm run db:run && PORT=8001 npm run $NPM_SCRIPT
working-directory: ./clients/js/
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ matrix.registry == 'https://registry.npmjs.org' && secrets.NPM_TOKEN || secrets.GITHUB_TOKEN }}
3 changes: 2 additions & 1 deletion clients/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
"genapi": "./genapi.sh",
"prettier": "prettier --write .",
"release": "run-s build test:run && npm publish",
"release_alpha": "run-s build test:run && npm publish --tag alpha"
"release_alpha": "run-s build test:run && npm publish --tag alpha",
"release_dev": "run-s build test:run && npm version ${NEW_VERSION} --no-git-tag-version && npm publish"
},
"engines": {
"node": ">=14.17.0"
Expand Down