electron-builder icon indicating copy to clipboard operation
electron-builder copied to clipboard

afterAllArtifactBuild script fires before latest.yml is created

Open cameronsutter opened this issue 5 years ago • 12 comments

  • Version: 21.0.1
  • Target: mac: dmg, zip; win: nsis

In the afterAllArtifactBuild script, latest.yml (and latest-mac.yml) are not created yet or are not saved to the output directory yet.

mac CI logs output from afterAllArtifactBuild: mac_output

windows CI logs output from afterAllArtifactBuild: windows_output

The arrays starting on line 167 and 92 respectfully are all the files in the outDir folder.

Note: BUILD TYPE trial is something specific to my app

cameronsutter avatar Nov 21 '19 19:11 cameronsutter

Similar issue? #4435

kzimny avatar Nov 23 '19 19:11 kzimny

Maybe try to look at your folder when it's being built (try in your own PC, and then on CIs if it does change), or maybe it is already named like this.

(on mac, maybe try to chmod 777 the whole folder before renaming, idk)

BellezaEmporium avatar Nov 24 '19 16:11 BellezaEmporium

@kzimny it's not quite similar because that one deals with when the app is trying to update. My issue is during build.

@ShadixAced that's a good idea. I'll give that a try and see what's happening on my local computer

cameronsutter avatar Nov 26 '19 22:11 cameronsutter

I'm having the same issue here. It really looks like afterAllArtifactBuild is called before latest-mac.yml is created. Therefore is quite a pain to setup a deploy system in the afterAllArtifactBuild.

I'm using version 22.2.0

oltreseba avatar Dec 10 '19 09:12 oltreseba

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Feb 08 '20 10:02 stale[bot]

Yes it is still relevant. latest-mac.yml (and alpha-mac.yml and beta-mac.yml if generateUpdatesFilesForAllChannels is set to true) is created after the event afterAllArtifactBuild is fired. It would make sense to fire the afterAllArtifactBuild event after all the files have been created.

oltreseba avatar Feb 12 '20 17:02 oltreseba

Still relevant, because latest-mac.yml is actually not generated when version is valid semver alpha and generateUpdatesFilesForAllChannels: true.
If afterAllArtifactBuild was predictable a hook could be used, that would check if latest-mac.yml is generated, if not then create it by looking if there is beta-mac.yml or alpha-mac.yml and copy that as latest-mac.yml.

kroko avatar Apr 27 '21 20:04 kroko

I solved this problem by using chokidar

// afterAllArtifactBuild.js
const chokidar = require('chokidar')
const fs = require('fs')
const path = require('path')
exports.default = async buildResult => {
  const filePath = path.join(buildResult.outDir, 'latest.yml')
  fs.access(filePath, fs.contants.R_OK, err => {
    const watcher = chokidar.watch(filePath)
    watcher.on(err ? 'add' : 'change', (event, path) => {
        // await do something
        watcher.unwatch(filePath)
        process.exit(0)
      })
  })
}

asd281533890 avatar Aug 03 '21 09:08 asd281533890

Still relevant in 23.0.0-alpha.3

panther7 avatar Feb 11 '22 19:02 panther7

Still relevant in 23.0.2. I'm trying to automate a modification to the yml file before it gets uploaded, and this is impossible directly with afterAllArtifactBuild, as the yml file doesn't exist when afterAllArtifactBuild is called. The above solution by asd seems like a possible hack/workaround, but doesn't seem like it should be the expected approach.

If afterAllArtifactBuild is meant to be used solely for the application artifacts and not the yml file, then a new hook along the lines of "beforeUpload" should be available.

ArmelChesnais avatar Mar 22 '22 18:03 ArmelChesnais

I solved this problem by using chokidar

// afterAllArtifactBuild.js
const chokidar = require('chokidar')
const fs = require('fs')
const path = require('path')
exports.default = async buildResult => {
  const filePath = path.join(buildResult.outDir, 'latest.yml')
  fs.access(filePath, fs.contants.R_OK, err => {
    const watcher = chokidar.watch(filePath)
    watcher.on(err ? 'add' : 'change', (event, path) => {
        // await do something
        watcher.unwatch(filePath)
        process.exit(0)
      })
  })
}

fs.constants.R_OK is right

promotion-xu avatar Jun 16 '22 10:06 promotion-xu

any news on this? can't seem to make it work with chokidar.

I want to wait until latest.yml is created so I can return more items in the array for this afterAllArtifactBuild method

MiguelSOliveira avatar Jul 12 '22 15:07 MiguelSOliveira