diff --git a/.gitea/workflows/deploy-client.yml b/.gitea/workflows/deploy-client.yml index c90770b..5404c56 100644 --- a/.gitea/workflows/deploy-client.yml +++ b/.gitea/workflows/deploy-client.yml @@ -2,16 +2,15 @@ name: Deploy on: push: - branches: - - release - # tags: - # - "v[0-9]+.[0-9]+.[0-9]+" + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + paths: - ".gitea/workflows/deploy-client.yml" - "client/**" jobs: - publish-web: + publish-windows: runs-on: ubuntu-latest steps: @@ -27,48 +26,55 @@ jobs: persist-credentials: false - name: Build - run: docker build -t chad-client ./client --build-arg COMMIT_SHA=${{ gitea.sha }} --build-arg API_BASE_URL=${{ vars.API_BASE_URL }} - - - name: Stop old container - run: docker rm -f chad-client || true - - - name: Run run: | - docker run -d \ - --name chad-client \ - --network traefik \ - --label "traefik.enable=true" \ - --label "traefik.http.routers.chad-client.rule=Host(\`chad.koptilnya.xyz\`)" \ - --label "traefik.http.routers.chad-client.entrypoints=websecure" \ - --label "traefik.http.routers.chad-client.tls.certresolver=myresolver" \ - --label "traefik.http.services.chad-client.loadbalancer.server.port=80" \ - chad-client:latest + docker build \ + -t chad-client-windows-builder \ + -f ./client/Dockerfile.windows \ + ./client \ + --build-arg COMMIT_SHA=${{ gitea.sha }} \ + --build-arg API_BASE_URL=${{ vars.API_BASE_URL }} \ + --build-arg TAURI_SIGNING_PRIVATE_KEY=${{ secrets.TAURI_SIGNING_PRIVATE_KEY }} - publish-tauri: - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 + docker create --name chad-client-windows-container chad-client-windows-builder + docker cp chad-client-windows-container:/app/src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis ./nsis + docker rm chad-client-windows-container - - name: setup node - uses: actions/setup-node@v4 + - name: Publish + uses: akkuman/gitea-release-action@v1 with: - node-version: lts/* + files: | + nsis/** + draft: true - - name: install Rust stable - uses: dtolnay/rust-toolchain@stable + # publish-web: + # runs-on: ubuntu-latest - - name: install frontend dependencies - run: yarn install + # steps: + # - name: Keyscan + # run: | + # ssh-keyscan git.koptilnya.xyz >> ~/.ssh/known_hosts - - uses: tauri-apps/tauri-action@v1 - env: - GITHUB_TOKEN: ${{ secrets.TOKEN }} - with: - tagName: app-v__VERSION__ - releaseName: "App v__VERSION__" - releaseBody: "See the assets to download this version and install." - releaseDraft: true - projectPath: "./client" - githubBaseUrl: "https://git.koptilnya.xyz/api/v1" - isGitea: true - prerelease: false + # - name: Checkout + # uses: actions/checkout@v4 + # with: + # ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + # ssh-strict: false + # persist-credentials: false + + # - name: Build + # run: docker build -t chad-client -f ./client/Dockerfile.web ./client --build-arg COMMIT_SHA=${{ gitea.sha }} --build-arg API_BASE_URL=${{ vars.API_BASE_URL }} + + # - name: Stop old container + # run: docker rm -f chad-client || true + + # - name: Run + # run: | + # docker run -d \ + # --name chad-client \ + # --network traefik \ + # --label "traefik.enable=true" \ + # --label "traefik.http.routers.chad-client.rule=Host(\`chad.koptilnya.xyz\`)" \ + # --label "traefik.http.routers.chad-client.entrypoints=websecure" \ + # --label "traefik.http.routers.chad-client.tls.certresolver=myresolver" \ + # --label "traefik.http.services.chad-client.loadbalancer.server.port=80" \ + # chad-client:latest diff --git a/client/Dockerfile b/client/Dockerfile.web similarity index 100% rename from client/Dockerfile rename to client/Dockerfile.web diff --git a/client/Dockerfile.windows b/client/Dockerfile.windows new file mode 100644 index 0000000..a14e3a4 --- /dev/null +++ b/client/Dockerfile.windows @@ -0,0 +1,40 @@ +FROM node:lts + +WORKDIR /app + +RUN corepack enable yarn +RUN yarn set version stable + +COPY package.json yarn.lock .yarnrc.yml ./ + +RUN yarn install +COPY . . + +ARG COMMIT_SHA=unknown +ARG API_BASE_URL +ARG TAURI_SIGNING_PRIVATE_KEY + +ENV COMMIT_SHA=$COMMIT_SHA \ + API_BASE_URL=$API_BASE_URL \ + TAURI_SIGNING_PRIVATE_KEY=$TAURI_SIGNING_PRIVATE_KEY \ + TAURI_SIGNING_PRIVATE_KEY_PASSWORD= + +RUN apt update && apt install -y \ + nsis \ + clang \ + lld \ + llvm + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + +ENV PATH=/root/.cargo/bin:$PATH + +RUN rustup target add x86_64-pc-windows-msvc + +RUN cargo install --locked cargo-xwin + +RUN yarn tauri build --runner cargo-xwin --target x86_64-pc-windows-msvc + +RUN node scripts/generate-updater.js + +RUN ls -la diff --git a/client/scripts/generate-updater.mjs b/client/scripts/generate-updater.mjs new file mode 100644 index 0000000..0a14901 --- /dev/null +++ b/client/scripts/generate-updater.mjs @@ -0,0 +1,41 @@ +import fs from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) + +const TAURI_CONF = path.resolve(__dirname, '../src-tauri/tauri.conf.json') +const OUTPUT = path.resolve(__dirname, '../updater.json') + +const PLATFORM = 'windows-x86_64' +const BASE_URL = 'https://git.koptilnya.xyz/opti1337/chad/releases/download/latest' + +const tauriConfRaw = fs.readFileSync(TAURI_CONF, 'utf8') +const tauriConf = JSON.parse(tauriConfRaw) +const version = tauriConf.package.version + +const SIG_FILE = path.resolve( + __dirname, + `../src-tauri/target/release/bundle/nsis/chad_${version}_x64-setup.exe.sig`, +) + +const signature = fs.readFileSync(SIG_FILE, 'utf8').trim() + +const installerName = `chad_${version}_x64-setup.exe` + +const updater = { + pub_date: new Date().toISOString(), + version, + platforms: { + [PLATFORM]: { + url: `${BASE_URL}/${installerName}`, + signature, + }, + }, + notes: '', +} + +fs.writeFileSync(OUTPUT, JSON.stringify(updater, null, 2), 'utf8') + +console.log('updater.json generated') diff --git a/client/src-tauri/tauri.conf.json b/client/src-tauri/tauri.conf.json index 4efaa6a..569d9a4 100644 --- a/client/src-tauri/tauri.conf.json +++ b/client/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "chad", - "version": "0.2.5-rc.2", + "version": "0.2.6", "identifier": "xyz.koptilnya.chad", "build": { "frontendDist": "../.output/public", @@ -44,9 +44,9 @@ }, "plugins": { "updater": { - "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDI3NDM5Q0I4MDI5M0MyRjQKUldUMHdwTUN1SnhESjBoUFpuWkJxRzFqcWJxdTY4UkNvMmUzcHFnZnJtbSs3WmJoUmhxQ3R5bWYK", + "pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEU3MzkxMzM3RkQ3NTg4QUQKUldTdGlIWDlOeE01NStIak9VbmZTTm9HY2NyNUQrVXB5ZEdIN1BkK2lhYW9zWkNCQnZQSjRmelIK", "endpoints": [ - "https://git.koptilnya.xyz/opti1337/chad/releases/download/latest/latest.json" + "https://git.koptilnya.xyz/opti1337/chad/releases/download/latest/updater.json" ] } }