Skip to content

Commit

Permalink
Refactor/ci split modules (#118)
Browse files Browse the repository at this point in the history
* 👷 rename integrations label

* ♻️ ci split build for modules

* 🔥 rm root pom

* 👷 ci release mak snapshot no default

* 👷 ci labeler add refactoring to maintenance

* 👷 ci build always

* 👷 ci split release note by module

* ♻️ ci extract build image to separate action

* ♻️ ci extract build image to separate action

* ♻️ ci split build for modules

* 👷 ci image build default registry

* ♻️ ci extract maven build to action

* ♻️ ci extract maven build to action use

* 🐛 ci mv checkout from action to workflow

* 🐛 ci maven build action fix typo

* 🐛 ci maven build action fix typo

* 💡 ci add names for used actions

* 🐛 ci maven build action bool as string

* ➕ gateway add maven-release-plugin

* 🐛 gateway skip deploy
  • Loading branch information
simonhir authored Sep 3, 2024
1 parent 4c93bd4 commit 97c5089
Show file tree
Hide file tree
Showing 11 changed files with 414 additions and 210 deletions.
58 changes: 58 additions & 0 deletions .github/actions/build-image/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: build-image
description: "Builds and pushes a docker image"

inputs:
registry:
description: "Image registry to push image to"
required: true
default: ghcr.io
registry-username:
description: "Username to authenticate against image registry"
required: true
registry-password:
description: "Password to authenticate against image registry"
required: true
path:
description: "Path to the Dockerfile to build image from"
required: true
image-name:
description: "Name to give the image"
required: true
image-tags:
description: "Tags to tag image with"
required: false
default: |
type=raw,value=latest
image-labels:
description: "Labels to add to image"
required: false
default: |
org.opencontainers.image.description=See ${{ github.server_url }}/${{ github.repository }}
runs:
using: "composite"
steps:
- name: Download a single artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: target
- name: Login to Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.registry-username }}
password: ${{ inputs.registry-password }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: "${{ inputs.registry }}/${{ github.repository }}/${{ inputs.image-name }}"
tags: ${{inputs.image-tags}}
labels: ${{inputs.image-labels}}
- name: Build and push image
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0
with:
context: ./${{ inputs.path }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
101 changes: 101 additions & 0 deletions .github/actions/build-maven/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: ""
description: ""

inputs:
module:
description: 'Module to build'
required: true
release:
description: 'Release?'
default: 'false'
release-version:
description: 'Release version'
required: false
default: "X.Y.Z"
next-version:
description: "Next version to use after release"
required: false
default: "X.Y.Z-SNAPSHOT"
java-version:
description: "Jave version used for building"
required: false
default: "21"
gpg-private-key:
description: "Gpg private key used for signing packages for maven central release"
required: false
gpg-passphrase:
description: "Gpg passphrase for private key"
required: false
sonatype-username:
description: "Sonatype username for maven central release"
required: false
sonatype-password:
description: "Sonatype password for maven central release"
required: false

runs:
using: "composite"
steps:
- name: Set up JDK
uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2
with:
java-version: ${{ inputs.java-version }}
distribution: "temurin"
cache: "maven"
cache-dependency-path: "./${{ inputs.module }}/pom.xml"
server-id: "central"
server-username: CENTRAL_USERNAME
server-password: CENTRAL_PASSWORD
gpg-private-key: ${{ inputs.gpg-private-key }}
gpg-passphrase: SIGN_KEY_PASS
- name: Maven build
if: ${{ inputs.release != 'true' }}
shell: bash
run: mvn -f ./${{ inputs.module }}/pom.xml --batch-mode clean install
- name: Maven release
if: ${{ inputs.release == 'true' }}
shell: bash
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
mvn release:prepare -f ./${{ inputs.module }}/pom.xml -B -DreleaseVersion=${{ inputs.release-version }} -DdevelopmentVersion=${{ inputs.next-version }} -DpushChanges=false -DremoteTagging=false
mvn release:perform -f ./${{ inputs.module }}/pom.xml -DlocalCheckout=true
env:
SIGN_KEY_PASS: ${{ inputs.gpg-passphrase }}
CENTRAL_USERNAME: ${{ inputs.sonatype-username }}
CENTRAL_PASSWORD: ${{ inputs.sonatype-password }}
- name: "Upload target artifacts"
uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
with:
name: target
path: "**/target"
retention-days: 5
- name: Push changes to new branch
if: ${{ inputs.release == 'true' }}
shell: bash
run: |
git checkout -b ${{ github.ref_name }}-version-bump
git push --force origin ${{ github.ref_name }}-version-bump
- name: Create pull request
if: ${{ inputs.release == 'true' }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const { repo, owner } = context.repo;
const pullResult = await github.rest.pulls.create({
title: 'chore: bump release version ${{ github.ref_name }}',
owner,
repo,
head: '${{ github.ref_name }}-version-bump',
base: '${{ github.ref_name }}',
body: [
'This PR is auto-generated'
].join('\n')
});
await github.rest.issues.addAssignees({
owner,
repo,
issue_number: pullResult.data.number,
assignees: ['${{ github.actor }}'],
});
console.log(`Pull Request created: ${pullResult.data.html_url}`);
12 changes: 6 additions & 6 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@
"Type: Bug":
- head-branch: [ '^bug', 'bug' ]
"Type: Maintenance":
- head-branch: [ '^maint', 'maintenance' ]
- head-branch: [ '^maint', 'maintenance', '^refact' ]
"Type: Documentation":
- head-branch: [ '^docs', "documentation" ]
- changed-files:
- any-glob-to-any-file: ['docs/**']
- any-glob-to-any-file: [ 'docs/**' ]
"Type: Dependency":
- head-branch: [ '^dep', 'dependency' ]
"Type: Security":
- head-branch: [ '^sec', 'security' ]
"Component: API-Gateway":
- changed-files:
- any-glob-to-any-file: ['refarch-gateway/**']
"Component: Integration":
- any-glob-to-any-file: [ 'refarch-gateway/**' ]
"Component: Integrations":
- changed-files:
- any-glob-to-any-file: ['refarch-integrations/**']
- any-glob-to-any-file: [ 'refarch-integrations/**' ]
"Component: CLI":
- changed-files:
- any-glob-to-any-file: ['refarch-cli/**']
- any-glob-to-any-file: [ 'refarch-cli/**' ]
93 changes: 85 additions & 8 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,100 @@
changelog:
categories:
- title: 🎉 New Features
# refarch-gateway
- title: Gateway - 🎉 New Features
labels:
- "Type: Feature"
- title: 🐞 Bug Fixes
exclude: &filter-gateway
labels:
- "Component: Integrations"
- "Component: CLI"
- title: Gateway - 🐞 Bug Fixes
labels:
- "Type: Bug"
- title: 🔨 Maintenance
exclude: *filter-gateway
- title: Gateway - 🔨 Maintenance
labels:
- "Type: Maintenance"
- title: 📔 Documentation
exclude: *filter-gateway
- title: Gateway - 📔 Documentation
labels:
- "Type: Documentation"
- title: ⬆️ Dependency Upgrades
exclude: *filter-gateway
- title: Gateway - ⬆️ Dependency Upgrades
labels:
- "Type: Dependency"
- title: 🔒️ Security
exclude: *filter-gateway
- title: Gateway - 🔒️ Security
labels:
- "Type: Security"
- title: 💥 Breaking Changes
exclude: *filter-gateway
- title: Gateway - 💥 Breaking Changes
labels:
- BREAKING
- BREAKING
exclude: *filter-gateway

# refarch-integrations
- title: Integrations - 🎉 New Features
labels:
- "Type: Feature"
exclude: &filter-integrations
labels:
- "Component: API-Gateway"
- "Component: CLI"
- title: Integrations - 🐞 Bug Fixes
labels:
- "Type: Bug"
exclude: *filter-integrations
- title: Integrations - 🔨 Maintenance
labels:
- "Type: Maintenance"
exclude: *filter-integrations
- title: Integrations - 📔 Documentation
labels:
- "Type: Documentation"
exclude: *filter-integrations
- title: Integrations - ⬆️ Dependency Upgrades
labels:
- "Type: Dependency"
exclude: *filter-integrations
- title: Integrations - 🔒️ Security
labels:
- "Type: Security"
exclude: *filter-integrations
- title: Integrations - 💥 Breaking Changes
labels:
- BREAKING
exclude: *filter-integrations

# refarch-cli
- title: CLI - 🎉 New Features
labels:
- "Type: Feature"
exclude: &filter-cli
labels:
- "Component: API-Gateway"
- "Component: Integrations"
- title: CLI - 🐞 Bug Fixes
labels:
- "Type: Bug"
exclude: *filter-cli
- title: CLI - 🔨 Maintenance
labels:
- "Type: Maintenance"
exclude: *filter-cli
- title: CLI - 📔 Documentation
labels:
- "Type: Documentation"
exclude: *filter-cli
- title: CLI - ⬆️ Dependency Upgrades
labels:
- "Type: Dependency"
exclude: *filter-cli
- title: CLI - 🔒️ Security
labels:
- "Type: Security"
exclude: *filter-cli
- title: CLI - 💥 Breaking Changes
labels:
- BREAKING
exclude: *filter-cli
15 changes: 0 additions & 15 deletions .github/workflows/build.yaml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/build_gateway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: build-gateway

on:
pull_request:
push:
branches:
- main

jobs:
build-maven:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Maven build
uses: ./.github/actions/build-maven
with:
module: refarch-gateway

build-images:
if: github.ref_name == 'main'
needs: build-maven
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Build and push image
uses: ./.github/actions/build-image
with:
registry-username: ${{ github.actor }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
path: ./refarch-gateway
image-name: refarch-gateway
image-tags: |
type=raw,value=dev
40 changes: 40 additions & 0 deletions .github/workflows/build_integrations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: build-integrations

on:
pull_request:
push:
branches:
- main

jobs:
build-maven:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Maven build
uses: ./.github/actions/build-maven
with:
module: refarch-integrations

build-images:
if: github.ref_name == 'main'
needs: build-maven
runs-on: ubuntu-latest
strategy:
matrix:
include:
- name: s3-integration-rest-service
path: ./refarch-integrations/refarch-s3-integration/refarch-s3-integration-rest/refarch-s3-integration-rest-service
steps:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Build and push image
uses: ./.github/actions/build-image
with:
registry-username: ${{ github.actor }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
path: ${{ matrix.path }}
image-name: ${{ matrix.name }}
image-tags: |
type=raw,value=dev
Loading

0 comments on commit 97c5089

Please sign in to comment.