Set up CI/CD at Github for Gradle (Java)
Tags: cicdpipeline, github, githubactions, gradle
Published: 2021-07-04 13:23:01

---
title: Set up CI/CD at Github for Gradle (Java)
published: true
date: 2021-06-25 13:30:57 UTC
tags: cicdpipeline,github,githubactions,gradle
canonical_url: https://berviantoleo.medium.com/set-up-ci-cd-at-github-for-gradle-java-519b210ab2c2
---

#### 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.

[bervProject/PDFUtil](https://github.com/bervProject/PDFUtil)

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:

1. Checkout source code
2. Setup java (in this case, I use java 11)
3. Gradle Build
4. Gradle Dist (distTar & distZip)
5. 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:

[softprops/action-gh-release](https://github.com/softprops/action-gh-release)

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.

![](https://cdn-images-1.medium.com/max/1024/1*F754p1cudY5n4Z-7U43d-A.png)<figcaption>Github Release</figcaption>

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!

![](https://cdn-images-1.medium.com/max/1024/0*RiSaPj7Ly1UafSO-)<figcaption>Photo by <a href="https://unsplash.com/@hannynaibaho?utm_source=medium&amp;utm_medium=referral">Hanny Naibaho</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption>