chegele / AutoGitUpdate

Update node application from git repo.
63 stars 19 forks source link

Feature request: Add option to get files from GitHub's releases instead of repo #8

Closed GoudronViande24 closed 2 years ago

GoudronViande24 commented 2 years ago

Basically, download files from there instead of a repo: image

I don't know if this could be possible though.

chegele commented 2 years ago

I believe this could be done so long as releases/latest will populate the expected result for you. Here is a breakdown of the changes which I anticipate will be needed. Let me know if these updates would be a viable solution for your request.

  1. Allow the configuration to recognize and accept latest release as an option. Example: config = {repository: "https://github.com/steveukx/git-js/releases/latest", ... }
  2. Identify the tag name of the latest release during initialization Utilize api like: https://api.github.com/repos/steveukx/git-js/releases/latest _Retrieve tag from: _response.tagname : "v2.48.0"_
  3. Update the configured branch to be the tag name This will then work with already built in functionality for checking remote version and cloning. _index.js:46 - updateConfig.branch = 'master' -> updateConfig.branch = response.tagname; index.js:240 - /${config.branch}/package.json // This should work with latest tag index.js:267 - [--branch=${branch}] // This should work with latest tag
GoudronViande24 commented 2 years ago

I'm not entirely sure about step 3, but it looks exactly like what I thought.

chegele commented 2 years ago

I'm not entirely sure about step 3, but it looks exactly like what I thought.

I have added a branch for this feature request. I believe that I have accomplished what you are wanting. I do not personally work with GitHub releases. Would you be willing to complete some testing using this branch of the code and inform me if anything is not meeting expectations? The only change needed is to add "fromReleases: true" to your configuration. You continue to use the same git repo config.

https://github.com/chegele/AutoGitUpdate/tree/GitHub-releases-support

const config = {
    repository: 'https://github.com/chegele/BackupPurger',
    fromReleases: true, <--- NEW CONFIG EXAMPLE
    tempLocation: 'C:\\Users\\scheg\\Desktop\\tmp\\',
    ignoreFiles: ['util/log.js'],
    executeOnComplete: 'C:\\Users\\scheg\\Desktop\\worksapce\\AutoGitUpdate\\startTest.bat',
    exitOnComplete: true
}
GoudronViande24 commented 2 years ago

I managed to use the main branch of my repo to publish the updates for now, but next time I publish an update I will try to implement this. I'll close for now and in case it does not work I will reopen the issue. Thank you very much for the fast response and fix!

GoudronViande24 commented 2 years ago

I'm working on implementing this right now

Changed my Config object to fromReleases: true. The setBranchToReleaseTag function is called on creating the AutoGitUpdate class, so it sends a message to the console before we are able to set the logger config with setLogConfig. Could this be fixed please?

chegele commented 2 years ago

I'm working on implementing this right now

Changed my Config object to fromReleases: true. The setBranchToReleaseTag function is called on creating the AutoGitUpdate class, so it sends a message to the console before we are able to set the logger config with setLogConfig. Could this be fixed please?

You should now be able to include your logging preferences in the configuration object used to create a new AutoGitUpdate instance. This will fire the updateConfig after some configuration validations and before the setBranchToReleaseTag function.

Let me know once you have tested these features. If there are no issues identified i will publish the feature to the NPM module.

GoudronViande24 commented 2 years ago

Just tested, your patch for the log message works perfectly. I will finish to migrate to the /release way and I will tell you when I'm done and if everything works as expected.

GoudronViande24 commented 2 years ago

It looks like it works perfectly, I think it is ready to be published.

chegele commented 2 years ago

Thank you for the awesome feature request and assistance with testing. It has been published for both versions of this module.