From 64a50e02b42035be67ea66df1d7228f38149b1cc Mon Sep 17 00:00:00 2001 From: hiento09 <136591877+hiento09@users.noreply.github.com> Date: Thu, 28 Sep 2023 17:54:30 +0700 Subject: [PATCH] Add CICD for macos (#221) Co-authored-by: Hien To --- .github/workflows/ci-production.yml | 53 ------------------------ .github/workflows/ci-staging.yml | 58 --------------------------- .github/workflows/macos-build-app.yml | 50 +++++++++++++++++++++++ README.md | 6 ++- electron/package.json | 4 +- 5 files changed, 57 insertions(+), 114 deletions(-) delete mode 100644 .github/workflows/ci-production.yml delete mode 100644 .github/workflows/ci-staging.yml create mode 100644 .github/workflows/macos-build-app.yml diff --git a/.github/workflows/ci-production.yml b/.github/workflows/ci-production.yml deleted file mode 100644 index 0d0a0a152c..0000000000 --- a/.github/workflows/ci-production.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Jan CI Production - -on: - push: - tags: ['v*.*.*'] - -env: - REGISTRY: ghcr.io - HASURA_WORKER_IMAGE_NAME: ${{ github.repository }}/worker - WEB_CLIENT_IMAGE_NAME: ${{ github.repository }}/web-client - -jobs: - build-docker-image: - runs-on: ubuntu-latest - environment: production - permissions: - contents: read - packages: write - steps: - - name: Getting the repo - uses: actions/checkout@v3 - - - name: Log in to the Container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Get tag - id: tag - uses: dawidd6/action-get-tag@v1 - - # Build and docker image for app-backend worker - - name: Build docker image for app-backend worker - run: | - cd ./app-backend/worker - docker build -t ${{ env.REGISTRY }}/${{ env.HASURA_WORKER_IMAGE_NAME }}:${{ steps.tag.outputs.tag }} . - docker push ${{ env.REGISTRY }}/${{ env.HASURA_WORKER_IMAGE_NAME }}:${{ steps.tag.outputs.tag }} - - # Get .env for FE - - name: Get .env file for build time - run: cd ./web-client && base64 -d <<< "$ENV_FILE_BASE64" > .env - shell: bash - env: - ENV_FILE_BASE64: ${{ secrets.ENV_FILE_BASE64 }} - - # Build and push docker for web client - - name: Build docker image for web-client - run: | - cd ./web-client - docker build -t ${{ env.REGISTRY }}/${{ env.WEB_CLIENT_IMAGE_NAME }}:${{ steps.tag.outputs.tag }} . - docker push ${{ env.REGISTRY }}/${{ env.WEB_CLIENT_IMAGE_NAME }}:${{ steps.tag.outputs.tag }} diff --git a/.github/workflows/ci-staging.yml b/.github/workflows/ci-staging.yml deleted file mode 100644 index 5f42cef4b6..0000000000 --- a/.github/workflows/ci-staging.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Jan CI Staging -on: - push: - branches: - - stag - paths: - - 'app-backend/worker/**' # hasura worker source code - - 'web-client/**' # web client source code - -env: - REGISTRY: ghcr.io - HASURA_WORKER_IMAGE_NAME: ${{ github.repository }}/worker - WEB_CLIENT_IMAGE_NAME: ${{ github.repository }}/web-client - -jobs: - build-docker-image: - runs-on: ubuntu-latest - environment: staging - permissions: - contents: read - packages: write - steps: - - name: Getting the repo - uses: actions/checkout@v3 - - - name: Log in to the Container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Get current date - id: date - run: echo "::set-output name=date::$(date +'%Y.%m.%d')" - - # Build docker image for app-backend worker - - name: Build docker image for app-backend worker - if: ${{ contains(github.event.head_commit.added, 'app-backend/worker/') }} - run: | - cd ./app-backend/worker - docker build -t ${{ env.REGISTRY }}/${{ env.HASURA_WORKER_IMAGE_NAME }}:staging-${{ steps.date.outputs.date }}.${{github.run_number}} . - docker push ${{ env.REGISTRY }}/${{ env.HASURA_WORKER_IMAGE_NAME }}:staging-${{ steps.date.outputs.date }}.${{github.run_number}} - - # Get .env for FE - - name: Get .env file for build time - run: cd ./web-client && base64 -d <<< "$ENV_FILE_BASE64" > .env - shell: bash - env: - ENV_FILE_BASE64: ${{ secrets.ENV_FILE_BASE64 }} - - # Build and push docker for web client - - name: Build docker image for web-client - if: ${{ contains(github.event.head_commit.added, 'web-client/') }} - run: | - cd ./web-client - docker build -t ${{ env.REGISTRY }}/${{ env.WEB_CLIENT_IMAGE_NAME }}:staging-${{ steps.date.outputs.date }}.${{github.run_number}} . - docker push ${{ env.REGISTRY }}/${{ env.WEB_CLIENT_IMAGE_NAME }}:staging-${{ steps.date.outputs.date }}.${{github.run_number}} diff --git a/.github/workflows/macos-build-app.yml b/.github/workflows/macos-build-app.yml new file mode 100644 index 0000000000..0977d1a6f7 --- /dev/null +++ b/.github/workflows/macos-build-app.yml @@ -0,0 +1,50 @@ +name: Jan Build MacOS App + +on: + push: + tags: ['v*.*.*'] + +jobs: + build-macos-app: + runs-on: macos-latest + + 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: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 + + - name: Update app version base on tag + run: | + if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: Tag is not valid!" + exit 1 + fi + jq --arg version "${VERSION_TAG#v}" '.version = $version' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json + env: + VERSION_TAG: ${{ steps.tag.outputs.tag }} + + - name: Install yarn dependencies + run: | + yarn install + yarn build:plugins + + - name: Build and publish app + run: | + yarn build:publish + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/README.md b/README.md index 27eb72fa83..682be7ca99 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,9 @@ Note: This instruction is tested on MacOS only. ``` yarn install + + # Packing base plugins + yarn build:plugins ``` 4. **Run development and Using Jan Desktop** @@ -108,6 +111,7 @@ Note: This instruction is tested on MacOS only. git clone https://github.com/janhq/jan cd jan yarn install + yarn build:plugins # Build the app yarn build @@ -123,7 +127,7 @@ Contributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) fi ```sh # From the root, run: -yarn +yarn install yarn build:plugins diff --git a/electron/package.json b/electron/package.json index 797acb948d..1f00675a55 100644 --- a/electron/package.json +++ b/electron/package.json @@ -27,8 +27,8 @@ }, "scripts": { "dev": "tsc -p . && electron .", - "build": "tsc -p . && electron-builder -p never -mwl", - "build:publish": "tsc -p . && electron-builder -p onTagOrDraft -mwl", + "build": "tsc -p . && electron-builder -p never -mw", + "build:publish": "tsc -p . && electron-builder -p onTagOrDraft -mw", "postinstall": "electron-builder install-app-deps" }, "dependencies": {