❔ ✅ creating an update feature in my application
https://github.com/mekasu0124/Todo
I've created a todo application. I want to incorporate a feature that will check the users current version against the github version. If they do not match, I would like to have a popup window appear over the homescreen informing the user that there is an update available and they click the yes or no button to update. When the application starts to update, I would like for it to close the application and show a loading bar screen that will show the progress of the update, and time remaining until finished. Once the update has finished, I'd like for the loading screen to close, and the application to open back up. I do not know how to do this, so it'll be a learning process for me, but any help is appreciated in advanced. Thank you
115 Replies
You can use GitHubs REST API to get the latest release number for a given repository
You will have to register your app with GitHub apps, as far as I can see. Which is easy, but the tricky part is getting your access token into your app without leaking it
The best way to tackle this is to create a GitHub action for automatically building your app and creating a release
The GitHub action, or CI/CD process, should be used to safely provide your app with the access token without revealing to everyone in your source code
Check out whether you can get a repos latest release without a token, that'll simplify things for you
I appreciate all of that, but I am beyond lost and have no idea what to do with any of this
I do not know how to do this, so it'll be a learning process for me, but any help is appreciated in advanced. Thank you
I'd start with figuring out how you will deliver new versions of your app
Where will they be stored?
My advice - GitHub releases
everything is stored on github
Figure out how to publish a new release in GitHub
Not the source code, but the compiled app
I haven't seen any releases in your Todo repo
there aren't any at this time. The app is built and ready to go. I just wanted to implement a pop up window that alerted users of an update and when they click update, it closes the app and shows a loading screen that showed the progress of the update and once it was finished, it closed the loading screen and opened the app back up.
the update implementation is only being added in for if I produce updates in the future
I figured it easier to learn with my todo app as that's what I used to learn avalonia
This is how the user will interact with the update mechanism. But you need to figure out the following:
Where to get information of a new version update
If you upload the built binaries directly into your repository source code, then you are doing it incorrectly
It doesn't belong there
the repo holds all the code. The builds folder in the repo is where the executables are
That is incorrect
The builds folder mustn't be part of the version control
well idk what you want me to do. I build the app for windows 64, windows 32, linux 64, and mac 64. Gotta have a way to separate them
Releases
Built binaries should be in the releases
I'm beyond confused. In the last thread I was told not to put my executables separate from my code. So I didn't. I created a builds folder to build my executables into which contains the files generated from the build and a zip folder of those files. I was told to do the zip folder as that's what I would use for the releases so what am I not understand?
You either build them binaries manually and upload to GitHub releases, or most preferably,
Create a CI/CD pipeline using GitHub actions to build your app automatically
Oh no
Delete that builds folder please. It's not something you do
Yes, the published binaties should be separate from the code, in that they should be excluded from the repository
Or exclude using gitignore
so I just don't need to build them anymore using visual studio or command prompt. I should just let github do it
You can do that, yes
Or you can build them using VS or CLI, sure
But exclude the build directory from the repo
And upload the binaties, manually if need be, as a release
I don't know what "binaries" are
Letting Github Actions do it will be easier in the long run, but will require some setup
That's what the code turns into when it's compiled
Your release files
.exe
s and the restok I deleted the folder. now what do I need to do?
create a new release on github?
Well, now you no longer have any files to upload to the release you're asking how to do it with Github Actions
one second
please*
- Builds folder has been added to the gitignore
- rebuilt executable and other generated files for windows x64
so now I put those generates files and the executable in a zip folder, yes?
they've been placed into a zip folder. What's my next step?
Create a new release on Github
and upload the files there
ok so when creating the new release, since this is for windows 64-bit os, I would created a
windows_64
tag, right?Tags are for versions
1.0.0
, 1.1.2
, etc
You can upload multiple files to a single releaseok so would it be version 1.0.0 or 0.0.1? I never quite grasped the versioning concept
major.minor.patch
so 1.0.0
Yep
Since it's the first public release
Then, if you add some small functionality, you'd increase the minor
ok and how would I write the title?
or does that part not matter?
Whatever you want
And if you patch some bugs, you increase the patch
And if you rewrite the app, or change it completely, you increase the major
ok how does one normally go about describing the release?
or does that part not really matter either?
You can write: Initial release
For now
Since it's the first release, just say it's the first release
Yeah
Next you'd write change notes
Later on, the description is where your changelog goes
Check out other repos and how they do their releases
E.g., avalonia
ok so here's where I'm at
etc
lgtm
so drag and drop the zip folder in there
Yep
Yes
igtm?
Looks Good To Me
oh that's an
l
not an i
lol my badthen publish release?
I do apologize if I'm coming off as a headache. I don't mean to. I just learn a different way and a slightly slower rate than others
Yep
Unless you have some other files you still want to attach
ok it published. what do I do with it now?
oh so I should've built the other files and put them in the zip folders and added them at the same time?
for the other os's?
If you want versions for other OSs, then yes
All builds of the same version usually go into a single release
what does "set as the latest release" do?
It makes it so it shows when you link to the
/latest
release
You can get a link to individual releases, but they change
So if you want a link to the latest release somewhere, you use /releases/latest
insteadso I'll want to ensure I check that every time, unless its a pre-release and not ready to be used, right?
ok so I've created the release, but it added 2 extra items that I didn't put:
Source code (zip)
and Source code (tar.gz)
what are those?I believe the last release always becomes the latest automatically
The "set as latest" simply lets you overwrite that behaviour
They contain the source code
I thought users weren't supposed to have that?
Well, the code is on Github anyway
true
So it's publicly available anyway
ok so now that i've created a release, what do I do next?
You can send someone a link to it so they can download it
And you can access it via the Github API
ok so then we're to the part where I would create the update system in my project, right?
ye
What you want to do isn't as trivial as you'd like.
You need to compile your app in such a way that it knows its release verison, can ask GitHub for the lastest release and download it, if needed. The installation process is a whole other story
What you just did was manual release creation. It's best to automate it all using CICD via GitHub actions
this?
(also, there's some autoupdater packages that can do the updating for you)
That's Github Actions, yes
I'm willing to learn whatever is easiest. If there's a way that I can work on my code, and when I make a push to github, github will automatically create a new release and version and stuff, then I'll go that route.
Yep, Github Actions do that
like if I could use the command prompt within the projects directory to do something like
github -push -main -build -new_version/release -<version_number>
and it handle the rest for me, awesome
ok what action do I want to go with and how do I set it up?
or do I want to select the blue line that says setup a workflow yourselfThe suggested action looks good for starters
how do i determine these different paths?
uh, first time I heard of Wap
Unless in the context of pre-HSDPA mobile internet lol
I have zero idea lol
so I'm guessing I leave those bottom 3 as they are?
Isn't it just some dirty pop song?
lol
It is, but I'm talking about this 1999 protocol that let my Sony Ericsson rack up a huge internet bill
https://en.wikipedia.org/wiki/Wireless_Application_Protocol
https://pastebin.com/RaZtdVwe
here's where I'm at with this file so far. What else do I need to change?
Ahhh, that looks like an action to build a WinUI app
Not Avalonia
so cancel this?
I believe so, yes
Try googling how to create a GitHub action for avalonia
Those would be the actions that Avalonia repo uses
And they don't seem to be using any
so it's sounding like I'll have to manually create a workflow then?
I mean, honestly, if it's I create a workflow manually, or just manually upload my releases, I'm ok with the latter. I just wanted a way that my applications would check for updates themselves and then update the application as updates became available with a cute little loading screen.
Alternatively, there's the Github CLI
gh release create
ok and what does that do?
Creates a release
So you don't need to open the browser, the project, etc
And you can do it all from the command line
ok so I'd use the publisher to create the executables, put those created files into a zip folder like I've been doing and then go to command prompt and type what?
gh release create
And it'll lead you through the process'gh' is not recognized as an internal or external command, operable program or batch file
Did you install Github CLI?
I have Git?
Git is not Github
Github is not Git
I know I can type
git clone <repo_link>
but that's all I've ever needed to doGit is pron
GitHub is pronhub
Swap the letters o and r
Thus, git =! GitHub
ok so I got the cli installed, and ran
gh release create
. I went through the prompts and created a new tag 1.0.1 and such. It did it, however, I went to the address it gave me, and it only has the source code. It didn't take the executables so how should I have ran the command so that it pulls the executables from the build folder (there are 4 zip folders to include) instead of just doing the source code?Read the docs
gh release create ./bin/release/*.zip
will upload all zip
files from ./bin/release
folderso with me having them separated like I do
my command would be like
gh release create v1.0.2 ./Builds/Windows/x32/Todo_Windows_x32.zip ./Builds/Windows/x64/Todo_Windows_x64.zip ./Builds/Linux/Todo_Linux_x64.zip ./Builds/Mac/Todo_Mac_x64.zip
right?
ok that actually worked 😂 cool. Last question. If I wanted to use the command prompt to build my projects to those executables, I know I can use dotnet build
then dotnet publish
but how can I get it to designate those folders for each build and each type of build? Something like dotnet publish win-64 /target/destination/folder
?
meh it's alright. I like the way it's setup now 🙂 thank you for your help, both of you ❤️dotnet publish
also buildsright, but as per https://discord.com/channels/143867839282020352/1143782009215393883/1143784175313375363
...bin\Debug\net7.0\publish I found it here, ...it publishes to that folder instead of asking me what os I want to create the files for (Wx32, Wx64, Lx64, Mx64) and where I want to put them
./Builds/Windows/x32
, ./Builds/Windows/x64
, ./Builds/Linux
, ./Builds/Mac
Check the docs for the
dotnet publish
command, thenright. I did that last night and found
and was just lost
-o
or --output
sets the output path
And -r
or --runtime
sets the runtime identifier
So dotnet publish -o ./builds -r win-x64
will publish a Win64 build in ./builds
directoryso if I wanted to add the self-contained flag in there, it would be -sc alone or -sc true?
The flag alone should be enough
ok so I ran
dotnet publish -o ./Builds/Windows/x32 -r win-x86
and it put 244 files in the designated folder. I deleted those files and ran
dotnet publich -o ./Builds/Windows/x32 -r win-x86 --self-contained
and it did the same thing again. So what am I missing? I think it's the produce single file
that is in the publish wizard$singlefile
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true
Use of -p:PublishSingleFile=true
implies --self-contained true
. Add --self-contained false
to publish as runtime-dependent.
-r RID
and -p:PublishSingleFile=true
can be moved to .csproj as the following properties:but to target multiple RIDs, you have to use dotnet publish
with the -r
option for each RID.
You can also add -p:IncludeNativeLibrariesForSelfExtract=true
to include native libraries (like Common Language Runtime dlls) in the output executable.
You might want to instead publish your application compiled Ahead Of Time to native code, see $nativeaot for examples.
https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file
https://docs.microsoft.com/en-us/dotnet/core/rid-catalog
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publishCreate a single file for application deployment - .NET
Learn what single file application is and why you should consider using this application deployment model.
.NET Runtime Identifier (RID) catalog
Learn about the runtime identifier (RID) and how RIDs are used in .NET.
ok bet. that worked. tyvm
ok I believe I'm done here so I'm going to let this ticket close and make a new one to learn about popups and such
thanks for all your help, both of you ❤️
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.