Add CICD for plugins

This commit is contained in:
Hien To 2023-10-16 18:10:56 +07:00
parent 56f72c9f28
commit cdc97f564c
11 changed files with 5214 additions and 5499 deletions

92
.github/workflows/publish-plugins.yml vendored Normal file
View File

@ -0,0 +1,92 @@
name: Publish plugins/$dir Package to npmjs
on:
push:
branches:
- main
- feature/cicd-all-plugins
paths:
- "plugins/**"
- ".github/workflows/publish-plugins.yml"
- "!plugins/*/package.json"
jobs:
build:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
token: ${{ secrets.PAT_SERVICE_ACCOUNT }}
- name: Install jq
uses: dcarbone/install-jq-action@v2.0.1
- name: Check Path Change
run: |
git config --global user.email "service@jan.ai"
git config --global user.name "Service Account"
echo "Changes in these directories trigger the build:"
changed_dirs=$(git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.GITHUB_TOKEN }}" diff --name-only HEAD HEAD~1 | grep 'plugins/' | awk -F/ '{print $2}' | uniq)
echo $changed_dirs > /tmp/change_dir.txt
- name: "Auto Increase package Version"
run: |
cd plugins
for dir in $(cat /tmp/change_dir.txt)
do
echo "$dir"
# Extract current version
current_version=$(jq -r '.version' $dir/package.json)
# Break the version into its components
major_version=$(echo $current_version | cut -d "." -f 1)
minor_version=$(echo $current_version | cut -d "." -f 2)
patch_version=$(echo $current_version | cut -d "." -f 3)
# Increment the patch version by one
new_patch_version=$((patch_version+1))
# Construct the new version
new_version="$major_version.$minor_version.$new_patch_version"
# Replace the old version with the new version in package.json
jq --arg version "$new_version" '.version = $version' $dir/package.json > /tmp/package.json && mv /tmp/package.json $dir/package.json
# Print the new version
echo "Updated $dir package.json version to: $new_version"
done
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
# - name: Publish npm packages
# run: |
# cd plugins
# for dir in $(cat /tmp/change_dir.txt)
# do
# echo $dir
# cd $dir
# npm install && npm run build
# npm publish --access public
# cd ..
# done
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "Commit new version to main and create tag"
run: |
for dir in $(cat /tmp/change_dir.txt)
do
echo "$dir"
version=$(jq -r '.version' plugins/$dir/package.json)
git config --global user.email "service@jan.ai"
git config --global user.name "Service Account"
git add plugins/$dir/package.json
git commit -m "${GITHUB_REPOSITORY}: Update tag build $version for $dir"
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin HEAD:feature/cicd-all-plugins
git tag -a $dir-$version -m "${GITHUB_REPOSITORY}: Update tag build $version for $dir"
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin $dir-$version
done

View File

@ -1,12 +1,12 @@
{
"name": "data-plugin",
"version": "1.0.4",
"name": "@janhq/data-plugin",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "data-plugin",
"version": "1.0.4",
"name": "@janhq/data-plugin",
"version": "1.0.0",
"bundleDependencies": [
"pouchdb-node",
"pouchdb-find"

View File

@ -1,6 +1,6 @@
{
"name": "data-plugin",
"version": "1.0.4",
"name": "@janhq/data-plugin",
"version": "1.0.0",
"description": "The Data Connector provides easy access to a data API using the PouchDB engine. It offers accessible data management capabilities.",
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/circle-stack.svg",
"main": "dist/esm/index.js",

View File

@ -1,11 +1,11 @@
{
"name": "inference-plugin",
"name": "@janhq/inference-plugin",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "inference-plugin",
"name": "@janhq/inference-plugin",
"version": "1.0.0",
"bundleDependencies": [
"tcp-port-used",

View File

@ -1,5 +1,5 @@
{
"name": "inference-plugin",
"name": "@janhq/inference-plugin",
"version": "1.0.0",
"description": "Inference Plugin, powered by @janhq/nitro, bring a high-performance Llama model inference in pure C++.",
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/command-line.svg",

View File

@ -1,11 +1,11 @@
{
"name": "model-management-plugin",
"name": "@janhq/model-management-plugin",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "model-management-plugin",
"name": "@janhq/model-management-plugin",
"version": "1.0.0",
"bundleDependencies": [
"@huggingface/hub"

View File

@ -1,5 +1,5 @@
{
"name": "model-management-plugin",
"name": "@janhq/model-management-plugin",
"version": "1.0.0",
"description": "Model Management Plugin provides model exploration and seamless downloads",
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/queue-list.svg",

View File

@ -1,11 +1,11 @@
{
"name": "monitoring-plugin",
"name": "@janhq/monitoring-plugin",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "monitoring-plugin",
"name": "@janhq/monitoring-plugin",
"version": "1.0.0",
"bundleDependencies": [
"systeminformation"

View File

@ -1,5 +1,5 @@
{
"name": "monitoring-plugin",
"name": "@janhq/monitoring-plugin",
"version": "1.0.0",
"description": "Utilizing systeminformation, it provides essential System and OS information retrieval",
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/cpu-chip.svg",

View File

@ -1,5 +1,5 @@
{
"name": "azure-openai-plugin",
"name": "@janhq/azure-openai-plugin",
"version": "1.0.0",
"description": "Inference plugin for Azure OpenAI",
"icon": "https://static-assets.jan.ai/openai-icon.jpg",

10589
yarn.lock

File diff suppressed because it is too large Load Diff