Skip to content

Rename publish command to avoid naming conflict with yarn publish #2820

Open

Description

@guizmaii

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

6.0.0-beta.63

Electron version

v18.1.0

Operating system

All

Last known working Electron Forge version

No response

Expected behavior

See "Actual behavior" description

Actual behavior

In my forge.config.js config, following this doc https://js.electronforge.io/publisher/github/interfaces/publishergithubconfig#authtoken, I have:

  publishers: [
    {
      name: '@electron-forge/publisher-github',
      config: {
        repository: {
          owner: 'myaccount',
          name: 'myrepo',
        },
        authToken: process.env.GITHUB_TOKEN,
        draft: process.env.PUBLISHER_GITHUB_DRAFT,
        prerelease: process.env.PUBLISHER_GITHUB_PRERELEASE,
      },
    },
  ],

When I yarn publish in my CI, I have the error:

> Run yarn publish
yarn publish v1.22.1
[1/4] Bumping version...
info Current version: 0.0.1
[2/4] Logging in...
error No token found and can't prompt for login when running with --non-interactive.
info Visit https://yarnpkg.com/en/docs/cli/publish for documentation about this command.
Error: Process completed with exit code 1.

To fix, this issue I had to remove the authToken from the forge.config.js config:

  publishers: [
    {
      name: '@electron-forge/publisher-github',
      config: {
        repository: {
          owner: 'myaccount',
          name: 'myrepo',
        },
        draft: process.env.PUBLISHER_GITHUB_DRAFT,
        prerelease: process.env.PUBLISHER_GITHUB_PRERELEASE,
      },
    },
  ],

and change the command run in CI with:

yarn electron-forge publish --auth-token=${GITHUB_TOKEN}

which finally works as expected:

...
Making for the following targets: deb
- Making for target: deb - On platform: linux - For arch: x64
✔ Making for target: deb - On platform: linux - For arch: x64
- Resolving publish target: @electron-forge/publisher-github
✔ Resolving publish target: @electron-forge/publisher-github
- Searching for target release: 0.0.1
✔ Searching for target release: 0.0.1
- Uploading Artifacts 0/1 to v0.0.1
✔ Uploading Artifacts 1/1 to v0.0.1
Done in 74.63s.

Steps to reproduce

See "Actual behavior" description

Additional information

No response

Activity

  1. Mubramaj commented on Oct 2, 2023

    @Mubramaj

    I think what is happening here is that the Github action is confused and the yarn publish is trying actually to do the publishing of an npm package, that needs a specific token ( not the GITHUB_TOKEN of electron forge )

    What I did in my repo is that I replaced the package.json script publish by publish-app :

      "scripts": {
        "start": "electron-forge start",
        "package": "electron-forge package",
        "make": "electron-forge make",
        "publish-app": "electron-forge publish",
        "lint": "eslint --ext .ts,.tsx ."
      },
    
    

    Of course also updated my github action to run yarn publish-app instead of yarn publish

  2. changed the title [-]publisher-github: Setting the `authToken` in the `forge.config.js` configuration doesn't work[/-] [+]Rename `publish` command to avoid naming conflict with `yarn publish`[/+] on Feb 1, 2025
  3. erickzhao commented on Feb 1, 2025

    @erickzhao
    Member

    Another solution would just be to run yarn run publish, but having this as the default command is confusing if you're used to running yarn scripts directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions