Skip to content

maven-release

maven-release #18

Workflow file for this run

name: maven-release
env:
APP_PATH: ""
REGISTRY: ghcr.io
on:
workflow_dispatch:
inputs:
releaseVersion:
description: "Default version to use when preparing a release."
required: true
default: "X.Y.Z"
developmentVersion:
description: "Default version to use for new local working copy."
required: true
default: "X.Y.Z-SNAPSHOT"
jobs:
release:
runs-on: ubuntu-latest
outputs:
MVN_ARTIFACT_ID: ${{ steps.maven-release-step.outputs.MVN_ARTIFACT_ID }}
steps:
# Checkout source code, set up Java, etc. Then...
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
cache: "maven"
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Maven Release Step
id: maven-release-step
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
MVN_ARTIFACT_ID=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)
echo $MVN_ARTIFACT_ID
echo "MVN_ARTIFACT_ID=$MVN_ARTIFACT_ID" >> $GITHUB_OUTPUT
mvn release:prepare release:perform -B -DreleaseVersion=${{ github.event.inputs.releaseVersion }} -DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} -Darguments="-Dmaven.deploy.skip=true"
- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: target
path: "**/target"
retention-days: 5
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-image:
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download a single artifact
uses: actions/download-artifact@v4
with:
name: target
- name: Login to 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 }}${{ github.event.inputs.APP_PATH }}
tags: |
type=semver,pattern={{version}},value=${{ github.event.inputs.releaseVersion }}
- name: Build and push image
uses: docker/build-push-action@v4
with:
context: .${{ env.APP_PATH }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
create-github-release:
needs: release
runs-on: ubuntu-latest
steps:
- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{needs.release.outputs.MVN_ARTIFACT_ID}}-${{ github.event.inputs.releaseVersion }}
draft: false
prerelease: false
generate_release_notes: false