-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathrelease-dev-javascript-client.yml
More file actions
146 lines (132 loc) · 5.07 KB
/
Copy pathrelease-dev-javascript-client.yml
File metadata and controls
146 lines (132 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: 📦 Development Release JavaScript client
on:
push:
branches:
- main
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
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: blacksmith-4vcpu-ubuntu-2404
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@v5
with:
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "18.x"
registry-url: ${{ matrix.registry }}
check-latest: false
token: ${{ secrets.GITHUB_TOKEN }}
cache: 'pnpm'
cache-dependency-path: 'clients/js/pnpm-lock.yaml'
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
working-directory: ./clients/js/
- name: Build packages
run: pnpm build
working-directory: ./clients/js/
- name: Generate Dev Version
id: dev-version
run: |
set -e
# Generate a dev tag using commit short sha and run id
COMMIT_SHA=$(git rev-parse --short HEAD)
DEV_TAG="dev.${COMMIT_SHA}-${GITHUB_RUN_ID}"
echo "DEV_TAG=${DEV_TAG}" >> "$GITHUB_ENV"
# Update each package's version with dev tag
for PKG_DIR in packages/chromadb packages/chromadb-client; do
PKG_PATH="./${PKG_DIR}/package.json"
# Get current version
CURRENT_VERSION=$(node -p "require('${PKG_PATH}').version")
# Create full version with dev 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}"
# Update package.json with new version
jq --arg version "$NEW_VERSION" '.version = $version' $PKG_PATH > tmp.$$.json && mv tmp.$$.json $PKG_PATH
echo "Updated ${PKG_DIR} to version ${NEW_VERSION}"
done
working-directory: ./clients/js/
- name: Update package.json with organization scope
run: |
ORG_NAME="@chroma-core"
# Update chromadb package
CHROMADB_PKG="./packages/chromadb/package.json"
PACKAGE_NAME=$(jq -r '.name' $CHROMADB_PKG)
jq --arg org "$ORG_NAME" --arg name "$PACKAGE_NAME" '.name = "\($org)/\($name)"' $CHROMADB_PKG > tmp.$$.json && mv tmp.$$.json $CHROMADB_PKG
# Update chromadb-client package
CLIENT_PKG="./packages/chromadb-client/package.json"
PACKAGE_NAME=$(jq -r '.name' $CLIENT_PKG)
jq --arg org "$ORG_NAME" --arg name "$PACKAGE_NAME" '.name = "\($org)/\($name)"' $CLIENT_PKG > tmp.$$.json && mv tmp.$$.json $CLIENT_PKG
working-directory: ./clients/js/
- name: Publish dev packages
run: pnpm publish -r --access public --no-git-checks --tag dev
working-directory: ./clients/js/
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runtime-report:
name: Runtime report
if: always()
needs:
- release-dev
runs-on: blacksmith-2vcpu-ubuntu-2404
permissions:
actions: read
contents: read
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Generate runtime report
continue-on-error: true
uses: ./.github/actions/runtime-report
with:
github-token: ${{ github.token }}
notify-slack-on-failure:
name: Notify Slack on Release Failure
if: failure()
needs: [release-dev]
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- name: Notify Slack
uses: slackapi/slack-github-action@v2.0.0
with:
token: ${{ secrets.SLACK_BOT_TOKEN }}
method: chat.postMessage
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
text: |
:x: *JavaScript client (dev) release failure!*
*Workflow:* ${{ github.workflow }}
*Run:* <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View run>
*Ref:* <https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}|${{ github.ref_name }}>
*Author:* ${{ github.actor }}