Code Monkey home page Code Monkey logo

build-release-cicd-sample's Introduction

build-release-cicd-sample

This is an example of setting up CI/CD pipeline for a Java Maven project using GitHub Actions

CI/CD with GitHub Actions

This GitHub Actions workflow automates the build and release process for a Java Maven project. The workflow includes two jobs: "build" and "release," each serving a specific purpose in the Continuous Integration and Continuous Deployment (CI/CD) pipeline.

Trigger

This workflow is triggered on each push to the main branch. Any changes pushed to the main branch will initiate the workflow, ensuring that the latest code changes are automatically tested, built, and released.

on:
  push:
    branches:
      - main

Build Job

The "build" job is responsible for setting up the Java environment, compiling the project using Maven, and running any necessary build tasks. This job uses the actions/setup-java action to configure JDK 11.

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: 'Set up JDK 11'
        uses: actions/setup-java@v3
        with:
          java-version: '11'
          distribution: 'temurin'

      - name: Build with Maven
        run: mvn clean install -Dmaven.test.skip=true --file pom.xml

Explanation:

  • runs-on: Specifies the operating system on which the workflow will run (ubuntu-latest in this case).
  • Set up JDK 11: Configures the Java environment using JDK 11 from the Temurin distribution.
  • Build with Maven: Executes Maven commands to clean the project, install dependencies, and build the project. The -Dmaven.test.skip=true flag skips running tests during the build.

Release Job

The "release" job is dependent on the successful completion of the "build" job. It uses the softprops/action-gh-release action to create a GitHub release, including the generated JAR files in the release assets.

  release:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Create Release
        uses: softprops/action-gh-release@v1
        with:
          files: target/*.jar

Explanation:

  • needs: build: Specifies that the "release" job depends on the successful completion of the "build" job.
  • Create Release: Utilizes the softprops/action-gh-release action to create a GitHub release. The specified files (JAR files in the target directory) are included in the release as assets.

This workflow streamlines the software delivery process, providing a seamless CI/CD pipeline for Java Maven projects hosted on GitHub. Any commits to the main branch will automatically trigger these defined steps, ensuring that the project is continuously integrated, tested, and released with each push.

build-release-cicd-sample's People

Contributors

shrss-service-wso2-cloud avatar ramiiyan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.