forge icon indicating copy to clipboard operation
forge copied to clipboard

github publisher unable to create release

Open nzhul opened this issue 3 years ago • 14 comments

Pre-flight checklist

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

Electron Forge version

6.0.5

Electron version

23.0.0

Operating system

Windows 10 Pro

Last known working Electron Forge version

No response

Expected behavior

Github release is created an Squirrel setup executable is attached as asset.

Actual behavior

I am using the following workflow file:

name: Make and Publish to Github

on:
  push:
    branches:
      - master

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  build_on_win:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@master
        with:
          node-version: 18
      - name: Install dependencies
        run: yarn install
      - name: Publish
        run: yarn run publish

I get the following error:

[STARTED] [publisher-github] Running the publish command
[DATA] Searching for target release: v1.0.1
[FAILED] Not Found
[FAILED] Not Found

An unhandled rejection has occurred inside Forge:
HttpError: Not Found
at D:\a\launcher\launcher\node_modules\@octokit\rest\node_modules\@octokit\request\dist-src\fetch-wrapper.js:68:27
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Job.doExecute (D:\a\launcher\launcher\node_modules\bottleneck\light.js:405:18)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

Here is the full log of my publish step:

yarn run v1.22.19
$ electron-forge publish
[STARTED] Checking your system
[STARTED] Checking git exists
[STARTED] Checking node version
[STARTED] Checking packageManager version
[TITLE] Found [email protected]
[SUCCESS] Found [email protected]
[TITLE] Found [email protected]
[SUCCESS] Found [email protected]
[TITLE] Found [email protected]
[SUCCESS] Found [email protected]
[SUCCESS] Checking your system
[STARTED] Loading configuration
[SUCCESS] Loading configuration
[STARTED] Resolving publish targets
[DATA] Publishing to the following targets: github
[SUCCESS] Resolving publish targets
[STARTED] Running make command
[STARTED] Loading configuration
[SUCCESS] Loading configuration
[STARTED] Resolving make targets
[DATA] Making for the following targets: squirrel
[SUCCESS] Resolving make targets
[STARTED] Running package command
[STARTED] Preparing to package application
[SUCCESS] Preparing to package application
[STARTED] Running packaging hooks
[STARTED] Running generateAssets hook
[SUCCESS] Running generateAssets hook
[STARTED] Running prePackage hook
[STARTED] [plugin-webpack] Preparing native dependencies
[TITLE] [plugin-webpack] Preparing native dependencies
[SUCCESS] [plugin-webpack] Preparing native dependencies
[STARTED] [plugin-webpack] Building webpack bundles
[SUCCESS] [plugin-webpack] Building webpack bundles
[SUCCESS] Running prePackage hook
[SUCCESS] Running packaging hooks
[STARTED] Packaging application
[DATA] Determining targets...
[STARTED] Packaging for x64 on win32
[STARTED] Copying files
[SUCCESS] Copying files
[STARTED] Preparing native dependencies
[TITLE] Preparing native dependencies
[SUCCESS] Preparing native dependencies
[STARTED] Finalizing package
[SUCCESS] Finalizing package
[SUCCESS] Packaging for x64 on win32
[SUCCESS] Packaging application
[STARTED] Running postPackage hook
[SUCCESS] Running postPackage hook
[SUCCESS] Running package command
[STARTED] Running preMake hook
[SUCCESS] Running preMake hook
[STARTED] Making distributables
[STARTED] Making a squirrel distributable for win32/x64
[SUCCESS] Making a squirrel distributable for win32/x64
[SUCCESS] Making distributables
[STARTED] Running postMake hook
[DATA] Artifacts available at: D:\a\launcher\launcher\out\make
[SUCCESS] Running postMake hook
[SUCCESS] Running make command
[STARTED] Publishing distributables
[STARTED] [publisher-github] Running the publish command
[DATA] Searching for target release: v1.0.1
[FAILED] Not Found
[FAILED] Not Found

