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

chore: rename cortex-js folder to platform #1033

Merged
merged 5 commits into from
Sep 4, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
292 changes: 4 additions & 288 deletions .github/workflows/cortex-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: CI Cortex Release

on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+", "v[0-9]+.[0-9]+.[0-9]+-*", "!v[0-9]+.[0-9]+.[0-9]+-cortex-js", "!v[0-9]+.[0-9]+.[0-9]+-[0-9]+-cortex-js"]
paths: ["cortex-cpp/**", "cortex-js/**"]
tags: ["v[0-9]+.[0-9]+.[0-9]+", "v[0-9]+.[0-9]+.[0-9]+-*", "!v[0-9]+.[0-9]+.[0-9]+-platform", "!v[0-9]+.[0-9]+.[0-9]+-[0-9]+-platform"]
paths: ["cortex-cpp/**", "platform/**"]
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -223,237 +223,8 @@ jobs:

## cortex-cpp node binding

build-cortex-single-binary:
runs-on: ${{ matrix.runs-on }}
needs: [create-draft-release, build-and-test]
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
include:
- os: "linux"
name: "amd64"
runs-on: "ubuntu-20-04"

- os: "windows"
name: "amd64"
runs-on: "windows-2019"

- os: "mac"
name: "amd64"
runs-on: "macos-13"

- os: "mac"
name: "arm64"
runs-on: "macos-latest"
steps:
- name: Clone
id: checkout
uses: actions/checkout@v3
with:
submodules: recursive

- uses: actions/setup-dotnet@v3
if: runner.os == 'Windows'
with:
dotnet-version: "8.0.x"

- name: Install jq
uses: dcarbone/[email protected]

- uses: actions/setup-node@v3
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"

- name: "Update version by tag"
working-directory: cortex-js
shell: bash
run: |
echo "Version: ${{ needs.create-draft-release.outputs.version }}"
# Update the version in package.json
jq --arg version "${{ needs.create-draft-release.outputs.version }}" '.version = $version' package.json > /tmp/package.json
mv /tmp/package.json package.json

- name: Install choco on Windows
if: runner.os == 'Windows'
run: |
choco install make -y

- uses: actions/setup-node@v3
with:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"

- uses: actions/setup-python@v3
with:
python-version: "3.10"

- run: pip3 install --upgrade setuptools
if: runner.os == 'macOS'

- run: yarn install && yarn build:binary
working-directory: ./cortex-js

- name: Get Cer for code signing
if: runner.os == 'macOS'
run: base64 -d <<< "$NOTARIZE_P8_BASE64" > /tmp/notary-key.p8
shell: bash
env:
NOTARIZE_P8_BASE64: ${{ secrets.NOTARIZE_P8_BASE64 }}

- uses: apple-actions/import-codesign-certs@v2
continue-on-error: true
if: runner.os == 'macOS'
with:
p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }}

- name: update app info
run: |
cd cortex-js
make update-app-info

- name: copy bin file macos
if: runner.os == 'macOS'
run: |
cd cortex-js
mkdir -p installer
which cp
which mv
npm install -g cpx
npx cpx ./dist/cortexso ./
mv cortexso cortex

- name: Code Signing macOS
if: runner.os == 'macOS'
run: |
cd cortex-js
./dist/cortexso --help
echo "--------"
./cortex --help
make codesign-binary CODE_SIGN=true DEVELOPER_ID="${{ secrets.DEVELOPER_ID }}"

# install quill
curl -sSfL https://raw.githubusercontent.com/anchore/quill/main/install.sh | sh -s -- -b /usr/local/bin

# Notarize the binary
quill notarize ./cortex
env:
QUILL_NOTARY_KEY_ID: ${{ secrets.NOTARY_KEY_ID }}
QUILL_NOTARY_ISSUER: ${{ secrets.NOTARY_ISSUER }}
QUILL_NOTARY_KEY: "/tmp/notary-key.p8"

- name: Create MacOS PKG Installer
if: runner.os == 'macOS'
run: |
cd cortex-js
echo "--------"
npx cpx ./cortex ./installer
./installer/cortex --help
pkgbuild --identifier ai.cortex.pkg --install-location ./usr/local/bin/ --root ./installer cortex-installer.pkg
make codesign-installer CODE_SIGN=true DEVELOPER_ID="${{ secrets.DEVELOPER_ID }}"

