Closed Piyush-Use-Personal closed 3 years ago
I recently experienced this and it was due to not bring authenticated with snap. Once I added
"Linux": { "target": "AppImage"}
It prevented snapcraft from being created and removed the issues.
If this doesn't help at the very bottom of your action change the release value to true instead of the check for a tag. If you want to only build on tags change the on: method to activated on main that has tags
@scope2229 Can you give some reference in the package.json file or if you could edit the same package.json? I am kind of stuck with every trial and error
Now I'm getting this error
snapcraft is not installed, please: sudo snap install snapcraft --classic
Added that line in package.json
"Linux": {
"target": "AppImage"
}
I took a deeper look at your package.json file looks like your "build" is setup with some errors.
"build": {
"productName": "some product",
"extends": null,
"appId": "com.appId",
"directories": {
"buildResources": "assets"
}
},
"publish": [
{
"provider": "github",
"owner": "owner-name",
"repo": "repo-link"
}
],
A basic Electron builder configuration would look something like this.
"build": {
"appId": "io.companyname.appname",
"productName": "appname",
"files": [
"dist/**/*.{js,css,html,ttf}"
],
"directories": {
"buildResources": "./"
},
"mac": {
"category": "public.app-category.developer-tools",
"icon": "icons/icon.icns",
"artifactName": "${productName}-${version}-${os}-${arch}.${ext}",
"hardenedRuntime": true,
"entitlementsInherit": "build/entitlements.mac.inherit-plist"
},
"linux": {
"target": "AppImage",
"artifactName": "${productName}-${version}-${os}-${arch}.${ext}",
"icon": "icons/icon.png",
"category": "Development"
},
"win": {
"target": "nsis",
"artifactName": "${productName}-${version}-${os}-${arch}.${ext}",
"icon": "icons/icon.png"
},
"publish": {
"provider": "github",
"repo": "reponame",
"owner": "ownername",
"releaseType": "release"
},
"afterSign": "./build/afterSignHook.js"
},
Your publish needs to be inside "build", along with "mac", "win", "linux" all lower case. Publish you only really need an array if your going to publish to multiple repo's or locations. Example Github and S3. If you need the configuration options for each you can get them from the Electron builder docs
Also to answer your other questions
name: Build/release
on:
push:
branches:
- main
env:
CI: false
jobs:
release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# os: [macos-latest, ubuntu-latest, windows-latest]
os: [ubuntu-latest]
steps:
- name: Check out Git repository
uses: actions/checkout@v1
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 14
- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
with:
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.github_token }}
# If the commit is tagged with a version (e.g. "v1.0.0"),
# release the app after building
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
I would have this run only when i push a tag. For testing you would be better off building locally on your machine without using a github action.
on:
push:
tags:
# Build on every tag in the form v1.2.3-something.4
- 'v*'
macos-latest
should be macOs-latest
github_token: ${{ secrets.github_token }}
make sure to change this to a name your using and store the value in settings/secrets, either i did something wrong or it just wouldn't automatically get the token, also if you release to a public repo form a private you'll need to set this anyway.
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
this doesn't work you'll need to update it to the correct function or just set to true. (setting to true is the easiest option as this will only run on a tag being pushed).
@scope2229 I'm using exact same conf as your with addition to
"extends": null,
"files": [
"dist/**/*",
"package.json"
],
and Now it is giving me this error
Error: Application entry file "build/main.js" in the "<path>/dist/mac/<app-name>/Contents/Resources/app.asar" does not exist.
The issue here is actually with the github action file. By default it will run the script electron-builder
this does not mean it will by default create the release if it doesn't exist. to do this you have to include the args: "-p always"
which will then make sure a new release is created even if no draft release exists
Here is my currently working example
# This is a basic workflow to help you get started with Actions
name: Build/release
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches:
- master
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 14
- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
with:
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.github_token }}
use_vue_cli: true
args: "-p always"
# If the commit is tagged with a version (e.g. "v1.0.0"),
# release the app after building
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
@hcmlopes Still getting same error
The other issues got fixed, I just need to remove the files array and it is working as fine. Thanks a lot @scope2229 and @hcmlopes
But now it is failing for GITHUB_TOKEN. Even after using the separate variable for this. Any idea how to fix that?
Don't call GitHub tokens GitHub have it like GH_TOKEN. GitHub prevents secrets starting with GitHub. To expand on @hcmlopes he's correct although missed the fact the release is described inside the build configuration in your package.json. so pick one not both.
Don't call GitHub tokens GitHub have it like GH_TOKEN. GitHub prevents secrets starting with GitHub. To expand on @hcmlopes he's correct although missed the fact the release is described inside the build configuration in your package.json. so pick one not both.
Are you saying I need to remove the public
object from package.json ?
On the other note, I have updated the variable to OWN_REPO_TOKEN
but still gives the same error
Edit: It was a typo for me
Guys @hcmlopes @scope2229 Thanks for your support and I'm closing this issue now. The only additional thing I have to do is remove the files object from package.json.
So it could be
github_token: ${{ secrets.GH_TOKEN }}
Then in your GitHub secrets name it GH_TOKEN
@scope2229
release: ${{ startsWith(github.ref, 'refs/tags/v') }} this doesn't work you'll need to update it to the correct function or just set to true. (setting to true is the easiest option as this will only run on a tag being pushed).
How do we figure out what the "correct function" is and how to call it?
You would need to check GitHub docs and find the ref object for tags. But honestly I feel it's better to only run the action if a tag is created and pushed.
Then you can simply use release: true for the action to release and false for a draft.
HELP WANTED!
Hey thanks for reaching to this issue
I am building an electron app that uses ReactJS, sqlite3, and sequelizer as the main area.
I have been new in the GitHub action and I tried making an action that will trigger on 2 occasions for my electron app
testing
branchI wanted to generate artifacts for both of the occasions but something is not adding up
I have tried everything which the
action-electron-builder
actions say but it keeps on saying *release doesn't exist and not created because "publish" is not "always" and build is not on tag v.*.*** without any errorThe repo is private and I cannot share much project level info tho but attaching an action result for ref
This is my GitHub workflow file
And this is my package.json
Please let me know in case I'm doing some horrible mistakes