An unhandled rejection has occurred inside Forge:
HttpError: Not Found
at D:\a\launcher\launcher\node_modules\@octokit\rest\node_modules\@octokit\request\dist-src\fetch-wrapper.js:68:2[7](https://github.com/nzhul/launcher/actions/runs/4806546800/jobs/8554196138#step:5:8)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Job.doExecute (D:\a\launcher\launcher\node_modules\bottleneck\light.js:405:1[8](https://github.com/nzhul/launcher/actions/runs/4806546800/jobs/8554196138#step:5:9))
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

Steps to reproduce

n/a

Additional information

Link to my workflow file: https://github.com/nzhul/launcher/blob/master/.github/workflows/main.yml Link to my job: https://github.com/nzhul/launcher/actions/runs/4806546800/jobs/8554196138

nzhul avatar Apr 26 '23 08:04 nzhul

I checked in the code of the github publisher and it looks like there is logic that creates the release if it is missing. I wonder why this step is failing. Here is the line that do this > https://github.com/electron/forge/blob/main/packages/publisher/github/src/PublisherGithub.ts#L69

Is it possible that my GITHUB_TOKEN doesn't have permissions to create release ?

nzhul avatar Apr 26 '23 09:04 nzhul

Some update from me, one day later. Since my first error was:

[DATA] Searching for target release: v1.0.8
[FAILED] Not Found
[FAILED] Not Found

I decided to edit my workflow to first create the release. Unfortunately even after this change it fails with the same error. Even though the Release is existing:

Release: https://github.com/nzhul/launcher/releases/tag/v1.0.8 Job: https://github.com/nzhul/launcher/actions/runs/4823565146/jobs/8592221543#step:5:73

Release: image

Job: image

I will take a rest now, and tomorrow will probably try to just create the release and upload the artifacts without using your publisher.

I really hope you fix this some day.

nzhul avatar Apr 27 '23 19:04 nzhul

Final comment from me. I decided to implement the release creation and asset upload by myself. Here is my workflow file if someone is interested, and have the same problem:


name: Make and Publish to Github

on:
  push:
    branches:
      - master

permissions:
  contents: write

env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  check-version:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@master
        with:
          node-version: 18
          cache: 'yarn'


      # this check works by first searching for '<WHATEVER> 1.2.3' in the commit message
      # if it cannot find it in the commit message, it start diff check search
      # diff check is slower and it is recommended to use the first option
      - name: Check if version has been updated
        id: check
        uses: EndBug/version-check@v2

      - name: Version changed
        if: steps.check.outputs.changed == 'true'
        run: 'echo "Version change found in commit ${{ steps.check.outputs.commit }}! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"'

      - name: Version unchanged
        if: steps.check.outputs.changed == 'false'
        run: 'echo "No version change :/"'

    outputs:
      SHOULD_PUBLISH: ${{ steps.check.outputs.changed }}
      VERSION: ${{ steps.check.outputs.version }}

  build-on-win:
    needs: check-version
    if: needs.check-version.outputs.SHOULD_PUBLISH == 'true'
    runs-on: windows-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@master
        with:
          node-version: 18
          cache: 'yarn'
      - name: Install dependencies
        run: yarn install --network-timeout 600000
      - name: Make
        run: yarn make
      - uses: actions/upload-artifact@v2
        with:
          name: ancient-warriors-launcher-v${{needs.check-version.outputs.VERSION}}
          path: out/make/squirrel.windows/x64/Ancient Warriors Launcher-${{needs.check-version.outputs.VERSION}} Setup.exe

    outputs:
      VERSION: ${{ needs.check-version.outputs.VERSION }}

  create-release:
    needs: build-on-win
    name: create-release 🚀
    runs-on: ubuntu-latest
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Download Artifact
        uses: actions/download-artifact@v2
        with:
          name: ancient-warriors-launcher-v${{needs.build-on-win.outputs.VERSION}}
          path: build-artifact

      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        with:
          tag_name: v${{needs.build-on-win.outputs.VERSION}}
          release_name: Release v${{needs.build-on-win.outputs.VERSION}}
          body: |
            Changes in this release:
            - Add new feature (todo: resolve dynamically)
            - Bug fixes
          draft: false
          prerelease: false

      - name: Upload Asset
        id: upload-release-asset
        uses: actions/upload-release-asset@v1
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }}
          asset_path: build-artifact/Ancient Warriors Launcher-${{needs.build-on-win.outputs.VERSION}} Setup.exe
          asset_name: Ancient Warriors Launcher-${{needs.build-on-win.outputs.VERSION}} Setup.exe
          asset_content_type: application/vnd.microsoft.portable-executable

nzhul avatar Apr 27 '23 22:04 nzhul

Sooo yeah ... It turned out it was me :D Basically I am using electron-forge and there is this publishers section in forge.config.ts where you need to set the repository owner and name. For some reason I had put wrong repository name in there. And this was causing the NotFound error.

  publishers: [
    {
      name: '@electron-forge/publisher-github',
      config: {
        repository: {
          owner: '<Owner>',
          name: '<RepositoryName>',
        },
        draft: true,
      },
    },
  ],

Yeah I know ... I am stupid. Sorry for the spam. Feel free to delete/close the issue. Or maybe you can leave it in case someone do the same mistake as mee.

nzhul avatar Apr 29 '23 18:04 nzhul

Glad you figured it out @nzhul !

erickzhao avatar May 01 '23 21:05 erickzhao

@nzhul Thank you for not deleting this, since I ran into the exact same problem!

VictorNYSPI avatar Jan 04 '24 20:01 VictorNYSPI

I stumbled upon this issue, but my forge config was already done correctly

Gilgaustus avatar Jan 09 '24 19:01 Gilgaustus

Is your owner value set as your Github username and your name value set as the name of the repository ?

That was the mistake I made by being careless and not carefully making sure that these values were correct.

VictorNYSPI avatar Jan 09 '24 19:01 VictorNYSPI

@VictorNYSPI yes, the owner of the repo is the one set there and the name is the repository

Gilgaustus avatar Jan 10 '24 16:01 Gilgaustus

I have this happen randomly. But everything is working fine. If i re-run my github action then it usually works the second time. Any ideas?

GitMurf avatar Apr 25 '24 22:04 GitMurf

Thank you for leaving it up.

wslabn avatar Aug 04 '24 21:08 wslabn

Yeeww, thank you. Also had overlooked this bit and your post was the top hit when searching, very helpful!

windsywinds avatar Oct 16 '24 14:10 windsywinds

Getting the same error, but I have my name set, but maybe I'm unclear how the name format should be?

which one is correct?

[email protected]:MyOrg/my-repo.git MyOrg/my-repo.git MyOrg/my-repo my-repo

something else?

LMS007 avatar Nov 18 '24 22:11 LMS007

^^ awe, if you are using an org, then its

      owner: 'OrgName,
      name: 'repo-name'

don't use your personal github username in that case.

LMS007 avatar Nov 19 '24 01:11 LMS007