Skip to content

avioconsulting/shared-workflows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Github Actions - Shared Workflows

A repository to store the Github Actions shared workflows

Adding workflows to a new project

Maven Java Build

Create/Add a .github/workflows/build.yml file within the project.

name: Maven Build and Release

on:
  push:
    branches:
      - 'main'
      - 'chore/**'
      - 'feat/**'
  pull_request:
    branches:
      - 'main'

jobs:
  Build-Maven:
    uses: avioconsulting/shared-workflows/.github/workflows/maven-build.yml@main
    secrets: inherit
    # with:
    #   include-mule-ee-repo: false
    #   java-distribution: adopt-hotspot
    #   java-version: 8
    #   include-test-results: true
    #   maven-args: -X

  Release-Maven:
    needs: Build-Maven
    uses: avioconsulting/shared-workflows/.github/workflows/maven-release.yml@main
    secrets: inherit
    with:
      app-version: ${{ needs.Build-Maven.outputs.app-version }}
    #   java-distribution: adopt-hotspot
    #   java-version: 8
    #   publish-maven-central: true
    #   maven-args: -X
    #   main-branch: main

  Post-Release-Maven:
    needs: [Build-Maven, Release-Maven]
    uses: avioconsulting/shared-workflows/.github/workflows/maven-post-release.yml@main
    secrets: inherit
    with:
      app-version: ${{ needs.Build-Maven.outputs.app-version }}
    #   java-distribution: adopt-hotspot
    #   java-version: 8
    #   maven-args: -X
    #   pr-reviewers: adesjardin, manikmagar, kkingavio

Maven mule-plugin Build

The difference with a mule-plugin build, is that a mule-plugin needs to be deployed to maven central.

name: Maven Build and Release for Mule-Plugin

on:
  push:
    branches:
      - 'main'
      - 'chore/**'
      - 'feat/**'
  pull_request:
    branches:
      - 'main'

jobs:
  Build-Maven:
    uses: avioconsulting/shared-workflows/.github/workflows/maven-build.yml@main
    secrets: inherit
    with:
      include-mule-ee-repo: true
    #   java-distribution: adopt-hotspot
    #   java-version: 8
    #   include-test-results: true
    #   maven-args: -X

  Release-Maven:
    needs: Build-Maven
    uses: avioconsulting/shared-workflows/.github/workflows/maven-release.yml@main
    secrets: inherit
    with:
      app-version: ${{ needs.Build-Maven.outputs.app-version }}
      publish-maven-central: true
    #   java-distribution: adopt-hotspot
    #   java-version: 8
    #   maven-args: -X
    #   main-branch: main

  Post-Release-Maven:
    needs: [Build-Maven, Release-Maven]
    uses: avioconsulting/shared-workflows/.github/workflows/maven-post-release.yml@main
    secrets: inherit
    with:
      app-version: ${{ needs.Build-Maven.outputs.app-version }}
    #   java-distribution: adopt-hotspot
    #   java-version: 8
    #   maven-args: -X
    #   main-branch: main
    #   pr-reviewers: adesjardin, manikmagar, kkingavio

Gradle Java Build

name: Gradle Build and Release

on:
  push:
    branches:
      - 'main'
      - 'chore/**'
      - 'feat/**'
  pull_request:
    branches:
      - 'main'

jobs:
  Build-Gradle:
    uses: avioconsulting/shared-workflows/.github/workflows/gradle-build.yml@main
    secrets: inherit
    # with:
    #   include-mule-ee-repo: false
    #   java-distribution: adopt-hotspot
    #   java-version: 8
    #   include-test-results: true
    #   gradle-args: -X

  Release-Gradle:
    needs: Build-Gradle
    uses: avioconsulting/shared-workflows/.github/workflows/gradle-release.yml@main
    secrets: inherit
    with:
      app-version: ${{ needs.Build-Gradle.outputs.app-version }}
    #   java-distribution: adopt-hotspot
    #   java-version: 8
    #   gradle-args: -X
    #   main-branch: main

  Post-Release-Gradle:
    needs: [Build-Gradle, Release-Gradle]
    uses: avioconsulting/shared-workflows/.github/workflows/gradle-post-release.yml@main
    secrets: inherit
    with:
      app-version: ${{ needs.Build-Gradle.outputs.app-version }}
    #   java-distribution: adopt-hotspot
    #   java-version: 8
    #   main-branch: main
    #   version-project: mule-linter-core
    #   pr-reviewers: adesjardin, manikmagar, kkingavio

UV Python Build

Must use UV as package manager

name: Build and Release for Python Project

on:
  push:
    branches:
      - 'main'
      - 'chore/**'
      - 'feat/**'
  pull_request:
    branches:
      - 'main'

jobs:
  Build-Python:
    secrets: inherit
    uses: avioconsulting/shared-workflows/.github/workflows/python-build.yml@main
    with: 
      # python-version: '3.12'
      # include-test-results: true

  Release-Python:
    secrets: inherit
    needs: Build-Python
    uses: avioconsulting/shared-workflows/.github/workflows/python-release.yml@main
    with:
      app-version: ${{ needs.Build-Python.outputs.app-version }}
      # main-branch: 'main'

  Post-Release-Python:
    secrets: inherit
    needs: [Build-Python, Release-Python]
    uses: avioconsulting/shared-workflows/.github/workflows/python-post-release.yml@main
    with:
      app-version: ${{ needs.Build-Python.outputs.app-version }}
      # python-version: '3.12'
      # main-branch: 'main'
      # pr-reviewers: adesjardin, manikmagar, kkingavio

Shared Workflow Details

maven-build.yml

  • Runs on any branches defined by the project build.yml, which should include main, chore/*, feat/*
  • Executes initial setup, then .mvnw compile, .mvnw verify and then publishes the unit test results
Variable Description Type Required Default Input/Output
include-mule-ee-repo Adds the Mule EE repo to settings.xml for java setup. This is needed for mule plugin projects. boolean false false input
java-distribution The Java Distribution to use string false adopt-hotspot input
java-version The Java Version to use string false 8 input
include-test-results A flag to run publish-unit-test-result boolean false true input
maven-args Maven arguments appended to maven calls string false n/a input
app-version The application version string n/a n/a output

maven-release.yml

  • Only runs on the main branch
  • Executes initial setup, then runs JReleaser, and captures the JReleaser output. Optionally it will release the artifact to maven central
Variable Description Type Required Default Input/Output
app-version Application version to release string true n/a input
publish-maven-central Publish artifact to maven central, enable this for mule-plugins boolean false false input
java-distribution The Java Distribution to use string false adopt-hotspot input
java-version The Java Version to use string false 8 input
main-branch Main branch name, allows override for repos that still use ‘master’ string false main input
maven-args Maven arguments appended to maven calls string false n/a input

Maven release workflow requires the following Organization Secrets to be shared with the target repository :

  • JRELEASER_GPG_PASSPHRASE
  • JRELEASER_GPG_PUBLIC_KEY
  • JRELEASER_GPG_SECRET_KEY
  • MAVEN_GPG_PASSPHRASE
  • MAVEN_GPG_PRIVATE_KEY
  • MULE_EE_PASSWORD (if Mule EE is needed)
  • MULE_EE_USERNAME (if Mule EE is needed)

Depending on the target maven deployment repository, configure the target repository secrets and maven POM.

NOTE: Do not set both sets of secrets on a repository, build may fail.

If you are using avio-mule-modules-parent, check its documentation for how to configure Maven POM.

Deploying to Maven Central

Assign following secrets to the target repository -

  • OSSRH_PASSWORD
  • OSSRH_USERNAME

Distribution Management section -

    <distributionManagement>
        <repository>
            <id>ossrh</id>
            <url>${nexus.url}/service/local/staging/deploy/maven2/</url>
        </repository>
        <snapshotRepository>
            <id>ossrh</id>
            <url>${nexus.url}/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

Deploying to AVIO's JFrog Artifactory

Assign following Secrets to the target repository -

  • MAVEN_PUBLISH_USERNAME
  • MAVEN_PUBLISH_PASSWORD

Distribution Management section -

  <distributionManagement>
    <repository>
      <id>maven-publish</id>
      <name>AVIO Releases Repository</name>
      <url>https://avio.jfrog.io/artifactory/mulesoft-mvn-local/</url>
    </repository>
    <snapshotRepository>
      <id>maven-publish</id>
      <name>AVIO Snapshots Repository</name>
      <url>https://avio.jfrog.io/artifactory/mulesoft-mvn-local/</url>
    </snapshotRepository>
  </distributionManagement>

maven-post-release.yml

  • Only runs on main branch, if the app-version does not include 'SNAPSHOT'
  • Executes initial setup, increments the pom version, then creates a pull request for the version changes
Variable Description Type Required Default Input/Output
app-version Application version that was released string true n/a input
java-distribution The Java Distribution to use string false adopt-hotspot input
java-version The Java Version to use string false 8 input
main-branch Main branch name, allows override for repos that still use ‘master’ string false main input
pr-reviewers Users to be included in the post-release pull request string false adesjardin, manikmagar, kkingavio input

gradle-build.yml

  • Runs on any branches defined by the project build.yml, which should include main, chore/*, feat/*
  • Executes initial setup, then .mvnw compile, .mvn verify and then publishes the unit test results
Variable Description Type Required Default Input/Output
java-distribution The Java Distribution to use string false adopt-hotspot input
java-version The Java Version to use string false 8 input
include-test-results A flag to run publish-unit-test-result boolean false true input
version-project For use with multi-module projects, this is used to determine application version boolean false n/a input
gradle-args Gradle arguments appended to gradle calls string false n/a input
app-version The application version string n/a n/a output

gradle-release.yml

  • Only runs on the main branch
  • Executes initial setup, then runs JReleaser, and captures the JReleaser output.
Variable Description Type Required Default Input/Output
app-version Application version to release string true n/a input
java-distribution The Java Distribution to use string false adopt-hotspot input
java-version The Java Version to use string false 8 input
main-branch Main branch name, allows override for repos that still use ‘master’ string false main input
gradle-args Gradle arguments appended to gradle calls string false n/a input

Gradle release workflow requires the following Organization Secrets to be shared with the target repository :

  • JRELEASER_GPG_PASSPHRASE
  • JRELEASER_GPG_PUBLIC_KEY
  • JRELEASER_GPG_SECRET_KEY
  • MAVEN_GPG_PASSPHRASE
  • MAVEN_GPG_PRIVATE_KEY
  • OSSRH_PASSWORD
  • OSSRH_USERNAME

gradle-post-release.yml

  • Only runs on main branch, if the app-version does not include 'SNAPSHOT'
  • Executes initial setup, increments the version, then creates a pull request for the version changes
Variable Description Type Required Default Input/Output
app-version Application version that was released string true n/a input
java-distribution The Java Distribution to use string false adopt-hotspot input
java-version The Java Version to use string false 8 input
main-branch Main branch name, allows override for repos that still use ‘master’ string false main input
version-project For use with multi-module projects, this is used to determine application version boolean false n/a input
pr-reviewers Users to be included in the post-release pull request string false adesjardin, manikmagar, kkingavio input

python-build.yml

  • Runs on any branches defined by the project build.yml, which should include main, chore/*, feat/*
  • Executes initial setup, tests with pytest, and then publishes the unit test results
Variable Description Type Required Default Input/Output
python-version The Python Version to use string false 3.12 input
include-test-results A flag to publish unit test results boolean false true input
app-version The application version string n/a n/a output

python-release.yml

  • Only runs on the main branch
  • Executes downloads artifacts, then runs JReleaser, and captures the JReleaser output.
Variable Description Type Required Default Input/Output
app-version Application version to release string true n/a input
main-branch Main branch name, allows override for repos that still use ‘master’ string false main input

Python release workflow requires the following Organization Secrets to be shared with the target repository:

  • JRELEASER_GPG_PASSPHRASE
  • JRELEASER_GPG_PUBLIC_KEY
  • JRELEASER_GPG_SECRET_KEY

python-post-release.yml

  • Only runs on main branch, if the app-version does not include '.dev'
  • Executes initial setup, increments the patch version and adds .dev1, then creates a pull request for the version changes
Variable Description Type Required Default Input/Output
app-version Application version to release string true n/a input
python-version The Python Version to use string false 3.12 input
main-branch Main branch name, allows override for repos that still use ‘master’ string false main input
pr-reviewers Users to be included in the post-release pull request string false adesjardin, manikmagar, kkingavio input

Publish docs to GitHub Pages

Create/Add a .github/workflows/github-pages.yml file within the project.

# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
  # Runs on pushes targeting the default branch
  # Temporary on current branch
  push:
    branches:
      - main

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  Build-Maven:
    uses: avioconsulting/shared-workflows/.github/workflows/github-pages.yml@feat/add-github-pages
    secrets: inherit
    # with:
    #   java-distribution: temurin
    #   java-version: 8
    #   pages-directory: './target/docs'

About

A repository to store the Github Actions workflows

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5