[BUG] Generate protos with a lower version for tests. (#3329) #597
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: 📦 Development Release JavaScript client | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
test: | |
name: JavaScript client tests | |
uses: ./.github/workflows/_javascript-client-tests.yml | |
release-dev: | |
needs: test | |
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@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "16.x" | |
registry-url: ${{ matrix.registry }} | |
check-latest: false | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- 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" | |
working-directory: ./clients/js/ | |
- name: Update package.json with organization scope | |
run: | | |
ORG_NAME="@chroma-core" | |
PACKAGE_NAME=$(jq -r '.name' package.json) | |
jq --arg org "$ORG_NAME" --arg name "$PACKAGE_NAME" '.name = "\($org)/\($name)"' package.json > tmp.$$.json && mv tmp.$$.json package.json | |
working-directory: ./clients/js/ | |
- name: Test & publish | |
run: npm run $NPM_SCRIPT | |
working-directory: ./clients/js/ | |
env: | |
NODE_AUTH_TOKEN: ${{ matrix.registry == 'https://registry.npmjs.org' && secrets.NPM_TOKEN || secrets.GITHUB_TOKEN }} |