# Notary the installer
xcrun notarytool submit cortex-installer.pkg --apple-id ${{ secrets.APPLE_ID }} --password ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} --team-id ${{ secrets.APPLE_TEAM_ID }} --wait

- name: Create Linux DEB Installer
if: runner.os == 'Linux'
run: |
cd cortex-js
mkdir -p cortexso/DEBIAN
mkdir -p cortexso/usr/local/bin
sed "s/Version:/Version: ${{ needs.create-draft-release.outputs.version }}/g" control.template > cortexso/DEBIAN/control
cp cortex cortexso/usr/local/bin/cortex
dpkg-deb --build cortexso

- run: |
cd cortex-js
set PATH=%PATH%;%USERPROFILE%\.dotnet\tools
make codesign-binary CODE_SIGN=true CORTEX_VERSION="0.${{ needs.create-draft-release.outputs.version }}" AZURE_KEY_VAULT_URI="${{ secrets.AZURE_KEY_VAULT_URI }}" AZURE_CLIENT_ID="${{ secrets.AZURE_CLIENT_ID }}" AZURE_TENANT_ID="${{ secrets.AZURE_TENANT_ID }}" AZURE_CLIENT_SECRET="${{ secrets.AZURE_CLIENT_SECRET }}" AZURE_CERT_NAME="${{ secrets.AZURE_CERT_NAME }}"
name: Code Signing Windows
shell: cmd
if: runner.os == 'Windows'

- name: Update version in installer.iss using sed
if: runner.os == 'Windows'
shell: bash
run: |
cd cortex-js
sed -i "s/AppVersion=1.0/AppVersion=${{ needs.create-draft-release.outputs.version }}/g" installer.iss
cat installer.iss

- name: Compile .ISS to .EXE Installer
uses: Minionguyjpro/[email protected]
if: runner.os == 'Windows'
with:
path: cortex-js/installer.iss
options: /O+

- run: |
cd cortex-js
set PATH=%PATH%;%USERPROFILE%\.dotnet\tools
make codesign-installer CODE_SIGN=true CORTEX_VERSION="0.${{ needs.create-draft-release.outputs.version }}" AZURE_KEY_VAULT_URI="${{ secrets.AZURE_KEY_VAULT_URI }}" AZURE_CLIENT_ID="${{ secrets.AZURE_CLIENT_ID }}" AZURE_TENANT_ID="${{ secrets.AZURE_TENANT_ID }}" AZURE_CLIENT_SECRET="${{ secrets.AZURE_CLIENT_SECRET }}" AZURE_CERT_NAME="${{ secrets.AZURE_CERT_NAME }}"
name: Code Signing Windows
shell: cmd
if: runner.os == 'Windows'

- name: Post-Bundle
run: |
cd cortex-js
make postbundle

- name: Upload Cortex Installer
uses: actions/[email protected]
if: runner.os != 'Linux'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
asset_path: ./cortex-js/cortex-installer.tar.gz
asset_name: cortex-installer-${{ needs.create-draft-release.outputs.version }}-${{ matrix.name }}-${{ matrix.os }}.tar.gz
asset_content_type: application/gzip

- name: Upload Cortex Installer
uses: actions/[email protected]
if: runner.os == 'Windows'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
asset_path: ./cortex-js/setup.exe
asset_name: cortex-installer-${{ needs.create-draft-release.outputs.version }}-${{ matrix.name }}-${{ matrix.os }}.exe
asset_content_type: application/octet-stream

- uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
asset_path: ./cortex-js/cortex.tar.gz
asset_name: cortex-${{ needs.create-draft-release.outputs.version }}-${{ matrix.name }}-${{ matrix.os }}.tar.gz
asset_content_type: application/gzip

- uses: actions/[email protected]
if: runner.os == 'Linux'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-draft-release.outputs.upload_url }}
asset_path: ./cortex-js/cortexso.deb
asset_name: cortex-installer-${{ needs.create-draft-release.outputs.version }}-${{ matrix.name }}-${{ matrix.os }}.deb
asset_content_type: application/gzip

# Upload artifact for package manager
- name: Upload Artifact
if: runner.os == 'Linux'
uses: actions/upload-artifact@v2
with:
name: cortex-linux
path: ./cortex-js/cortex

