From 03edc197d3a94aacf89817ff29ef77caa4f06357 Mon Sep 17 00:00:00 2001 From: Anbraten Date: Mon, 25 Apr 2022 10:18:13 +0200 Subject: [PATCH] fix desktop app releasing (#2116) * fix app releasing * fix sed for macos * fix setting app version on all oses --- .../workflows/build-and-release-desktop.yml | 16 ++++++++++++---- desktop/electron/electron-builder.yml | 3 +-- desktop/electron/helpers/set-version.js | 18 ++++++++++++++++++ desktop/electron/package.json | 3 +-- 4 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 desktop/electron/helpers/set-version.js diff --git a/.github/workflows/build-and-release-desktop.yml b/.github/workflows/build-and-release-desktop.yml index cc0d4d48..99d4e4d8 100644 --- a/.github/workflows/build-and-release-desktop.yml +++ b/.github/workflows/build-and-release-desktop.yml @@ -60,6 +60,10 @@ jobs: run: yarn build working-directory: "desktop/local-app" + - name: "Set desktop app version" + run: node helpers/set-version.js + working-directory: "desktop/electron" + - name: "Install dependencies" run: yarn install --froze-lockfile working-directory: "desktop/electron" @@ -68,15 +72,19 @@ jobs: run: yarn build working-directory: "desktop/electron" - - name: "Build app" - run: yarn bundle --publish never + - name: "Install electron tools" + run: yarn electron-builder install-app-deps + working-directory: "desktop/electron" + + - name: "Build app for testing" + run: yarn electron-builder --publish never env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} working-directory: "desktop/electron" if: ${{ github.event_name != 'release' }} - - name: "Build & publish App" - run: yarn release + - name: "Build & release app" + run: yarn electron-builder --publish always env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} working-directory: "desktop/electron" diff --git a/desktop/electron/electron-builder.yml b/desktop/electron/electron-builder.yml index faca3d73..d9fd4eb1 100644 --- a/desktop/electron/electron-builder.yml +++ b/desktop/electron/electron-builder.yml @@ -28,5 +28,4 @@ publish: provider: github owner: thecodingmachine repo: workadventure - vPrefixedTagName: false - releaseType: draft + releaseType: release diff --git a/desktop/electron/helpers/set-version.js b/desktop/electron/helpers/set-version.js new file mode 100644 index 00000000..52c5e8c8 --- /dev/null +++ b/desktop/electron/helpers/set-version.js @@ -0,0 +1,18 @@ +const path = require('path'); +const fs = require('fs'); + +let version = '0.0.0'; + +if (process.env.GITHUB_REF.startsWith('refs/tags/v')) { + version = process.env.GITHUB_REF.replace('refs/tags/v', ''); +} + +console.log('Version:', version); + +const packageJsonPath = path.resolve(__dirname, '..', 'package.json'); + +let data = fs.readFileSync(packageJsonPath, 'utf8'); + +data = data.replace('managedbyci', version); + +fs.writeFileSync(packageJsonPath, data); diff --git a/desktop/electron/package.json b/desktop/electron/package.json index 26a3929c..f4fa0686 100644 --- a/desktop/electron/package.json +++ b/desktop/electron/package.json @@ -1,6 +1,6 @@ { "name": "workadventure-desktop", - "version": "1.0.0", + "version": "managedbyci", "description": "Desktop application for WorkAdventure", "author": "thecodingmachine", "main": "dist/main.js", @@ -11,7 +11,6 @@ "dev": "yarn build --watch --onSuccess 'yarn electron dist/main.js'", "dev:local-app": "cd ../local-app && yarn && yarn dev", "bundle": "yarn build:local-app && yarn build && electron-builder install-app-deps && electron-builder", - "release": "yarn bundle", "typecheck": "tsc --noEmit", "test": "exit 0", "lint": "yarn eslint src/ . --ext .ts",