diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..fe8056b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,60 @@ +stages: + - Build + - Upload + - Release + +build: + stage: Build + image: electronuserland/builder:wine + before_script: + - yarn + script: + - export VERSION=$(node -e "console.log(require('./package.json').version)") + - echo "VERSION=$VERSION" >> variables.env + - export APPNAME=$(node -e "console.log(require('./package.json').productName)") + - echo "APPNAME=$APPNAME" >> variables.env + - yarn build + artifacts: + reports: + dotenv: variables.env + name: $CI_COMMIT_REF_SLUG + paths: + - $CI_PROJECT_DIR/dist/*.* + when: on_success + only: + - main + +variables: + WIN_BINARY: '${APPNAME}-${VERSION}.exe' + PACKAGE_REGISTRY_URL: '${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${APPNAME}/${VERSION}' + +upload: + stage: Upload + needs: + - job: build + artifacts: true + rules: + - if: $CI_COMMIT_TAG + when: never # Do not run this job when a tag is created manually + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when when commits are pushed to the default branch + script: + - 'curl --header "JOB-TOKEN: $CI_DEPLOY_PASSWORD" --upload-file "./dist/${WIN_BINARY}" "${PACKAGE_REGISTRY_URL}/${WIN_BINARY}"' + +auto-release-master: + image: registry.gitlab.com/gitlab-org/release-cli + needs: + - job: build + artifacts: true + - job: upload + artifacts: true + stage: Release + rules: + - if: $CI_COMMIT_TAG + when: never # Do not run this job when a tag is created manually + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when when commits are pushed to the default branch + script: + - echo "Release $VERSION" + - | + release-cli create --name "Release $VERSION" --tag-name v$VERSION \ + --description 'Created using the release-cli. $CI_COMMIT_TITLE' --ref $CI_COMMIT_SHA \ + --assets-link "{\"name\":\"${APPNAME}\",\"url\":\"${PACKAGE_REGISTRY_URL}/${WIN_BINARY}\"}" diff --git a/electron.builder.yml b/electron.builder.yml new file mode 100644 index 0000000..2590695 --- /dev/null +++ b/electron.builder.yml @@ -0,0 +1,51 @@ +electronVersion: 9.0.0 +compression: normal +npmRebuild: false +# TODO: enable this in the future once we sign all the linux builds. +#forceCodeSigning: true +directories: + output: dist + buildResources: build + app: . + +mac: + category: Reference + icon: ./icons/icon.icns + target: + - target: dmg + - target: zip + + # steps for notarizing the MacOS builds: + # https://kilianvalkhof.com/2019/electron/notarizing-your-electron-application/ + + hardenedRuntime: true + gatekeeperAssess: false + entitlements: build/macos/entitlements.mac.plist + entitlementsInherit: build/macos/entitlements.mac.plist + +dmg: + # The inner app inside the .dmg is signed and there is some broken logic + # which requires that the DMG itself is not signed. + sign: false + + +nsis: + artifactName: ${name}-${version}-${arch}.${ext} + +appx: + artifactName: ${name}-${version}-${arch}.${ext} + applicationId: polar + identityName: 25130KevinBurton.PolarBookshelf + publisher: CN=D3591277-F57D-4C75-B342-D158E6C4AAF5 + publisherDisplayName: Kevin Burton + + +# https://www.electron.build/configuration/publish +# https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ +publish: + provider: github + publishAutoUpdate: true + +asar: true +afterPack: "./electron-builder-afterpack.js" +afterSign: "./build/macos/notarize.js" diff --git a/package.json b/package.json index 5a395f7..b6bdecf 100644 --- a/package.json +++ b/package.json @@ -7,10 +7,41 @@ "author": { "name": "Enrique Hernandez" }, - "main": "background.js", + "main": "./src/background.ts", "scripts": { "dev": "vue-cli-service electron:serve", - "build": "vue-cli-service electron:build" + "serve": "vue-cli-service serve", + "build": "electron-builder --win", + "test:unit": "vue-cli-service test:unit", + "lint": "vue-cli-service lint", + "electron:build": "vue-cli-service electron:build", + "electron:serve": "vue-cli-service electron:serve", + "postinstall": "electron-builder install-app-deps", + "postuninstal": "electron-builder install-app-deps", + "dist": "electron-builder --publish always" + }, + "repository": { + "type": "git", + "url": "https://gitlab.com/crimata/electron-app.git", + "release": "latest" + }, + "build": { + "artifactName": "${productName}-${version}.${ext}", + "publish": { + "provider": "generic", + "url": "https://gitlab.com/api/v4/projects/25637892/jobs/artifacts/master/raw/dist?job=build" + }, + "win": { + "target": [ + "nsis" + ], + "verifyUpdateCodeSignature": false + }, + "linux": { + "target": [ + "AppImage" + ] + } }, "dependencies": { "@google-cloud/speech": "^4.2.0", @@ -51,6 +82,7 @@ "@wasm-tool/wasm-pack-plugin": "^1.3.1", "electron": "^9.0.0", "electron-devtools-installer": "^3.1.0", + "electron-log": "^4.3.4", "eslint": "^6.7.2", "eslint-plugin-vue": "^7.0.0-0", "lint-staged": "^9.5.0", diff --git a/src/App.vue b/src/App.vue index a8247ea..320b62f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -6,19 +6,19 @@ -