update_release_draft:
needs: [build-and-test, build-cortex-single-binary]
needs: [build-and-test]
permissions:
# write permission is required to create a github release
contents: write
Expand All @@ -476,59 +247,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


# Add jobs with approval
public_package_manager:
needs: [create-draft-release, update_release_draft]
runs-on: ubuntu-latest
environment: package-manager
permissions:
contents: read
steps:
- name: checkout
uses: actions/checkout@v4

- name: Download artifact
uses: actions/download-artifact@v2
with:
name: cortex-linux
path: ./cortex-linux

- name: install dependencies
run: |
ls -al ./cortex-linux
sudo apt-get install dput devscripts build-essential debhelper-compat pbuilder debootstrap devscripts -y

- name: import gpg key with subkey
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.HOMEBREW_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.HOMEBREW_GPG_PASSPHRASE }}
fingerprint: ${{ secrets.HOMEBREW_GPG_FINGERPRINT }}

- run: |
mkdir -p package-managers-template/launchpad/cortexso-${{ needs.create-draft-release.outputs.version }}/debian
cp package-managers-template/launchpad/cortexso/debian/* package-managers-template/launchpad/cortexso-${{ needs.create-draft-release.outputs.version }}/debian/
cp ./cortex-linux/cortex package-managers-template/launchpad/cortexso-${{ needs.create-draft-release.outputs.version }}/

- name: Get release notes
id: release_notes
run: |
RELEASE_NOTES="cortex update to version ${{ needs.create-draft-release.outputs.version }}"
echo "RELEASE_NOTES=${RELEASE_NOTES}" >> $GITHUB_ENV

- name: Update change log
run: |
sed -i "s/VERSION/${{ needs.create-draft-release.outputs.version }}/g" package-managers-template/launchpad/cortexso-${{ needs.create-draft-release.outputs.version }}/debian/changelog
sed -i "s/CHANGELOG_HERE/${{ env.RELEASE_NOTES }}/g" package-managers-template/launchpad/cortexso-${{ needs.create-draft-release.outputs.version }}/debian/changelog
timestamp=$(date -u +"%a, %d %b %Y %H:%M:%S +0000")
sed -i "s/TIME_HERE/${timestamp}/g" package-managers-template/launchpad/cortexso-${{ needs.create-draft-release.outputs.version }}/debian/changelog

- name: Build package
run: |
cd package-managers-template/launchpad/cortexso-${{ needs.create-draft-release.outputs.version }}
echo "y" | debuild -S -sa -k${{ secrets.HOMEBREW_GPG_FINGERPRINT }}
sudo pbuilder create --distribution jammy --debootstrapopts --variant=buildd
sudo pbuilder build ../cortexso_${{ needs.create-draft-release.outputs.version }}.dsc
dput ppa:homebrew-computer/main ../cortexso_${{ needs.create-draft-release.outputs.version }}_source.changes


Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
node-version: 20

- run: npm install -g yarn && yarn install && yarn build
working-directory: ./cortex-js
working-directory: ./platform

- name: install python venv
run: |
Expand All @@ -46,7 +46,7 @@ jobs:

- name: Run test
run: |
node cortex-js/dist/src/command.js --address 127.0.0.1 --port 4010 > cortex.log
node platform/dist/src/command.js --address 127.0.0.1 --port 4010 > cortex.log
sleep 3
wget --no-verbose -O api.json http://127.0.0.1:4010/api-json
cat api.json
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
- name: Clean up
if: always()
run: |
node cortex-js/dist/src/command.js stop
node platform/dist/src/command.js stop
rm -rf /tmp/jan
rm -rf openai-python
rm -rf report.html
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: CI test for cortex-js
name: CI test for platform
on:
pull_request:
paths:
- "cortex-js/**"
- .github/workflows/cortex-js-quality-gate.yml
- "platform/**"
- .github/workflows/platform-quality-gate.yml
workflow_dispatch:
jobs:
build-and-publish-plugins:
Expand All @@ -19,7 +19,7 @@ jobs:
node-version: "20.x"
registry-url: "https://registry.npmjs.org"
- run: yarn install && yarn build
working-directory: ./cortex-js
working-directory: ./platform
- run: yarn test
name: run tests
working-directory: ./cortex-js
working-directory: ./platform
Loading
Loading