Skip to content

Commit

Permalink
Merge pull request #90 from MrSebastian/try-new-mvn-release
Browse files Browse the repository at this point in the history
mvn release
  • Loading branch information
MrSebastian authored Apr 7, 2024
2 parents f1792d1 + 2ac80c7 commit a10d9a9
Show file tree
Hide file tree
Showing 8 changed files with 280 additions and 79 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/callable-create-ghcr-image-from-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: callable build ghcr image from tag
on:
workflow_call:
inputs:
tag:
required: true
type: string
description: 'tag that is used for build'
service:
required: true
type: string
description: 'name of service to use'

env:
REGISTRY: ghcr.io

jobs:
publish-ghcr-image:
permissions:
packages: write
runs-on: ubuntu-latest
steps:

- name: Check out Git repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
cache: 'maven'
cache-dependency-path: ${{ inputs.service }}/pom.xml
java-version: '17'
distribution: 'temurin'

- name: build jar without tests
run: mvn -B -ntp -DskipTests package -f ${{ inputs.service }}/pom.xml

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}-${{ inputs.service }}
context: git
# tags:
# - Major
# - Major.Minor
# - full semver: 1.2.3
# - latest
tags: |
type=match,pattern=(${{ inputs.service }})/v(\d).\d.\d,group=2
type=match,pattern=(${{ inputs.service }})/v(\d.\d).\d,group=2
type=match,pattern=(${{ inputs.service }})/v(.*),group=2
type=raw,value=latest
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: ./${{ inputs.service }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
49 changes: 49 additions & 0 deletions .github/workflows/callable-create-release-from-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: callable build gh release from tag
on:
workflow_call:
inputs:
tag:
required: true
type: string
description: 'tag that is used for build'
service:
required: true
type: string
description: 'name of service to use'

env:
REGISTRY: ghcr.io

jobs:
create-gh-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:

- name: Check out Git repository
uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
cache: 'maven'
cache-dependency-path: '${{ inputs.service }}/pom.xml'
java-version: '17'
distribution: 'temurin'

- name: build jar without tests
run: mvn -B -ntp -DskipTests package -f ${{ inputs.service }}/pom.xml

- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
files: |
${{ inputs.service }}/target/*.jar
tag_name: ${{ inputs.tag }}
draft: false
prerelease: false
generate_release_notes: false
61 changes: 61 additions & 0 deletions .github/workflows/dispatch-maven-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: build maven release

on:
workflow_dispatch:
inputs:
release-version:
required: true
description: release version
development-version:
required: true
description: next development version
service:
required: true
description: service to build (backend, frontend, ...)

jobs:
prepare-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Setup git user
uses: fregante/setup-git-user@v2
- name: Install Java and Maven
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "temurin"
cache: 'maven'
cache-dependency-path: '${{ github.event.inputs.service }}/pom.xml'
- name: Perform maven release
run: >
mvn -B -ntp release:prepare -f backend/pom.xml
-DreleaseVersion=${{ github.event.inputs.release-version }}
-DdevelopmentVersion=${{ github.event.inputs.development-version }}
-Dtag=${{ github.event.inputs.service }}/v${{ github.event.inputs.release-version }}
-Darguments="-DskipTests"
build-gh-release:
permissions:
contents: write
needs:
- prepare-release
uses:
./.github/workflows/callable-create-release-from-tag.yml
with:
tag: ${{ github.event.inputs.service }}/v${{ github.event.inputs.release-version }}
service: ${{ github.event.inputs.service }}

build-ghcr-image:
permissions:
packages: write
needs:
- prepare-release
uses:
./.github/workflows/callable-create-ghcr-image-from-tag.yml
with:
tag: ${{ github.event.inputs.service }}/v${{ github.event.inputs.release-version }}
service: ${{ github.event.inputs.service }}
45 changes: 45 additions & 0 deletions .github/workflows/push-tag_create-ghcr-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: build ghcr image from tag

on:
push:
tags:
- "*/v*"

env:
REGISTRY: ghcr.io

jobs:
extract-service:
runs-on: ubuntu-latest
outputs:
service: ${{ steps.getTagNameParts.outputs.service }}
version: ${{ steps.getTagNameParts.outputs.version }}
tag: ${{ steps.getTagNameParts.outputs.tag }}
steps:
- uses: olegtarasov/[email protected]
id: getTagNameParts
with:
tagRegex: (?<service>.*)\/v(?<version>.*) #example: backend/v1.2.3
tagRegexGroup: 0

- name: show-service
env:
ghRef: ${{ github.ref }}
service: ${{ steps.getTagNameParts.outputs.service }}
version: ${{ steps.getTagNameParts.outputs.version }}
tagFromAction: ${{ steps.getTagNameParts.outputs.tag }}
run: |
echo "Ref: $ghRef"
echo "Service: $service"
echo "Version: $version"
echo "tagFromAction: $tagFromAction"
publish-ghcr-image:
permissions:
packages: write
needs:
- extract-service
uses: ./.github/workflows/callable-create-ghcr-image-from-tag.yml
with:
tag: ${{ needs.extract-service.outputs.service }}/v${{ needs.extract-service.outputs.version }}
service: ${{ needs.extract-service.outputs.service }}
45 changes: 45 additions & 0 deletions .github/workflows/push-tag_create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: build gh release from tag

on:
push:
tags:
- "*/v*"

env:
REGISTRY: ghcr.io

jobs:
extract-service:
runs-on: ubuntu-latest
outputs:
service: ${{ steps.getTagNameParts.outputs.service }}
version: ${{ steps.getTagNameParts.outputs.version }}
tag: ${{ steps.getTagNameParts.outputs.tag }}
steps:
- uses: olegtarasov/[email protected]
id: getTagNameParts
with:
tagRegex: (?<service>.*)\/v(?<version>.*) #example: backend/v1.2.3
tagRegexGroup: 0

- name: show-service
env:
ghRef: ${{ github.ref }}
service: ${{ steps.getTagNameParts.outputs.service }}
version: ${{ steps.getTagNameParts.outputs.version }}
tagFromAction: ${{ steps.getTagNameParts.outputs.tag }}
run: |
echo "Ref: $ghRef"
echo "Service: $service"
echo "Version: $version"
echo "tagFromAction: $tagFromAction"
publish-ghcr-image:
permissions:
contents: write
needs:
- extract-service
uses: ./.github/workflows/callable-create-release-from-tag.yml
with:
tag: ${{ needs.extract-service.outputs.service }}/v${{ needs.extract-service.outputs.version }}
service: ${{ needs.extract-service.outputs.service }}
18 changes: 0 additions & 18 deletions .github/workflows/release_workflow.yml

This file was deleted.

56 changes: 0 additions & 56 deletions .github/workflows/reuse-release-workflow.yml

This file was deleted.

15 changes: 10 additions & 5 deletions backend/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.mrsebastian.todoappdemo</groupId>
Expand Down Expand Up @@ -39,6 +37,13 @@
<mapstruct.version>1.5.5.Final</mapstruct.version>
</properties>

<scm>
<connection>scm:git:${project.scm.url}.git</connection>
<developerConnection>scm:git:${project.scm.url}.git</developerConnection>
<url>https://github.com/MrSebastian/TodoAppOSSDemo</url>
<tag>HEAD</tag>
</scm>

<distributionManagement>
<repository>
<id>github</id>
Expand Down Expand Up @@ -415,8 +420,8 @@
<eclipse>
<file>itm-java-codeformat/java_codestyle_formatter.xml</file>
</eclipse>
<trimTrailingWhitespace/>
<endWithNewline/>
<trimTrailingWhitespace />
<endWithNewline />
</java>
</configuration>
<executions>
Expand Down

0 comments on commit a10d9a9

Please sign in to comment.