Skip to content

Commit

Permalink
Merge pull request #3822 from janhq/dev
Browse files Browse the repository at this point in the history
release: Jan Release Cut v0.5.7
  • Loading branch information
louis-menlo authored Oct 23, 2024
2 parents 3f6843a + 4620732 commit 33eda22
Show file tree
Hide file tree
Showing 508 changed files with 19,544 additions and 333 deletions.
47 changes: 47 additions & 0 deletions .github/scripts/rename-app-beta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Check if the correct number of arguments is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <path_to_json_input_file>"
exit 1
fi

INPUT_JSON_FILE="$1"

# Check if the input file exists
if [ ! -f "$INPUT_JSON_FILE" ]; then
echo "Input file not found: $INPUT_JSON_FILE"
exit 1
fi

# Use jq to transform the content
jq '
.name = "jan-beta" |
.productName = "Jan-beta" |
.build.appId = "jan-beta.ai.app" |
.build.productName = "Jan-beta" |
.build.appId = "jan-beta.ai.app" |
.build.protocols[0].name = "Jan-beta" |
.build.protocols[0].schemes = ["jan-beta"] |
.build.artifactName = "jan-beta-${os}-${arch}-${version}.${ext}" |
.build.publish[0].channel = "beta"
' "$INPUT_JSON_FILE" > ./package.json.tmp

cat ./package.json.tmp

rm $INPUT_JSON_FILE
mv ./package.json.tmp $INPUT_JSON_FILE

# Update the layout file
LAYOUT_FILE_PATH="web/app/layout.tsx"

if [ ! -f "$LAYOUT_FILE_PATH" ]; then
echo "File does not exist: $LAYOUT_FILE_PATH"
exit 1
fi

# Perform the replacements
sed -i -e "s#Jan#Jan-beta#g" "$LAYOUT_FILE_PATH"

# Notify completion
echo "File has been updated: $LAYOUT_FILE_PATH"
16 changes: 16 additions & 0 deletions .github/scripts/rename-uninstaller-beta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# File path to be modified
FILE_PATH="electron/scripts/uninstaller.nsh"

# Check if the file exists
if [ ! -f "$FILE_PATH" ]; then
echo "File does not exist: $FILE_PATH"
exit 1
fi

# Perform the replacements
sed -i -e "s#jan#jan-beta#g" "$FILE_PATH"

# Notify completion
echo "File has been updated: $FILE_PATH"
16 changes: 16 additions & 0 deletions .github/scripts/rename-workspace-beta.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# File path to be modified
FILE_PATH="$1"

# Check if the file exists
if [ ! -f "$FILE_PATH" ]; then
echo "File does not exist: $FILE_PATH"
exit 1
fi

# Perform the replacements
sed -i -e 's/yarn workspace jan/yarn workspace jan-beta/g' "$FILE_PATH"

# Notify completion
echo "File has been updated: $FILE_PATH"
25 changes: 0 additions & 25 deletions .github/workflows/auto-trigger-jan-docs.yaml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/clean-cloudflare-page-preview-url-and-r2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Clean old cloudflare pages preview urls and nightly build"
on:
schedule:
- cron: "0 0 * * *" # every day at 00:00
workflow_dispatch:

jobs:
clean-cloudflare-pages-preview-urls:
strategy:
matrix:
project: ["nitro", "docs"]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: install requests
run: |
python3 -m pip install requests pytz tqdm
- name: Python Inline script
uses: jannekem/run-python-script-action@v1
with:
script: |
import requests
from datetime import datetime, UTC
from pytz import timezone
from tqdm import tqdm
# Configuration
endpoint = "https://api.cloudflare.com/client/v4/accounts/${{ secrets.CLOUDFLARE_ACCOUNT_ID }}/pages/projects/${{ matrix.project }}/deployments"
expiration_days = 3
headers = {
"Content-Type": "application/json;charset=UTF-8",
"Authorization": "Bearer ${{ secrets.CLOUDFLARE_API_TOKEN }}"
}
utc_tz = timezone('UTC')
# Fetch the list of deployments
response = requests.get(endpoint, headers=headers)
deployments = response.json()
for deployment in tqdm(deployments['result']):
# Calculate the age of the deployment
created_on = datetime.strptime(deployment['created_on'], "%Y-%m-%dT%H:%M:%S.%fZ").replace(tzinfo=utc_tz)
if (datetime.now(UTC) - created_on).days > expiration_days:
# Delete the deployment
delete_response = requests.delete(f"{endpoint}/{deployment['id']}", headers=headers)
if delete_response.status_code == 200:
print(f"Deleted deployment: {deployment['id']}")
else:
print(f"Failed to delete deployment: {deployment['id']}")
63 changes: 63 additions & 0 deletions .github/workflows/jan-docs-new-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Deploy Docs on new release

