publisher-github: Inconsistent behavior between Linux/Windows and macOS when the package already exists in the release
- Dominant language
- TypeScript
- Stars
- 7.1k
- Forks
- 641
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 30
Description
### Pre-flight checklist
- [X] I have read the [contribution documentation](https://github.com/electron-userland/electron-forge/blob/master/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [code of conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) 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.0-beta.63
### Electron version
v18.1.0
### Operating system
macOS
### Last known working Electron Forge version
_No response_
### Expected behavior
Here's my `forge.config.js`:
```js
// See https://www.electronforge.io/configuration
//
// An interesting configuration example: https://github.com/electron/fiddle/blob/main/forge.config.js
//
const path = require('path');
const packageJson = require('./package.json');
const { version } = packageJson;
const iconDir = path.resolve(__dirname, 'assets', 'icons');
module.exports = {
packagerConfig: { // https://electron.github.io/electron-packager/main/interfaces/electronpackager.options.
// General packager configs
// Inspired by https://github.com/electron/fiddle/blob/main/forge.config.js
name: 'My App',
executableName: 'my-app',
asar: true,
appBundleId: 'com.my.app',
appCategoryType: 'public.app-category.developer-tools',
protocols: [
{
name: 'My App Launch Protocol',
schemes: ['my-app'],
},
],
win32metadata: {
CompanyName: 'MyCompany',
OriginalFilename: 'My App',
},
osxNotarize: { // https://www.npmjs.com/package/electron-notarize#method-notarizeopts-promisevoid
tool: "notarytool",
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_APP_SPECIFIC_PASSWORD,
teamId: "..."
},
// macOS code-signing configs. See https://www.electronjs.org/docs/latest/tutorial/code-signing#electron-forge
osxSign: { // https://www.npmjs.com/package/electron-osx-sign#opts
identity: "...",
'hardened-runtime': true,
entitlements: "./static/entitlements.plist",
'entitlements-inherit': './static/entitlements.plist',
keychain: "build.keychain"
},
},
makers: [
{
name: "@electron-forge/maker-squirrel",
config: (arch) => ({ // https://js.electronforge.io/maker/squirrel/interfaces/makersquirrelconfig
name: "my-app",
authors: "MyCompany",
exe: 'my-app.exe',
//iconUrl: path.resolve(iconDir, 'my-icon.png'),
noMsi: true,
setupExe: `my-app-${version}-win32-${arch}-setup.exe`,
//setupIcon: path.resolve(iconDir, 'my-icon.png'),
certificateFile: path.resolve(__dirname, 'static', 'mycertificate.pfx'),
certificatePassword: process.env.PFX_PASSWORD,
})
},
{
name: '@electron-forge/maker-dmg',
config: (arch) => ({ // https://js.electronforge.io/maker/dmg/interfaces/makerdmgconfig
background: './assets/icons/my-icon.png',
format: 'ULFO',
icon: './assets/icons/my-icon.png',
name: `My App ${arch}`,
overwrite: true
})
},
{
name: "@electron-forge/maker-deb",
config: { // https://js.electronforge.io/maker/deb/interfaces/makerdebconfigoptions
categories: ["Development"],
homepage: "https://www.mycompany.com/",
icon: "./assets/icons/my-icon.png",
maintainer: "MyCompany",
mimeType: ['x-scheme-handler/my-app'],
}
},
],
plugins: [
[
"@electron-forge/plugin-webpack",
{
mainConfig: "./webpack.main.config.js",
renderer: {
config: "./webpack.renderer.config.js",
entryPoints: [
{
html: "./src/index.html",
js: "./src/renderer.ts",
name: "main_window"
}
]
}
}
],
[
'@electron-forge/plugin-electronegativity', // https://www.electronforge.io/config/plugins/electronegativity
{
isSarif: true,
output: "out/electronegativity-result"
}
]
],
publishers: [
{
name: '@electron-forge/publisher-github',
config: {
repository: {
owner: 'myCompany',
name: 'my-repo',
},
draft: process.env.PUBLISHER_GITHUB_DRAFT,
prerelease: process.env.PUBLISHER_GITHUB_PRERELEASE,
},
},
],
}
```
Here's my Github Action job that is publishing the app in "draft" mode:
```yaml
jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
arch: [ x64 ]
include:
- os: macOS-latest
arch: arm64
...
- name: Publish
shell: bash
run: |
echo matrix.arch ${{ matrix.arch }}
... # Signing and notarizing if necessary
yarn electron-forge publish --arch=${{ matrix.arch }} --auth-token=${GITHUB_TOKEN}
env:
# See 'forge.config.js' Github publisher config
PUBLISHER_GITHUB_DRAFT: true
PUBLISHER_GITHUB_PRERELEASE: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
....
```
As you can see in my CI definition, I publish my app for `Linux x64`, `Windows x64`, `macOS x64` and `macOS arm64`
If I launch this job a first time with a version number that is not yet published, all the 4 apps will be correctly published.
My issue is that if I relaunch this job a second time with the same version number, then the Linux and Windows will be be published correctly while the 2 macOS versions will fail with the following error:
```bash
Making for the following targets: dmg
✔ Making for target: dmg - On platform: darwin - For arch: arm64
- 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 0/1 to v0.0.1
An unhandled error has occurred inside Forge:
Validation Failed: {"resource":"ReleaseAsset","code":"already_exists","field":"name"}
HttpError: Validation Failed: {"resource":"ReleaseAsset","code":"already_exists","field":"name"}
at /Users/runner/work/my-app/my-app/node_modules/@octokit/request/dist-src/fetch-wrapper.js:68:27
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Job.doExecute (/Users/runner/work/my-app/my-app/node_modules/bottleneck/light.js:405:18)
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
Error: Process completed with exit code 1.
```
Expected behavior: The macOS versions are published too, overriding the previously published versions
### Actual behavior
See "Expected behavior" part
### Steps to reproduce
See "Expected behavior" part
### Additional information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.