Electron-builder: GitHub Personal Access Token is not set, neither programmatically, nor using env "GH_TOKEN"

Created on 17 Jun 2017  路  11Comments  路  Source: electron-userland/electron-builder


  • Version: 19.4.2 and 19.5.0

  • Target: macOS and Win
[============================================>] 100.0% of 43.04 MB (21.52 MB/s)
Building NSIS installer
  Packaging NSIS installer for arch x64
  Packaging NSIS installer for arch ia32
Error: GitHub Personal Access Token is not set, neither programmatically, nor using env "GH_TOKEN"
    at new GitHubPublisher (C:\projects\closeio-electron\node_modules\electron-publish\src\gitHubPublisher.ts:52:15)

I am not publishing anything, why this is requesting the GH_TOKEN? I am running:

cross-env NODE_ENV='production' build -w  --config=config/production/electron-builder.yml --x64 --ia32
directories:
  buildResources: build/production
  output: dist/production

appId: org.myapp.electron

mac:
  category: public.app-category.productivity
  artifactName: myapp-${version}-${env.NODE_ENV}-mac.${ext}
  target:
    - zip

files:
  - app/**/*
  - node_modules/**/*
  - package.json
  - "!env.json"

extraResources:
  - 
    from: config/production/env.json
    to: env.json

win:
  target: "nsis"

nsis:
  artifactName: myapp-${version}-${env.NODE_ENV}-win.${ext}
  installerIcon: build/production/icon.ico
  runAfterFinish: false
  deleteAppDataOnUninstall: true
  allowToChangeInstallationDirectory: true
  oneClick: false

dmg: null
linux: null

$ cross-env NODE_ENV='dev' build -m --config=config/dev/electron-builder.yml 
CI detected, so artifacts will be published if draft release exists

How to ignore "CI detected, so artifacts will be published if draft release exists" and not publish?

Most helpful comment

@pujiaxun: go to GitHub settings, then developer settings and then personal access token.

All 11 comments

@develar First I thought that the problem was with the branch name, but I am using this pattern: bump-to-3.0.3-and-downgrade-electron-to-1.69.11

@develar Fixed by passing --publish=never. But I would like to know if PUBLISH is default even if I don't set GH_TOKEN variable on ci's?

Once you answer, feel free to close.

Please set env DEBUG=electron-builder and attach log of the terminal output.

@develar Like I said, I was able to fix passing publish=never. But looks like the builder is trying to publish everytime you are on master (or a tag branch name), by default.

DEBUG log will help to understand why.

I am having the same problem. Here's the log

Building AppImage for arch x64
鈿狅笍  Application category is not set for Linux (linux.category).
Please see https://electron.build/configuration/configuration#LinuxBuildOptions-category
Downloading appimage-9.0.2, please wait
Error: GitHub Personal Access Token is not set, neither programmatically, nor using env "GH_TOKEN"
    at new GitHubPublisher (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-publish/src/gitHubPublisher.ts:52:15)
    at createPublisher (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/src/publish/PublishManager.ts:235:14)
    at PublishManager.getOrCreatePublisher (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/src/publish/PublishManager.ts:160:19)
    at PublishManager.scheduleUpload (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/src/publish/PublishManager.ts:111:28)
    at EventEmitter.PublishManager.packager.artifactCreated.event (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/src/publish/PublishManager.ts:101:14)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:191:7)
    at Packager.dispatchArtifactCreated (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/src/packager.ts:171:23)
    at /home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/src/publish/updateUnfoBuilder.ts:189:14
    at Generator.next (<anonymous>)
From previous event:
    at default.map (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/out/publish/updateUnfoBuilder.js:161:30)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)
From previous event:
    at /home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/src/publish/updateUnfoBuilder.ts:185:25
    at Generator.next (<anonymous>)
From previous event:
    at writeUpdateInfoFiles (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/out/publish/updateUnfoBuilder.js:167:22)
    at /home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/src/publish/PublishManager.ts:180:11
From previous event:
    at PublishManager.awaitTasks (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/out/publish/PublishManager.js:436:11)
    at /home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/src/builder.ts:283:29
    at /home/travis/build/slightlytrue/pw-chat/node_modules/builder-util/src/promise.ts:26:11
    at Generator.next (<anonymous>)
From previous event:
    at executeFinally (/home/travis/build/slightlytrue/pw-chat/node_modules/builder-util/out/promise.js:37:21)
    at /home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/src/builder.ts:277:10
    at Generator.next (<anonymous>)
    at build (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/out/builder.js:63:21)
    at then (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/src/cli/cli.ts:49:4)
From previous event:
    at build (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/out/builder.js:63:21)
    at then (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/out/cli/cli.js:127:128)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)
From previous event:
    at Object.args [as handler] (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/out/cli/cli.js:127:117)
    at Object.runCommand (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/node_modules/yargs/lib/command.js:228:22)
    at Object.parseArgs [as _parseArgs] (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/node_modules/yargs/yargs.js:1041:24)
    at Object.get [as argv] (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/node_modules/yargs/yargs.js:957:21)
    at Object.<anonymous> (/home/travis/build/slightlytrue/pw-chat/node_modules/electron-builder/out/cli/cli.js:123:441)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)
    at bootstrap_node.js:542:3
error Command failed with exit code 255.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The command "yarn run build" exited with 1.
cache.2
store build cache
0.01s
45.00schanges detected, packing new archive
.
.
.
.
.
.
.
.
uploading archive
Done. Your build exited with 1.

and contents in my .travis.yml file:

osx_image: xcode8.3
sudo: required
dist: trusty
language: c
matrix:
  include:
  - os: osx
  - os: linux
    env: CC=clang CXX=clang++ npm_config_clang=1
    compiler: clang
cache:
  directories:
  - node_modules
  - "$HOME/.electron"
  - "$HOME/.cache"
addons:
  apt:
    packages:
    - libgnome-keyring-dev
    - icnsutils
before_install:
- mkdir -p /tmp/git-lfs && curl -L https://github.com/github/git-lfs/releases/download/v1.2.1/git-lfs-$([
  "$TRAVIS_OS_NAME" == "linux" ] && echo "linux" || echo "darwin")-amd64-1.2.1.tar.gz
  | tar -xz -C /tmp/git-lfs --strip-components 1 && /tmp/git-lfs/git-lfs pull
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install --no-install-recommends -y icnsutils graphicsmagick xz-utils; fi
install:
- nvm install 8
- curl -o- -L https://yarnpkg.com/install.sh | bash
- source ~/.bashrc
- npm install -g xvfb-maybe
- yarn
script:
- yarn run build
branches:
  only:
  - master

@slightlytrue It says that you don't add a category, it's a different issue. Check the log message.

@djalmaaraujo yeah, I have added the category (was warning only) and set the environment variable GH_TOKEN and now it works fine.

@slightlytrue I came across the same. And I wonder how to get or generate the GH_TOKEN please?

@pujiaxun: go to GitHub settings, then developer settings and then personal access token.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ccorcos picture ccorcos  路  3Comments

iklemm picture iklemm  路  3Comments

antonycourtney picture antonycourtney  路  3Comments

alexstrat picture alexstrat  路  3Comments

mstralka picture mstralka  路  3Comments