Merge branch 'main' into docs/pointing-client-remote-server
This commit is contained in:
commit
844459c647
203
.github/workflows/jan-electron-build-nightly.yml
vendored
203
.github/workflows/jan-electron-build-nightly.yml
vendored
@ -15,6 +15,7 @@ jobs:
|
||||
uses: unfor19/install-aws-cli-action@v1
|
||||
|
||||
- name: Delete cloudflare-r2 folder using awscli s3api
|
||||
if: github.ref == 'refs/heads/main'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
# Get the list of objects in the 'latest' folder
|
||||
@ -34,25 +35,18 @@ jobs:
|
||||
AWS_DEFAULT_REGION: auto
|
||||
AWS_EC2_METADATA_DISABLED: "true"
|
||||
|
||||
build-macos:
|
||||
runs-on: macos-latest
|
||||
# Job create Update app version based on latest release tag with build number and save to output
|
||||
get-update-version:
|
||||
runs-on: ubuntu-latest
|
||||
needs: delete-cloudflare-r2-folder
|
||||
environment: production
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
new_version: ${{ steps.version_update.outputs.new_version }}
|
||||
steps:
|
||||
- name: Getting the repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Installing node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install jq
|
||||
uses: dcarbone/install-jq-action@v2.0.1
|
||||
|
||||
|
||||
- name: Update app version based on latest release tag with build number
|
||||
id: version_update
|
||||
run: |
|
||||
@ -82,11 +76,35 @@ jobs:
|
||||
# Remove the 'v' and append the build number to the version
|
||||
NEW_VERSION="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}"
|
||||
echo "New version: $NEW_VERSION"
|
||||
|
||||
# Update the version in electron/package.json
|
||||
jq --arg version "$NEW_VERSION" '.version = $version' electron/package.json > /tmp/package.json
|
||||
mv /tmp/package.json electron/package.json
|
||||
echo "::set-output name=new_version::$NEW_VERSION"
|
||||
build-macos:
|
||||
runs-on: macos-latest
|
||||
needs: [delete-cloudflare-r2-folder, get-update-version]
|
||||
environment: production
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Getting the repo
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Installing node
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Install jq
|
||||
uses: dcarbone/install-jq-action@v2.0.1
|
||||
|
||||
|
||||
- name: Update app version based on latest release tag with build number
|
||||
id: version_update
|
||||
run: |
|
||||
# Update the version in electron/package.json
|
||||
jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' electron/package.json > /tmp/package.json
|
||||
mv /tmp/package.json electron/package.json
|
||||
|
||||
jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' web/package.json > /tmp/package.json
|
||||
mv /tmp/package.json web/package.json
|
||||
|
||||
jq '.build.publish = [{"provider": "generic", "url": "${{ secrets.CLOUDFLARE_R2_PUBLIC_URL }}", "channel": "latest"}]' electron/package.json > /tmp/package.json
|
||||
mv /tmp/package.json electron/package.json
|
||||
@ -119,26 +137,27 @@ jobs:
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: jan-mac-x64-${{ steps.version_update.outputs.new_version }}
|
||||
path: ./electron/dist/jan-mac-x64-${{ steps.version_update.outputs.new_version }}.dmg
|
||||
name: jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}
|
||||
path: ./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: jan-mac-arm64-${{ steps.version_update.outputs.new_version }}
|
||||
path: ./electron/dist/jan-mac-arm64-${{ steps.version_update.outputs.new_version }}.dmg
|
||||
name: jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}
|
||||
path: ./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg
|
||||
|
||||
- name: put-object using awscli s3api
|
||||
if: github.ref == 'refs/heads/main'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
ls -al ./electron/dist
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ steps.version_update.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ steps.version_update.outputs.new_version }}.dmg" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ steps.version_update.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ steps.version_update.outputs.new_version }}.dmg" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ steps.version_update.outputs.new_version }}.zip" --body "./electron/dist/jan-mac-x64-${{ steps.version_update.outputs.new_version }}.zip" --content-type "application/zip"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ steps.version_update.outputs.new_version }}.zip" --body "./electron/dist/jan-mac-arm64-${{ steps.version_update.outputs.new_version }}.zip" --content-type "application/zip"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ steps.version_update.outputs.new_version }}/jan-mac-x64-${{ steps.version_update.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ steps.version_update.outputs.new_version }}.dmg" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ steps.version_update.outputs.new_version }}/jan-mac-arm64-${{ steps.version_update.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ steps.version_update.outputs.new_version }}.dmg" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ steps.version_update.outputs.new_version }}/latest-mac.yml" --body "./electron/dist/latest-mac.yml" --content-type "text/yaml"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.zip" --body "./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.zip" --content-type "application/zip"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.zip" --body "./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.zip" --content-type "application/zip"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --body "./electron/dist/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/latest-mac.yml" --body "./electron/dist/latest-mac.yml" --content-type "text/yaml"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/latest-mac.yml" --body "./electron/dist/latest-mac.yml" --content-type "text/yaml"
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
|
||||
@ -148,7 +167,7 @@ jobs:
|
||||
|
||||
build-windows-x64:
|
||||
runs-on: windows-latest
|
||||
needs: delete-cloudflare-r2-folder
|
||||
needs: [delete-cloudflare-r2-folder, get-update-version]
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
@ -167,38 +186,12 @@ jobs:
|
||||
id: version_update
|
||||
shell: bash
|
||||
run: |
|
||||
# Function to get the latest release tag
|
||||
get_latest_tag() {
|
||||
local retries=0
|
||||
local max_retries=3
|
||||
local tag
|
||||
while [ $retries -lt $max_retries ]; do
|
||||
tag=$(curl -s https://api.github.com/repos/janhq/jan/releases/latest | jq -r .tag_name)
|
||||
if [ -n "$tag" ] && [ "$tag" != "null" ]; then
|
||||
echo $tag
|
||||
return
|
||||
else
|
||||
let retries++
|
||||
echo "Retrying... ($retries/$max_retries)"
|
||||
sleep 2
|
||||
fi
|
||||
done
|
||||
echo "Failed to fetch latest tag after $max_retries attempts."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Get the latest release tag from GitHub API
|
||||
LATEST_TAG=$(get_latest_tag)
|
||||
|
||||
# Remove the 'v' and append the build number to the version
|
||||
NEW_VERSION="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}"
|
||||
echo "New version: $NEW_VERSION"
|
||||
|
||||
# Update the version in electron/package.json
|
||||
jq --arg version "$NEW_VERSION" '.version = $version' electron/package.json > /tmp/package.json
|
||||
jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' electron/package.json > /tmp/package.json
|
||||
mv /tmp/package.json electron/package.json
|
||||
|
||||
echo "::set-output name=new_version::$NEW_VERSION"
|
||||
jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' web/package.json > /tmp/package.json
|
||||
mv /tmp/package.json web/package.json
|
||||
|
||||
jq '.build.publish = [{"provider": "generic", "url": "${{ secrets.CLOUDFLARE_R2_PUBLIC_URL }}", "channel": "latest"}]' electron/package.json > /tmp/package.json
|
||||
mv /tmp/package.json electron/package.json
|
||||
@ -223,18 +216,19 @@ jobs:
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: jan-win-x64-${{ steps.version_update.outputs.new_version }}
|
||||
name: jan-win-x64-${{ needs.get-update-version.outputs.new_version }}
|
||||
path: ./electron/dist/*.exe
|
||||
|
||||
- name: put-object using awscli s3api
|
||||
if: github.ref == 'refs/heads/main'
|
||||
shell: bash
|
||||
run: |
|
||||
ls -al ./electron/dist
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-win-x64-${{ steps.version_update.outputs.new_version }}.exe" --body "./electron/dist/jan-win-x64-${{ steps.version_update.outputs.new_version }}.exe"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-win-x64-${{ steps.version_update.outputs.new_version }}.exe.blockmap" --body "./electron/dist/jan-win-x64-${{ steps.version_update.outputs.new_version }}.exe.blockmap"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ steps.version_update.outputs.new_version }}/jan-win-x64-${{ steps.version_update.outputs.new_version }}.exe" --body "./electron/dist/jan-win-x64-${{ steps.version_update.outputs.new_version }}.exe"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe" --body "./electron/dist/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe.blockmap" --body "./electron/dist/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe.blockmap"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe" --body "./electron/dist/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/latest.yml" --body "./electron/dist/latest.yml"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ steps.version_update.outputs.new_version }}/latest.yml" --body "./electron/dist/latest.yml"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/latest.yml" --body "./electron/dist/latest.yml"
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
|
||||
@ -243,7 +237,7 @@ jobs:
|
||||
|
||||
build-linux-x64:
|
||||
runs-on: ubuntu-latest
|
||||
needs: delete-cloudflare-r2-folder
|
||||
needs: [delete-cloudflare-r2-folder, get-update-version]
|
||||
environment: production
|
||||
env:
|
||||
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
|
||||
@ -264,37 +258,11 @@ jobs:
|
||||
- name: Update app version base on tag
|
||||
id: version_update
|
||||
run: |
|
||||
# Function to get the latest release tag
|
||||
get_latest_tag() {
|
||||
local retries=0
|
||||
local max_retries=3
|
||||
local tag
|
||||
while [ $retries -lt $max_retries ]; do
|
||||
tag=$(curl -s https://api.github.com/repos/janhq/jan/releases/latest | jq -r .tag_name)
|
||||
if [ -n "$tag" ] && [ "$tag" != "null" ]; then
|
||||
echo $tag
|
||||
return
|
||||
else
|
||||
let retries++
|
||||
echo "Retrying... ($retries/$max_retries)"
|
||||
sleep 2
|
||||
fi
|
||||
done
|
||||
echo "Failed to fetch latest tag after $max_retries attempts."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Get the latest release tag from GitHub API
|
||||
LATEST_TAG=$(get_latest_tag)
|
||||
|
||||
# Remove the 'v' and append the build number to the version
|
||||
NEW_VERSION="${LATEST_TAG#v}-${GITHUB_RUN_NUMBER}"
|
||||
echo "New version: $NEW_VERSION"
|
||||
|
||||
# Update the version in electron/package.json
|
||||
jq --arg version "$NEW_VERSION" '.version = $version' electron/package.json > /tmp/package.json
|
||||
jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' electron/package.json > /tmp/package.json
|
||||
mv /tmp/package.json electron/package.json
|
||||
echo "::set-output name=new_version::$NEW_VERSION"
|
||||
jq --arg version "${{ needs.get-update-version.outputs.new_version }}" '.version = $version' web/package.json > /tmp/package.json
|
||||
mv /tmp/package.json web/package.json
|
||||
jq '.build.publish = [{"provider": "generic", "url": "${{ secrets.CLOUDFLARE_R2_PUBLIC_URL }}", "channel": "latest"}]' electron/package.json > /tmp/package.json
|
||||
mv /tmp/package.json electron/package.json
|
||||
|
||||
@ -307,16 +275,17 @@ jobs:
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: jan-linux-amd64-${{ steps.version_update.outputs.new_version }}
|
||||
name: jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}
|
||||
path: ./electron/dist/*.deb
|
||||
|
||||
- name: put-object using awscli s3api
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: |
|
||||
ls -al ./electron/dist
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-linux-amd64-${{ steps.version_update.outputs.new_version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ steps.version_update.outputs.new_version }}.deb" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ steps.version_update.outputs.new_version }}/jan-linux-amd64-${{ steps.version_update.outputs.new_version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ steps.version_update.outputs.new_version }}.deb" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --body "./electron/dist/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb" --content-type "application/octet-stream"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "latest/latest-linux.yml" --body "./electron/dist/latest-linux.yml" --content-type "text/yaml"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ steps.version_update.outputs.new_version }}/latest-linux.yml" --body "./electron/dist/latest-linux.yml" --content-type "text/yaml"
|
||||
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "${{ needs.get-update-version.outputs.new_version }}/latest-linux.yml" --body "./electron/dist/latest-linux.yml" --content-type "text/yaml"
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }}
|
||||
@ -324,7 +293,7 @@ jobs:
|
||||
AWS_EC2_METADATA_DISABLED: "true"
|
||||
|
||||
noti-discord-nightly-and-update-url-readme:
|
||||
needs: [build-macos, build-windows-x64, build-linux-x64, delete-cloudflare-r2-folder]
|
||||
needs: [build-macos, build-windows-x64, build-linux-x64, delete-cloudflare-r2-folder, get-update-version]
|
||||
environment: production
|
||||
if: github.event_name == 'schedule'
|
||||
runs-on: ubuntu-latest
|
||||
@ -335,16 +304,29 @@ jobs:
|
||||
fetch-depth: "0"
|
||||
token: ${{ secrets.PAT_SERVICE_ACCOUNT }}
|
||||
|
||||
- name: Set version to environment variable
|
||||
run: |
|
||||
echo "VERSION=${{ needs.get-update-version.outputs.new_version }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Notify Discord
|
||||
uses: Ilshidur/action-discord@master
|
||||
with:
|
||||
args: "Nightly build artifact: https://github.com/janhq/jan/actions/runs/{{ GITHUB_RUN_ID }}"
|
||||
args: |
|
||||
Jan App Nightly build artifact version {{ VERSION }}:
|
||||
- Windows: https://delta.jan.ai/{{ VERSION }}/jan-win-x64-{{ VERSION }}.exe
|
||||
- macOS Intel: https://delta.jan.ai/{{ VERSION }}/jan-mac-x64-{{ VERSION }}.dmg
|
||||
- macOS Apple Silicon: https://delta.jan.ai/{{ VERSION }}/jan-mac-arm64-{{ VERSION }}.dmg
|
||||
- Linux: https://delta.jan.ai/{{ VERSION }}/jan-linux-amd64-{{ VERSION }}.deb
|
||||
- Github action run: https://github.com/janhq/jan/actions/runs/{{ GITHUB_RUN_ID }}
|
||||
env:
|
||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
|
||||
- name: Update README.md with artifact URL
|
||||
run: |
|
||||
sed -i "s|<a href='https://github.com/janhq/jan/actions/runs/.*'>|<a href='https://github.com/janhq/jan/actions/runs/${GITHUB_RUN_ID}'>|" README.md
|
||||
sed -i "s|<a href='https://delta.jan.ai/.*/jan-win-x64-.*'>|<a href='https://delta.jan.ai/${{ needs.get-update-version.outputs.new_version }}/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe'>|" README.md
|
||||
sed -i "s|<a href='https://delta.jan.ai/.*/jan-mac-x64-.*'>|<a href='https://delta.jan.ai/${{ needs.get-update-version.outputs.new_version }}/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg'>|" README.md
|
||||
sed -i "s|<a href='https://delta.jan.ai/.*/jan-mac-arm64-.*'>|<a href='https://delta.jan.ai/${{ needs.get-update-version.outputs.new_version }}/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg'>|" README.md
|
||||
sed -i "s|<a href='https://delta.jan.ai/.*/jan-linux-amd64-.*'>|<a href='https://delta.jan.ai/${{ needs.get-update-version.outputs.new_version }}/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb'>|" README.md
|
||||
git config --global user.email "service@jan.ai"
|
||||
git config --global user.name "Service Account"
|
||||
git add README.md
|
||||
@ -354,9 +336,9 @@ jobs:
|
||||
GITHUB_RUN_ID: ${{ github.run_id }}
|
||||
|
||||
noti-discord-manual-and-update-url-readme:
|
||||
needs: [build-macos, build-windows-x64, build-linux-x64, delete-cloudflare-r2-folder]
|
||||
needs: [build-macos, build-windows-x64, build-linux-x64, delete-cloudflare-r2-folder, get-update-version]
|
||||
environment: production
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
@ -364,11 +346,21 @@ jobs:
|
||||
with:
|
||||
fetch-depth: "0"
|
||||
token: ${{ secrets.PAT_SERVICE_ACCOUNT }}
|
||||
|
||||
|
||||
- name: Set version to environment variable
|
||||
run: |
|
||||
echo "VERSION=${{ needs.get-update-version.outputs.new_version }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Notify Discord
|
||||
uses: Ilshidur/action-discord@master
|
||||
with:
|
||||
args: "Manual build artifact: https://github.com/janhq/jan/actions/runs/{{ GITHUB_RUN_ID }}"
|
||||
args: |
|
||||
Jan App Manual build artifact version {{ VERSION }}:
|
||||
- Windows: https://delta.jan.ai/{{ VERSION }}/jan-win-x64-{{ VERSION }}.exe
|
||||
- macOS Intel: https://delta.jan.ai/{{ VERSION }}/jan-mac-x64-{{ VERSION }}.dmg
|
||||
- macOS Apple Silicon: https://delta.jan.ai/{{ VERSION }}/jan-mac-arm64-{{ VERSION }}.dmg
|
||||
- Linux: https://delta.jan.ai/{{ VERSION }}/jan-linux-amd64-{{ VERSION }}.deb
|
||||
- Github action run: https://github.com/janhq/jan/actions/runs/{{ GITHUB_RUN_ID }}
|
||||
env:
|
||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
|
||||
@ -376,7 +368,10 @@ jobs:
|
||||
- name: Update README.md with artifact URL
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: |
|
||||
sed -i "s|<a href='https://github.com/janhq/jan/actions/runs/.*'>|<a href='https://github.com/janhq/jan/actions/runs/${GITHUB_RUN_ID}'>|" README.md
|
||||
sed -i "s|<a href='https://delta.jan.ai/.*/jan-win-x64-.*'>|<a href='https://delta.jan.ai/${{ needs.get-update-version.outputs.new_version }}/jan-win-x64-${{ needs.get-update-version.outputs.new_version }}.exe'>|" README.md
|
||||
sed -i "s|<a href='https://delta.jan.ai/.*/jan-mac-x64-.*'>|<a href='https://delta.jan.ai/${{ needs.get-update-version.outputs.new_version }}/jan-mac-x64-${{ needs.get-update-version.outputs.new_version }}.dmg'>|" README.md
|
||||
sed -i "s|<a href='https://delta.jan.ai/.*/jan-mac-arm64-.*'>|<a href='https://delta.jan.ai/${{ needs.get-update-version.outputs.new_version }}/jan-mac-arm64-${{ needs.get-update-version.outputs.new_version }}.dmg'>|" README.md
|
||||
sed -i "s|<a href='https://delta.jan.ai/.*/jan-linux-amd64-.*'>|<a href='https://delta.jan.ai/${{ needs.get-update-version.outputs.new_version }}/jan-linux-amd64-${{ needs.get-update-version.outputs.new_version }}.deb'>|" README.md
|
||||
git config --global user.email "service@jan.ai"
|
||||
git config --global user.name "Service Account"
|
||||
git add README.md
|
||||
|
||||
6
.github/workflows/jan-electron-build.yml
vendored
6
.github/workflows/jan-electron-build.yml
vendored
@ -60,6 +60,8 @@ jobs:
|
||||
fi
|
||||
jq --arg version "${VERSION_TAG#v}" '.version = $version' electron/package.json > /tmp/package.json
|
||||
mv /tmp/package.json electron/package.json
|
||||
jq --arg version "${VERSION_TAG#v}" '.version = $version' web/package.json > /tmp/package.json
|
||||
mv /tmp/package.json web/package.json
|
||||
env:
|
||||
VERSION_TAG: ${{ steps.tag.outputs.tag }}
|
||||
|
||||
@ -120,6 +122,8 @@ jobs:
|
||||
fi
|
||||
jq --arg version "${VERSION_TAG#v}" '.version = $version' electron/package.json > /tmp/package.json
|
||||
mv /tmp/package.json electron/package.json
|
||||
jq --arg version "${VERSION_TAG#v}" '.version = $version' web/package.json > /tmp/package.json
|
||||
mv /tmp/package.json web/package.json
|
||||
jq '.build.win.sign = "./sign.js"' electron/package.json > /tmp/package.json
|
||||
mv /tmp/package.json electron/package.json
|
||||
env:
|
||||
@ -203,6 +207,8 @@ jobs:
|
||||
fi
|
||||
jq --arg version "${VERSION_TAG#v}" '.version = $version' electron/package.json > /tmp/package.json
|
||||
mv /tmp/package.json electron/package.json
|
||||
jq --arg version "${VERSION_TAG#v}" '.version = $version' web/package.json > /tmp/package.json
|
||||
mv /tmp/package.json web/package.json
|
||||
env:
|
||||
VERSION_TAG: ${{ steps.tag.outputs.tag }}
|
||||
|
||||
|
||||
10
Makefile
10
Makefile
@ -52,21 +52,17 @@ build: check-file-counts
|
||||
clean:
|
||||
ifeq ($(OS),Windows_NT)
|
||||
powershell -Command "Get-ChildItem -Path . -Include node_modules, .next, dist -Recurse -Directory | Remove-Item -Recurse -Force"
|
||||
rmdir /s /q "%USERPROFILE%\AppData\Roaming\jan"
|
||||
rmdir /s /q "%USERPROFILE%\AppData\Roaming\jan-electron"
|
||||
rmdir /s /q "%USERPROFILE%\AppData\Local\jan*"
|
||||
rmdir /s /q "%USERPROFILE%\jan\extensions"
|
||||
else ifeq ($(shell uname -s),Linux)
|
||||
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
|
||||
find . -name ".next" -type d -exec rm -rf '{}' +
|
||||
find . -name "dist" -type d -exec rm -rf '{}' +
|
||||
rm -rf "~/.config/jan"
|
||||
rm -rf "~/.config/jan-electron"
|
||||
rm -rf "~/jan/extensions"
|
||||
rm -rf "~/.cache/jan*"
|
||||
else
|
||||
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
|
||||
find . -name ".next" -type d -exec rm -rf '{}' +
|
||||
find . -name "dist" -type d -exec rm -rf '{}' +
|
||||
rm -rf ~/Library/Application\ Support/jan
|
||||
rm -rf ~/Library/Application\ Support/jan-electron
|
||||
rm -rf ~/jan/extensions
|
||||
rm -rf ~/Library/Caches/jan*
|
||||
endif
|
||||
|
||||
75
README.md
75
README.md
@ -34,13 +34,13 @@ Jan is an open-source ChatGPT alternative that runs 100% offline on your compute
|
||||
## Download
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<tr style="text-align:center">
|
||||
<td style="text-align:center"><b>Version Type</b></td>
|
||||
<td style="text-align:center"><b>Windows</b></td>
|
||||
<td colspan="2" style="text-align:center"><b>MacOS</b></td>
|
||||
<td style="text-align:center"><b>Linux</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr style="text-align:center">
|
||||
<td style="text-align:center"><b>Stable (Recommended)</b></td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://github.com/janhq/jan/releases/download/v0.4.3/jan-win-x64-0.4.3.exe'>
|
||||
@ -67,11 +67,30 @@ Jan is an open-source ChatGPT alternative that runs 100% offline on your compute
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="text-align: center">
|
||||
<tr style="text-align:center">
|
||||
<td style="text-align:center"><b>Experimental (Nightly Build)</b></td>
|
||||
<td style="text-align:center" colspan="4">
|
||||
<a href='https://github.com/janhq/jan/actions/runs/7382651728'>
|
||||
<b>Github action artifactory</b>
|
||||
<td style="text-align:center">
|
||||
<a href='https://delta.jan.ai/0.4.3-112/jan-win-x64-0.4.3-112.exe'>
|
||||
<img src='./docs/static/img/windows.png' style="height:14px; width: 14px" />
|
||||
<b>jan.exe</b>
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://delta.jan.ai/0.4.3-112/jan-mac-x64-0.4.3-112.dmg'>
|
||||
<img src='./docs/static/img/mac.png' style="height:15px; width: 15px" />
|
||||
<b>Intel</b>
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://delta.jan.ai/0.4.3-112/jan-mac-arm64-0.4.3-112.dmg'>
|
||||
<img src='./docs/static/img/mac.png' style="height:15px; width: 15px" />
|
||||
<b>M1/M2</b>
|
||||
</a>
|
||||
</td>
|
||||
<td style="text-align:center">
|
||||
<a href='https://delta.jan.ai/0.4.3-112/jan-linux-amd64-0.4.3-112.deb'>
|
||||
<img src='./docs/static/img/linux.png' style="height:14px; width: 14px" />
|
||||
<b>jan.deb</b>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
@ -111,18 +130,7 @@ As Jan is in development mode, you might get stuck on a broken build.
|
||||
|
||||
To reset your installation:
|
||||
|
||||
1. **Remove Jan from your Applications folder and Cache folder**
|
||||
|
||||
```bash
|
||||
make clean
|
||||
```
|
||||
|
||||
This will remove all build artifacts and cached files:
|
||||
|
||||
- Delete Jan from your `/Applications` folder
|
||||
- Clear Application cache in `/Users/$(whoami)/Library/Caches/jan`
|
||||
|
||||
2. Use the following commands to remove any dangling backend processes:
|
||||
1. Use the following commands to remove any dangling backend processes:
|
||||
|
||||
```sh
|
||||
ps aux | grep nitro
|
||||
@ -134,6 +142,18 @@ To reset your installation:
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
2. **Remove Jan from your Applications folder and Cache folder**
|
||||
|
||||
```bash
|
||||
make clean
|
||||
```
|
||||
|
||||
This will remove all build artifacts and cached files:
|
||||
|
||||
- Delete Jan extension from your `~/jan/extensions` folder
|
||||
- Delete all `node_modules` in current folder
|
||||
- Clear Application cache in `~/Library/Caches/jan`
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) file
|
||||
@ -172,25 +192,6 @@ make build
|
||||
|
||||
This will build the app MacOS m1/m2 for production (with code signing already done) and put the result in `dist` folder.
|
||||
|
||||
## Nightly Build
|
||||
|
||||
Our nightly build process for this project is defined in [`.github/workflows/jan-electron-build-nightly.yml`](.github/workflows/jan-electron-build-nightly.yml)
|
||||
|
||||
The nightly build is triggered at 2:00 AM UTC every day.
|
||||
|
||||
Getting on Nightly:
|
||||
|
||||
1. Join our Discord server [here](https://discord.gg/FTk2MvZwJH) and go to channel [github-jan](https://discordapp.com/channels/1107178041848909847/1148534730359308298).
|
||||
2. Download the build artifacts from the channel.
|
||||
3. Subsequently, to get the latest nightly, just quit and restart the app.
|
||||
4. Upon app restart, you will be automatically prompted to update to the latest nightly build.
|
||||
|
||||
## Manual Build
|
||||
|
||||
Stable releases are triggered by manual builds. This is usually done for new features or a bug fixes.
|
||||
|
||||
The process for this project is defined in [`.github/workflows/jan-electron-build-nightly.yml`](.github/workflows/jan-electron-build-nightly.yml)
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
Jan builds on top of other open-source projects:
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
*/
|
||||
export class ModuleManager {
|
||||
public requiredModules: Record<string, any> = {}
|
||||
public cleaningResource = false
|
||||
|
||||
public static instance: ModuleManager = new ModuleManager()
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@ import { handleAppIPCs } from './handlers/app'
|
||||
import { handleAppUpdates } from './handlers/update'
|
||||
import { handleFsIPCs } from './handlers/fs'
|
||||
import { migrateExtensions } from './utils/migration'
|
||||
import { dispose } from './utils/disposable'
|
||||
|
||||
app
|
||||
.whenReady()
|
||||
@ -37,14 +38,12 @@ app
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
ModuleManager.instance.clearImportedModules()
|
||||
app.quit()
|
||||
app.once('window-all-closed', () => {
|
||||
cleanUpAndQuit()
|
||||
})
|
||||
|
||||
app.on('quit', () => {
|
||||
ModuleManager.instance.clearImportedModules()
|
||||
app.quit()
|
||||
app.once('quit', () => {
|
||||
cleanUpAndQuit()
|
||||
})
|
||||
|
||||
function createMainWindow() {
|
||||
@ -83,3 +82,13 @@ function handleIPCs() {
|
||||
handleAppIPCs()
|
||||
handleFileMangerIPCs()
|
||||
}
|
||||
|
||||
function cleanUpAndQuit() {
|
||||
if (!ModuleManager.instance.cleaningResource) {
|
||||
ModuleManager.instance.cleaningResource = true
|
||||
WindowManager.instance.currentWindow?.destroy()
|
||||
dispose(ModuleManager.instance.requiredModules)
|
||||
ModuleManager.instance.clearImportedModules()
|
||||
app.quit()
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ export const startServer = async (schemaPath?: string, baseDir?: string) => {
|
||||
});
|
||||
|
||||
await server.register(require("@fastify/swagger-ui"), {
|
||||
routePrefix: "/docs",
|
||||
routePrefix: "/",
|
||||
baseDir: baseDir ?? path.join(__dirname, "../..", "./docs/openapi"),
|
||||
uiConfig: {
|
||||
docExpansion: "full",
|
||||
|
||||
@ -26,7 +26,7 @@ import { useMainViewState } from '@/hooks/useMainViewState'
|
||||
|
||||
import useRecommendedModel from '@/hooks/useRecommendedModel'
|
||||
|
||||
import { toGigabytes } from '@/utils/converter'
|
||||
import { toGibibytes } from '@/utils/converter'
|
||||
|
||||
import {
|
||||
activeThreadAtom,
|
||||
@ -130,7 +130,7 @@ export default function DropdownListSidebar() {
|
||||
<div className="flex w-full justify-between">
|
||||
<span className="line-clamp-1 block">{x.name}</span>
|
||||
<span className="font-bold text-muted-foreground">
|
||||
{toGigabytes(x.metadata.size)}
|
||||
{toGibibytes(x.metadata.size)}
|
||||
</span>
|
||||
</div>
|
||||
</SelectItem>
|
||||
|
||||
@ -21,7 +21,7 @@ import { getAssistants } from '@/hooks/useGetAssistants'
|
||||
import { useGetDownloadedModels } from '@/hooks/useGetDownloadedModels'
|
||||
import { useMainViewState } from '@/hooks/useMainViewState'
|
||||
|
||||
import { toGigabytes } from '@/utils/converter'
|
||||
import { toGibibytes } from '@/utils/converter'
|
||||
|
||||
type Props = {
|
||||
model: Model
|
||||
@ -99,7 +99,7 @@ const ExploreModelItemHeader: React.FC<Props> = ({ model, onClick, open }) => {
|
||||
</div>
|
||||
<div className="inline-flex items-center space-x-2">
|
||||
<span className="mr-4 font-semibold text-muted-foreground">
|
||||
{toGigabytes(model.metadata.size)}
|
||||
{toGibibytes(model.metadata.size)}
|
||||
</span>
|
||||
{downloadButton}
|
||||
<ChevronDownIcon
|
||||
|
||||
@ -14,8 +14,6 @@ import { useDownloadState } from '@/hooks/useDownloadState'
|
||||
import { useGetDownloadedModels } from '@/hooks/useGetDownloadedModels'
|
||||
import { useMainViewState } from '@/hooks/useMainViewState'
|
||||
|
||||
import { toGigabytes } from '@/utils/converter'
|
||||
|
||||
type Props = {
|
||||
model: Model
|
||||
isRecommended: boolean
|
||||
|
||||
@ -15,7 +15,7 @@ import { useClickOutside } from '@/hooks/useClickOutside'
|
||||
|
||||
import useDeleteModel from '@/hooks/useDeleteModel'
|
||||
|
||||
import { toGigabytes } from '@/utils/converter'
|
||||
import { toGibibytes } from '@/utils/converter'
|
||||
|
||||
type RowModelProps = {
|
||||
data: Model
|
||||
@ -52,7 +52,7 @@ export default function RowModel(props: RowModelProps) {
|
||||
<td className="px-6 py-4">
|
||||
<Badge themes="secondary">
|
||||
{props.data.metadata.size
|
||||
? toGigabytes(props.data.metadata.size)
|
||||
? toGibibytes(props.data.metadata.size)
|
||||
: '-'}
|
||||
</Badge>
|
||||
</td>
|
||||
|
||||
@ -4,7 +4,7 @@ import { useAtomValue } from 'jotai'
|
||||
|
||||
import { useActiveModel } from '@/hooks/useActiveModel'
|
||||
|
||||
import { toGigabytes } from '@/utils/converter'
|
||||
import { toGibibytes } from '@/utils/converter'
|
||||
|
||||
import {
|
||||
cpuUsageAtom,
|
||||
@ -31,7 +31,7 @@ export default function SystemMonitorScreen() {
|
||||
ram ({Math.round((usedRam / totalRam) * 100)}%)
|
||||
</h4>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{toGigabytes(usedRam)} of {toGigabytes(totalRam)} used
|
||||
{toGibibytes(usedRam)} of {toGibibytes(totalRam)} used
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
@ -87,7 +87,7 @@ export default function SystemMonitorScreen() {
|
||||
<td className="px-6 py-2 font-bold">{activeModel.id}</td>
|
||||
<td className="px-6 py-2">
|
||||
<Badge themes="secondary">
|
||||
{toGigabytes(activeModel.metadata.size)}
|
||||
{toGibibytes(activeModel.metadata.size)}
|
||||
</Badge>
|
||||
</td>
|
||||
<td className="px-6 py-2">
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
export const toGigabytes = (input: number) => {
|
||||
export const toGibibytes = (input: number) => {
|
||||
if (!input) return ''
|
||||
if (input > 1024 ** 3) {
|
||||
return (input / 1000 ** 3).toFixed(2) + 'GB'
|
||||
return (input / 1024 ** 3).toFixed(2) + 'GB'
|
||||
} else if (input > 1024 ** 2) {
|
||||
return (input / 1000 ** 2).toFixed(2) + 'MB'
|
||||
return (input / 1024 ** 2).toFixed(2) + 'MB'
|
||||
} else if (input > 1024) {
|
||||
return (input / 1000).toFixed(2) + 'KB'
|
||||
return (input / 1024).toFixed(2) + 'KB'
|
||||
} else {
|
||||
return input + 'B'
|
||||
}
|
||||
@ -21,7 +21,7 @@ export const formatDownloadPercentage = (
|
||||
|
||||
export const formatDownloadSpeed = (input: number | undefined) => {
|
||||
if (!input) return '0B/s'
|
||||
return toGigabytes(input) + '/s'
|
||||
return toGibibytes(input) + '/s'
|
||||
}
|
||||
|
||||
export const formatTwoDigits = (input: number) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user