Set up CI/CD at Github for Gradle (Java)
It long time to understand because I am really a newcomer. :(
I just curious how to set up CI especially when using Gradle. Many tasks can be automated when using Gradle, so I have the inspiration to create CI/CD from this.
Sample Projects
I create a sample project with the name PDFUtil. What is that? Sometimes I need to remove the password from the PDF, not really common actually. So, I try to build it, takes a long time to build or develop because quite new in Java language world. I do not understand at a low level, so I try to find a higher-level library that helps me to open and remove the password. (Anyway, I need to know the password first, I’m quite lazy to create the guesser, please create with your own. :D) Okay so, in short, this is my repository.
I’m not want to tell you how I create the app, but for TLDR., I have some main components, there are plugin id and Gradle tasks (distTar
& distZip
). So, I need to have a plugin id with the name application
. After that, the main task for deployment is distTar
& distZip
. For the CI, actually, I will need tasks like build
& test
. But, because I’m not finished to create the unit test, so I will skip the test.
Github Action
Next, we go to workflow or CI/CD flow. I use Github Action so it will easy to integrate with another release function from Github Platform itself.
The steps by steps of my workflow:
- Checkout source code
- Setup java (in this case, I use java 11)
- Gradle Build
- Gradle Dist (distTar & distZip)
- Publish Release (only when tagging)
So, I use conditions at steps 4 & 5, only trigger when I push the tag and will create the Github Release.
To publish a release, I use this Github action:
Thank you so much for the Github action!
To Do
Actually, I still need to improve more aspects like CI (unit test and end-to-end test). Also, need release summarization (maybe pull all the commit message and summarize it to Github Release). Many homework that I should do!
Finally
Here we are, you can see the result, I included the dist command result to Github Releases.
At least, I can minimize some manual tasks for the release or deployment. It’s quite good. So, how about you? Do you have a different opinion? It’s okay, tell me, I hope I can improve my skills in CI/CD process especially at DevOps.
Thank you!