on:
release:
types:
- published
- edited
- released

jobs:
deploy:
name: Deploy to CloudFlare Pages
env:
CLOUDFLARE_PROJECT_NAME: docs
runs-on: ubuntu-latest
permissions:
contents: write
deployments: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: dev
- uses: actions/setup-node@v3
with:
node-version: 18

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

- name: Fill env vars
working-directory: docs
run: |
env_example_file=".env.example"
touch .env
while IFS= read -r line || [[ -n "$line" ]]; do
if [[ "$line" == *"="* ]]; then
var_name=$(echo $line | cut -d '=' -f 1)
echo $var_name
var_value="$(jq -r --arg key "$var_name" '.[$key]' <<< "$SECRETS")"
echo "$var_name=$var_value" >> .env
fi
done < "$env_example_file"
env:
SECRETS: '${{ toJson(secrets) }}'

- name: Install dependencies
working-directory: docs
run: yarn install
- name: Build website
working-directory: docs
run: export NODE_ENV=production && yarn build && cp _redirects out/_redirects

- name: Publish to Cloudflare Pages Production
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ env.CLOUDFLARE_PROJECT_NAME }}
directory: ./docs/out
branch: dev
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
88 changes: 88 additions & 0 deletions .github/workflows/jan-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Jan Docs

on:
push:
branches:
- dev
paths:
- 'docs/**'
- '.github/workflows/jan-docs.yml'
pull_request:
paths:
- 'docs/**'
- '.github/workflows/jan-docs.yml'
# Review gh actions docs if you want to further define triggers, paths, etc
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on
workflow_dispatch:

jobs:
deploy:
name: Deploy to CloudFlare Pages
env:
CLOUDFLARE_PROJECT_NAME: docs
runs-on: ubuntu-latest
permissions:
contents: write
deployments: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18

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

- name: Fill env vars
working-directory: docs
run: |
env_example_file=".env.example"
touch .env
while IFS= read -r line || [[ -n "$line" ]]; do
if [[ "$line" == *"="* ]]; then
var_name=$(echo $line | cut -d '=' -f 1)
echo $var_name
var_value="$(jq -r --arg key "$var_name" '.[$key]' <<< "$SECRETS")"
echo "$var_name=$var_value" >> .env
fi
done < "$env_example_file"
env:
SECRETS: '${{ toJson(secrets) }}'

- name: Install dependencies
working-directory: docs
run: yarn install
- name: Build website
working-directory: docs
run: export NODE_ENV=production && yarn build && cp _redirects out/_redirects

- name: Publish to Cloudflare Pages PR Preview and Staging
if: github.event_name == 'pull_request'
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ env.CLOUDFLARE_PROJECT_NAME }}
directory: ./docs/out
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
id: deployCloudflarePages

- uses: mshick/add-pr-comment@v2
if: github.event_name == 'pull_request'
with:
message: |
Preview URL: ${{ steps.deployCloudflarePages.outputs.url }}
- name: Publish to Cloudflare Pages Production
if: (github.event_name == 'push' && github.ref == 'refs/heads/dev') || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/dev')
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ env.CLOUDFLARE_PROJECT_NAME }}
directory: ./docs/out
branch: dev
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 33eda22

Please sign in to comment.