How to use Github Actions to publish/automate releases with Example using Maven Java Project

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back to my channel again so as we spoke in the last video in our github packages video today i'm going to use the same project which we created for the last time for the package and you are going to now see what is github actions so actions actions actions there are your actions okay so whenever you created a let this is the project which we created in the last video right so when i open it i'm going to see something called actions so what is actions actions are nothing but whenever you want to create a deployment or when you want to trigger some things some build depending on whenever you want to push the code what it does is it will automatically when uh you can configure it automatically so whenever you push the deployment should happen so the packages will get created okay so what we'll do is uh this is the project that we worked last time right so what i'll do is i'll push the code first okay so this is the package that we created the jar file package which over with it to commit and push push the code okay so make sure that you have added the distribution management here this is really important because this is what it needs because uh depending on the url that we are going to provide here it is going to create or deploy using this one okay so what i'll do is i'll go to actions under the project i'll refresh it so i know when i push the code yeah 28 seconds ago so i'll go to actions okay under actions uh you can choose many things there is something called maven java with maven so something called published our package with maven so uh uh so i what i do is i'll do java package with maven so since we want to create a package right so i'm going to do that i click on setup workflow ok so here if you see i'll just leave most of the thing as it is but only one thing which i want to focus on is this one so you can see uh the name is there on so this whole actions of code whichever is given here right will all get triggered when you run specific commands by default it is telling when i do release so whenever i create whenever i write maven release this is going to get run so now what i'll do is i'll do ins just first just to show you guys what i'll do is i'll just write i just make sure that whenever i push the code the deployment should happen so when i click enter it automatically gives me a list of all the things so you can select whatever you want so what i'll do is i'll use push create branch because i am i want to deploy that is in the master branch right okay done so i'll just click on commit commit new file so it will be created under a dot github folder there guys okay you come here right under dot github folder it will be created so since everything is now then i'll pull the code so that my project is updated so i should see dot github uh yeah i can see the folder the pull has been work see i can see all the things here okay so um we have to make sure that we still have the settings.xml with our data so i'm going to delete because you're not no more using it so this is our thing which we want to download and we have our credentials here okay okay so i'm going to close the settings.xml everything is there okay so what i'll do now is i'll click on edit configurations verify because it's going to run and see what is going to happen okay it is going to work anyways okay we gave here when when we push the code the deployment should happen right okay so what i'll do here is i'll create one more method this is just for reference that's all this is that should not necessarily be something like this public void some function is out okay it's going to print something uh why i did this is because i just want to show you guys uh i'll also change the version number here snapshot 1.1 because we used 1.0 for the github package example right so i'm going to make it to 1.1 here so why i did this is because um and since you have given in the maven publish file that whenever i pushed a code this maven package will happen so now what what i'll do since i've done something i made some changes right so i'll refresh my one because i change the version number then once this is done i'm going to commit and push the [Music] code okay i did some data you have to give a specific message so practice that guys this is just for an example i'm going to commit and push nowhere as to warning from it's okay commit and push again push two files has been committed get it is pushing okay pushed so i'll come back to my project and click on actions okay see some added some data this was the one we just did it right so i'll click on it i can see the build here on the left side see it is setting up everything this is going to build it so last time when you saw in my project here under packages you saw my example package with 1.0 snapshot right now i the expected thing is you should give me 1.1 snapshot okay now i see all the things has been done and the build is successful i'll just refresh my packages here my i can see 1.1 is added here so when i go here i can also see 1.1 so what why why are we doing this is because uh in your project you don't have to necessarily always come and create packages in like this and do it so if you if you have configured certain things here and uh this is like something useful when you're using ci cd pipelines or sunkens or something like that so it's automatically done so that is the reason uh whenever i created um the file whenever i created the file here this github dot maven publish dot ymen i can see that you can see there was only release um commander so when i do mvn release this was going to get record but since just for you just to show you guys i used push command because we wanted to push the code and check right so now for this project whenever i'm going to do a push command the package is going to get created and make sure guys whenever you're going to get whenever you're creating a package make sure the versions are different because there's no use right because when you make some changes and you want to upload updated or something when you want to add some extra features or solve some bugs in that and when you want to push the code you always want to change the version number you can also remove the snapshot you can also remove the snapshot here and you can only directly give why there is may one release okay why there is okay let us also try that let me go to terminal i will write mbn release okay i think i would need maven release plugins and everything let me just try whether it is going to work or not build failure valid life cycle do okay i think i forgot let me try to run the deploy command and see whether release is going to work or not life cycle phases let's see when the release is going to get triggered [Music] deploy should work i guess yeah it is downloading and uploading everywhere okay let me come here and refresh this actions okay no okay so guys oh i what i'll do i'll cover this in a next video or maybe sometime later so this is nothing i have nothing to do with uh to this tutorial actually uh it's just start to whenever you want to whenever you give your specific command maven command this particular code is going to get triggered okay so why release is because in release the snapshot is not going to come it is just going to ask you what version you have to release it it is going to take 1.01 if you want if you are releasing this particular file it will take 1.1 as the release it will not add this hyphen snapshot so after it releases it will make your sash once 1.2 whatever you give right it will make that as 1.2 let me also show i forgot it v1 release begin and even i'll copy this release plugin i'll put it in my [Music] build refresh it it is mbn release call and prepare let me try this okay scanning projects so before release right it is going to validate most of the things missing required scm connection and everything okay all these guys you need to put it in your form file so let me see if i have it in any of the older versions there is my old project okay let's just go back to my github project so uh this is how we learn guys because certain things you only encounter when you are working on it so scm i haven't i'll copy it i will put it just under the distribution management or anywhere so i need to change the names right so one copy paste it copy and paste it copy and paste it paste paste it so i've changed that urls and everything so developer information is also needed because that is what it has a developer connection must be specified right so here i'm going to copy the same thing again change the package name okay let me refresh my name and project and i'll run it again i would need this also yes okay that is refreshed i'll run the same name and release prepare again hopefully it should work okay form cannot prepare release because okay i think i should push this again update 10 commit and push because this is release rise we have to be very careful because whenever you do a release it means that you are releasing it's not a it's not just a build version it's not just a demo version you're releasing it to somebody else or maybe releasing it to a internet or somewhere just post let me again try to run so that is why it is more cautious because it needs to know what are you trying to release and what are you trying to push and everything okay see this is what i asked what is the release version of gita pack example package 1.1 right i'm i'm just going to click on enter because here it will not now release the packages as snapshot it'll now going to release at the release package i'm just going to click on enter what sem tagger label that we have to keep okay let me go back to the top there was something tag i think repository so github type screen okay i'm just going to click enter again what is the new develop c i as i told you right it is now changed to 1.2 so once you release the next version we are working on is 1.2 snapshot right so something i'll click enter executing goes clean verify [Music] it is doing all these things so whenever you do a release it actually checks whether everything is valid all the dependencies are there whether your project is working and everything only then it is going to work so it is still working working working it will take some time yeah build a sucks now successful so i just go back to reflect the file and go back to actions again hopefully it should be there see i can say as i said you're right when i did a maven release it automatically took the package names for it for us see maven release commit again prepare for release for next development that is also there and this is also that this is this is successful let us wait for this one to get completed why this one run run right guys okay let me tell you this one ran as a different com okay the maven release also committed itself and when we committed we also did one more time here okay all this releases do two commits actually i'll show you when you do a maven command it may one release right see we did not commit these two as a as as you saw in the video this was the last commit that i did but maven automatically did two more commits for us that is why specifying the user names specifying the sem details is mandatory here go back to actions okay if it is completed now what i'll do is i'll go back to my project my profile under the packages 1.2 okay 1.2 is there here because that was the next one right that we wanted to work on see it all changed to 1.2 and it pushed the code i did not change it anytime it asked me when i did a maven release and it and i got it see 1.1 is already here you can see right recent versions why there is 1.2 because maven also pushed a developmental uh project right because we released 1.2 and this is snapshot is still in development phase that is called snapshot there so 1.1 is again a release version you can see it is just 1.1 now okay so i've covered these things guys thank you for watching if you have any questions please give me a comment i'll just reply you guys whenever i have time and thank you for watching the video if you like my video please like subscribe guys thank you
Info
Channel: Manjunath Prabhakar
Views: 1,697
Rating: 4.6923075 out of 5
Keywords: maven, java, jar, github, githubpackages, githubactions, actions, mvn, release, mvnrelease, mvninstall
Id: SbQ5lL8lw8o
Channel Id: undefined
Length: 19min 1sec (1141 seconds)
Published: Tue Aug 18 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.