samuelmeuli / action-electron-builder

:electron: GitHub Action for building and releasing Electron apps
MIT License
670 stars 206 forks source link

Snap file fails to publish #71

Closed stamoun closed 3 years ago

stamoun commented 3 years ago

I'm trying to get automated release update to publish binaries and so far Linux is failing (Mac and Windows seem ok, albeit unsigned binaries).

The builder fails with the following (full log here)

...
   • creating GitHub release  reason=release doesn't exist tag=v1.6.4 version=1.6.4
  • publishing      publisher=Snap Store
  • uploading       file=lofi_1.6.4_amd64.snap provider=snapStore
  ⨯ snapcraft is not installed, please: sudo snap install snapcraft --classic  
  ⨯ 403 Forbidden
{
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest/reference/repos#create-a-release"
}
Headers: {
  "server": "GitHub.com",
  "date": "Tue, 14 Sep 2021 02:20:19 GMT",
  "content-type": "application/json; charset=utf-8",
  "content-length": "136",
  "x-github-media-type": "github.v3; format=json",
  "x-ratelimit-limit": "1000",
  "x-ratelimit-remaining": "998",
  "x-ratelimit-reset": "1631589619",
  "x-ratelimit-used": "2",
  "x-ratelimit-resource": "core",
  "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset",
  "access-control-allow-origin": "*",
  "strict-transport-security": "max-age=31536000; includeSubdomains; preload",
  "x-frame-options": "deny",
  "x-content-type-options": "nosniff",
  "x-xss-protection": "0",
  "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
  "content-security-policy": "default-src 'none'",
  "vary": "Accept-Encoding, Accept, X-Requested-With",
  "x-github-request-id": "07C1:4641:1D24CF3:33CA1CF:614006E3",
  "connection": "close"
}  failedTask=build stackTrace=HttpError: 403 Forbidden
{
  "message": "Resource not accessible by integration",
  "documentation_url": "https://docs.github.com/rest/reference/repos#create-a-release"
}
Headers: {
  "server": "GitHub.com",
  "date": "Tue, 14 Sep 2021 02:20:19 GMT",
  "content-type": "application/json; charset=utf-8",
  "content-length": "136",
  "x-github-media-type": "github.v3; format=json",
  "x-ratelimit-limit": "1000",
  "x-ratelimit-remaining": "998",
  "x-ratelimit-reset": "1631589619",
  "x-ratelimit-used": "2",
  "x-ratelimit-resource": "core",
  "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset",
  "access-control-allow-origin": "*",
  "strict-transport-security": "max-age=31536000; includeSubdomains; preload",
  "x-frame-options": "deny",
  "x-content-type-options": "nosniff",
  "x-xss-protection": "0",
  "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
  "content-security-policy": "default-src 'none'",
  "vary": "Accept-Encoding, Accept, X-Requested-With",
  "x-github-request-id": "07C1:4641:1D24CF3:33CA1CF:614006E3",
  "connection": "close"
}
    at createHttpError (/home/runner/work/lofi/lofi/node_modules/builder-util-runtime/src/httpExecutor.ts:30:10)
    at IncomingMessage.<anonymous> (/home/runner/work/lofi/lofi/node_modules/builder-util-runtime/src/httpExecutor.ts:179:18)
    at IncomingMessage.emit (events.js:412:35)
    at endReadableNT (internal/streams/readable.js:1317:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
/home/runner/work/_actions/samuelmeuli/action-electron-builder/v1.6.0/index.js:144
                throw err;
                ^

Error: Command failed: yarn run electron-builder --linux --publish always 
    at checkExecSyncError (child_process.js:621:11)
    at execSync (child_process.js:657:15)
    at run (/home/runner/work/_actions/samuelmeuli/action-electron-builder/v1.6.0/index.js:21:27)
    at runAction (/home/runner/work/_actions/samuelmeuli/action-electron-builder/v1.6.0/index.js:132:4)
    at Object.<anonymous> (/home/runner/work/_actions/samuelmeuli/action-electron-builder/v1.6.0/index.js:150:1)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
  status: 1,
  signal: null,
  output: [ null, null, null ],
  pid: 2110,
  stdout: null,
  stderr: null
}

Here's my workflow action file:

name: release
on: 
  push:
    branches:
       # TODO change to master once this works...
       - gh-actions
jobs:
  release:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [macos-latest, ubuntu-latest, windows-latest]

    steps:
      - name: Check out Git repository
        uses: actions/checkout@v2

      - name: Install Node.js, NPM and Yarn
        uses: actions/setup-node@v2
        with:
          node-version: 14

      - run: yarn install
      - run: yarn build
      - run: yarn production

      - name: Electron Builder Action
        uses: samuelmeuli/action-electron-builder@v1.6.0
        with:
          github_token: ${{ secrets.github_token }}
          release: true # to force every time for testing purposes

From what I can gather from the log, the snap file is created but there is an issue uploading it to GitHub releases?

stamoun commented 3 years ago

I removed a few things that were probably causing this (the publish part of the build, the args in the yaml). I'll be using the tag to trigger a build and create a draft release. I think I was overthinking the process :)

stamoun commented 3 years ago

Actually, it still fails miserably, I updated the original post with the latest log and release.yml (package.json no longer contains a publish section).

Am I only missing the secrets.snapcraft_token? Do I need to have that? Can't I just build a .snap without having to log into a 3rd party?

justin-hackin commented 3 years ago

@stamoun I ran into this issue too, I think we need to follow the instructions here https://github.com/samuelmeuli/action-electron-builder#snapcraft

stamoun commented 3 years ago

I bypassed the snap store by using args: "-c.snap.publish=github -p always" in the workflow file as well as the following in the build element of package.json:

 "build": {
    ...
    "publish": [
      {
        "provider": "github",
        "releaseType": "draft"
      }
    ]
  ...

With these two modifications, I was able to publish the snap without hitting the snap store so this is no longer an issue for me.