How to check last version of script using gihub/gitlab/bitbuchet/%other_git% services?
13 replies, posted
Hello, FacePunch GLua devs! :v:
I have a script on my local machine and it has a version of this script with a value — "0.1".
Also I have the same script on git-hosting. Now it has a version — "0.2".
How can I make version-checker in my script that will print in server console messages like as: "Available a new update!"?
Google search can't helps me to find solve of this problem! :disappoint:
I have found a http.Fetch() library and It may be solution of my problem, but I don't know how to use it right, because I have a "version.txt" file as on my local machine and on git-hosting. And I need fetch only "0.1" or "0.2" value from git-hosting, not html code.
I'm looking forward for your replies!
For example, lets take this script as an example of this in github.
[url]https://github.com/TeamUlysses/ulx[/url]
ULX Github. You can see their version is the... "ulx.build" file.
Well, if you want to retrieve that file directly from Github in plain text, you go to the file and press on the "Raw" button thats on top of the content of the file. And then the URL changes to the URL in which you would obtain that file RAW, for example, in ULX it would turn to [url]https://raw.githubusercontent.com/TeamUlysses/ulx/master/ulx.build[/url]
but it depends on the git service you're using.
[editline]7th June 2017[/editline]
It would be the same in Bitbucket and on Gitlab, but have in mind that the project has to be public so the server can retrieve this files.
Do you use Linux or Windows? It's super simple using Linux.
[QUOTE=geferon;52322564]For example, lets take this script as an example of this in github.
[url]https://github.com/TeamUlysses/ulx[/url]
ULX Github. You can see their version is the... "ulx.build" file.
Well, if you want to retrieve that file directly from Github in plain text, you go to the file and press on the "Raw" button thats on top of the content of the file. And then the URL changes to the URL in which you would obtain that file RAW, for example, in ULX it would turn to [url]https://raw.githubusercontent.com/TeamUlysses/ulx/master/ulx.build[/url]
but it depends on the git service you're using.[/QUOTE]
Thank you! I think this is that what I needed.
[QUOTE=geferon;52322564]
[editline]7th June 2017[/editline]
It would be the same in Bitbucket and on Gitlab, but have in mind that the project has to be public so the server can retrieve this files.[/QUOTE]
Oh... My project is in closed access. Is it possible to do same for close project?
for a lot of people that use github (and feature similar platforms), they push a release out to the releases tab on the platform
This information is easily avaliable over the Webapi, you can match these releases to your git SHA, or your own release string (SHA Hash can be easier for tracking versions down to the commit level on your releases)
Github's api for fetching releases can be found here;
[url]https://developer.github.com/v3/repos/releases/[/url]
[QUOTE=Kris101;52322581]Do you use Linux or Windows? It's super simple using Linux.[/QUOTE]
In fact, both of that. First I make script on my local home PC then I upload it on server that use Linux OS. I think I need something that will be multi-platform. :)
[QUOTE=Kris101;52322581]Additionally, the workshop has ULX/ULIB - which will automatically update.[/QUOTE]
Yeah, thanks, as had been written before in other post.
I'll check it out when I get back to my PC.
[editline]7th June 2017[/editline]
[QUOTE=Scratch.;52322597]for a lot of people that use github (and feature similar platforms), they push a release out to the releases tab on the platform
This information is easily avaliable over the Webapi, you can match these releases to your git SHA, or your own release string (SHA Hash can be easier for tracking versions down to the commit level on your releases)
Github's api for fetching releases can be found here;
[url]https://developer.github.com/v3/repos/releases/[/url][/QUOTE]
Hmm, it's interesting. Are there any examples of fetching methods in Lua? Because I need to fetch only latest version and maybe latest update date. Also, does it works for closed project of gitlab?
If you allow srcds (on by default?) to parse updated scripting files, it's extremely easy to make a background (non-garrysmod) script to check for say - the latest commit/head/version file in the git repository for version - wget it and move it into the correct path.
[QUOTE=Kris101;52322628]If you allow srcds (on by default?) to parse updated scripting files, it's extremely easy to make a background (non-garrysmod) script to check for say - the latest commit/head/version file in the git repository for version - wget it and move it into the correct path.[/QUOTE]
I need to print a message that update available with [b]server console[/B], without using any third-party widgets. [i](If I understand you correctly)[/i]
I want that script automatically print it into server console.
Alright, I have just learned to use http.Fetch(). It works fine with pastebin service, but is it possible to use it with closed project on gitlab?
It would be really good!
For that answer you will need to read through their API and find out. Oh look a [URL="https://docs.gitlab.com/ce/api/repositories.html"]Link[/URL].
[QUOTE=FusionLord;52323055]For that answer you will need to read through their API and find out. Oh look a [URL="https://docs.gitlab.com/ce/api/repositories.html"]Link[/URL].[/QUOTE]
Oh.. Is it possible to get link where I just can paste my private token, enter folder and next paste it into my script or something same? It's hard for me to find something like that, because I don't use Linux, but this documentation focused on Linux OS.
That documentation has nothing to do with linux. It is a web rest api.
[QUOTE=FusionLord;52323487]That documentation has nothing to do with linux. It is a web rest api.[/QUOTE]
Yeah, sorry, I already knew. I was confused by these commands before the web requests. I am almost close to solving my problem. It turns out that I need to use a query: https://gitlab.com/api/v3/projects/<project_id>/repository/raw_blobs/<file_id>?private_token=<your_private_token> —, but I had half an hour looking for where I can take a <file_id>. Can you help me? Where can I find this <file_id>?
I have been solve my problem. Solution of my problem (may be useful for those, who has same issue):
[quote]1. I have recieved got all tree of folders/files that located in on my project with web-request (this tree also contains the file IDs):
https://gitlab.com/api/v3/projects/<project_id>/repository/tree?recursive=1
2. I readed code of file on GitLab with web-request:
https://gitlab.com/api/v3/projects/<project_id>/repository/raw_blobs/<file_id>?private_token=<your_private_token>[/quote]
I thank everyone who helped me in solving this problem!
You are best, guys! :class:
Sorry, you need to Log In to post a reply to this thread.