C
C#16mo ago
Mekasu0124

❔ ✅ 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
Denis
Denis16mo ago
You can use GitHubs REST API to get the latest release number for a given repository
Denis
Denis16mo ago
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
Mekasu0124
Mekasu0124OP16mo ago
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
Denis
Denis16mo ago
I'd start with figuring out how you will deliver new versions of your app Where will they be stored? My advice - GitHub releases
Mekasu0124
Mekasu0124OP16mo ago
everything is stored on github
Denis
Denis16mo ago
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
Mekasu0124
Mekasu0124OP16mo ago
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
Denis
Denis16mo ago
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
Mekasu0124
Mekasu0124OP16mo ago
the repo holds all the code. The builds folder in the repo is where the executables are
Denis
Denis16mo ago
That is incorrect The builds folder mustn't be part of the version control
Mekasu0124
Mekasu0124OP16mo ago
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
Angius
Angius16mo ago
Releases Built binaries should be in the releases
Mekasu0124
Mekasu0124OP16mo ago
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?
Denis
Denis16mo ago
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
Angius
Angius16mo ago
Yes, the published binaties should be separate from the code, in that they should be excluded from the repository
Denis
Denis16mo ago
Or exclude using gitignore
Mekasu0124
Mekasu0124OP16mo ago
so I just don't need to build them anymore using visual studio or command prompt. I should just let github do it
Angius
Angius16mo ago
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
Mekasu0124
Mekasu0124OP16mo ago
I don't know what "binaries" are
Angius
Angius16mo ago
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 .exes and the rest
Mekasu0124
Mekasu0124OP16mo ago
ok I deleted the folder. now what do I need to do?
Mekasu0124
Mekasu0124OP16mo ago
create a new release on github?
Angius
Angius16mo ago
Well, now you no longer have any files to upload to the release KEKW you're asking how to do it with Github Actions
Mekasu0124
Mekasu0124OP16mo ago
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?
Angius
Angius16mo ago
Create a new release on Github and upload the files there
Mekasu0124
Mekasu0124OP16mo ago
ok so when creating the new release, since this is for windows 64-bit os, I would created a windows_64 tag, right?
Angius
Angius16mo ago
Tags are for versions 1.0.0, 1.1.2, etc You can upload multiple files to a single release
Mekasu0124
Mekasu0124OP16mo ago
ok so would it be version 1.0.0 or 0.0.1? I never quite grasped the versioning concept
Angius
Angius16mo ago
major.minor.patch
Mekasu0124
Mekasu0124OP16mo ago
so 1.0.0
Angius
Angius16mo ago
Yep Since it's the first public release Then, if you add some small functionality, you'd increase the minor
Mekasu0124
Mekasu0124OP16mo ago
ok and how would I write the title? or does that part not matter?
Angius
Angius16mo ago
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
Mekasu0124
Mekasu0124OP16mo ago
ok how does one normally go about describing the release? or does that part not really matter either?
Denis
Denis16mo ago
You can write: Initial release For now
Angius
Angius16mo ago
Since it's the first release, just say it's the first release Yeah
Denis
Denis16mo ago
Next you'd write change notes
Angius
Angius16mo ago
Later on, the description is where your changelog goes
Denis
Denis16mo ago
Check out other repos and how they do their releases E.g., avalonia
Mekasu0124
Mekasu0124OP16mo ago
ok so here's where I'm at
Angius
Angius16mo ago
* Fixes
* No longer crashes on startup
* The text no longer disappears
* Features
* You can now use Markdown in your notes
* Fixes
* No longer crashes on startup
* The text no longer disappears
* Features
* You can now use Markdown in your notes
etc lgtm
Mekasu0124
Mekasu0124OP16mo ago
so drag and drop the zip folder in there
Angius
Angius16mo ago
Yep
Denis
Denis16mo ago
Yes
Mekasu0124
Mekasu0124OP16mo ago
igtm?
Angius
Angius16mo ago
Looks Good To Me
Mekasu0124
Mekasu0124OP16mo ago
oh that's an l not an i lol my bad
Mekasu0124
Mekasu0124OP16mo ago
then publish release?
Mekasu0124
Mekasu0124OP16mo ago
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
Angius
Angius16mo ago
Yep Unless you have some other files you still want to attach
Mekasu0124
Mekasu0124OP16mo ago
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?
Angius
Angius16mo ago
If you want versions for other OSs, then yes All builds of the same version usually go into a single release
Mekasu0124
Mekasu0124OP16mo ago
what does "set as the latest release" do?
Angius
Angius16mo ago
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 instead
Mekasu0124
Mekasu0124OP16mo ago
so I'll want to ensure I check that every time, unless its a pre-release and not ready to be used, right?
Mekasu0124
Mekasu0124OP16mo ago
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?
Angius
Angius16mo ago
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
Mekasu0124
Mekasu0124OP16mo ago
I thought users weren't supposed to have that?
Angius
Angius16mo ago
Well, the code is on Github anyway
Mekasu0124
Mekasu0124OP16mo ago
true
Angius
Angius16mo ago
So it's publicly available anyway
Mekasu0124
Mekasu0124OP16mo ago
ok so now that i've created a release, what do I do next?
Angius
Angius16mo ago
You can send someone a link to it so they can download it And you can access it via the Github API
Mekasu0124
Mekasu0124OP16mo ago
ok so then we're to the part where I would create the update system in my project, right?
Angius
Angius16mo ago
ye
Denis
Denis16mo ago
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
Mekasu0124
Mekasu0124OP16mo ago
this?
Angius
Angius16mo ago
(also, there's some autoupdater packages that can do the updating for you) That's Github Actions, yes
Mekasu0124
Mekasu0124OP16mo ago
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.
Angius
Angius16mo ago
Yep, Github Actions do that
Mekasu0124
Mekasu0124OP16mo ago
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 yourself
Angius
Angius16mo ago
The suggested action looks good for starters
Mekasu0124
Mekasu0124OP16mo ago
how do i determine these different paths?
Angius
Angius16mo ago
uh, first time I heard of Wap Unless in the context of pre-HSDPA mobile internet lol
Mekasu0124
Mekasu0124OP16mo ago
I have zero idea lol so I'm guessing I leave those bottom 3 as they are?
Denis
Denis16mo ago
Isn't it just some dirty pop song?
Mekasu0124
Mekasu0124OP16mo ago
lol
Angius
Angius16mo ago
It is, but I'm talking about this 1999 protocol that let my Sony Ericsson rack up a huge internet bill KEKW https://en.wikipedia.org/wiki/Wireless_Application_Protocol
Mekasu0124
Mekasu0124OP16mo ago
https://pastebin.com/RaZtdVwe here's where I'm at with this file so far. What else do I need to change?
Angius
Angius16mo ago
Ahhh, that looks like an action to build a WinUI app Not Avalonia
Mekasu0124
Mekasu0124OP16mo ago
so cancel this?
Angius
Angius16mo ago
I believe so, yes
Denis
Denis16mo ago
Try googling how to create a GitHub action for avalonia
Angius
Angius16mo ago
Those would be the actions that Avalonia repo uses And they don't seem to be using any
Mekasu0124
Mekasu0124OP16mo ago
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.
Angius
Angius16mo ago
Alternatively, there's the Github CLI gh release create
Mekasu0124
Mekasu0124OP16mo ago
ok and what does that do?
Angius
Angius16mo ago
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
Mekasu0124
Mekasu0124OP16mo ago
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?
Angius
Angius16mo ago
gh release create And it'll lead you through the process
Mekasu0124
Mekasu0124OP16mo ago
'gh' is not recognized as an internal or external command, operable program or batch file
Angius
Angius16mo ago
Did you install Github CLI?
Mekasu0124
Mekasu0124OP16mo ago
I have Git?
Angius
Angius16mo ago
Git is not Github Github is not Git
Mekasu0124
Mekasu0124OP16mo ago
I know I can type git clone <repo_link> but that's all I've ever needed to do
Denis
Denis16mo ago
Git is pron GitHub is pronhub Swap the letters o and r Thus, git =! GitHub
Mekasu0124
Mekasu0124OP16mo ago
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?
Angius
Angius16mo ago
Read the docs
Angius
Angius16mo ago
GitHub CLI
GitHub CLI
Take GitHub to the command line
Angius
Angius16mo ago
gh release create ./bin/release/*.zip will upload all zip files from ./bin/release folder
Mekasu0124
Mekasu0124OP16mo ago
so with me having them separated like I do
root/
- Builds
-- Windows
--- x32
---- Todo_Windows_x32.zip
--- x64
---- Todo_Windows_x64.zip
-- Linux
--- Todo_Linux_x64.zip
-- Mac
--- Todo_Mac_x64.zip
root/
- Builds
-- Windows
--- x32
---- Todo_Windows_x32.zip
--- x64
---- Todo_Windows_x64.zip
-- Linux
--- Todo_Linux_x64.zip
-- Mac
--- Todo_Mac_x64.zip
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 ❤️
Angius
Angius16mo ago
dotnet publish also builds
Mekasu0124
Mekasu0124OP16mo ago
right, 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
Angius
Angius16mo ago
Check the docs for the dotnet publish command, then
Mekasu0124
Mekasu0124OP16mo ago
right. I did that last night and found
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish

dotnet publish [<PROJECT>|<SOLUTION>] [-a|--arch <ARCHITECTURE>]
[-c|--configuration <CONFIGURATION>] [--disable-build-servers]
[-f|--framework <FRAMEWORK>] [--force] [--interactive]
[--manifest <PATH_TO_MANIFEST_FILE>] [--no-build] [--no-dependencies]
[--no-restore] [--nologo] [-o|--output <OUTPUT_DIRECTORY>]
[--os <OS>] [-r|--runtime <RUNTIME_IDENTIFIER>]
[--sc|--self-contained [true|false]] [--no-self-contained]
[-s|--source <SOURCE>] [--use-current-runtime, --ucr [true|false]]
[-v|--verbosity <LEVEL>] [--version-suffix <VERSION_SUFFIX>]

dotnet publish -h|--help
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-publish

dotnet publish [<PROJECT>|<SOLUTION>] [-a|--arch <ARCHITECTURE>]
[-c|--configuration <CONFIGURATION>] [--disable-build-servers]
[-f|--framework <FRAMEWORK>] [--force] [--interactive]
[--manifest <PATH_TO_MANIFEST_FILE>] [--no-build] [--no-dependencies]
[--no-restore] [--nologo] [-o|--output <OUTPUT_DIRECTORY>]
[--os <OS>] [-r|--runtime <RUNTIME_IDENTIFIER>]
[--sc|--self-contained [true|false]] [--no-self-contained]
[-s|--source <SOURCE>] [--use-current-runtime, --ucr [true|false]]
[-v|--verbosity <LEVEL>] [--version-suffix <VERSION_SUFFIX>]

dotnet publish -h|--help
and was just lost
Angius
Angius16mo ago
-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 directory
Mekasu0124
Mekasu0124OP16mo ago
so if I wanted to add the self-contained flag in there, it would be -sc alone or -sc true?
Angius
Angius16mo ago
The flag alone should be enough
Mekasu0124
Mekasu0124OP16mo ago
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
Angius
Angius16mo ago
$singlefile
MODiX
MODiX16mo ago
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:
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
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-publish
Create 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.
Mekasu0124
Mekasu0124OP16mo ago
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 ❤️
Accord
Accord16mo ago
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.
Want results from more Discord servers?
Add your server