Skip to content

Release job

Release job #76

Workflow file for this run

name: Release job
on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'Release version'
required: true
nextVersion:
description: 'Next version'
required: true
jobs:
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' || startsWith(github.ref_name, 'hotfix')
steps:
- name: Checkout
uses: actions/checkout@v4.2.2
- name: Set up JDK 21
uses: actions/setup-java@v4.5.0
with:
java-version: 21
distribution: 'temurin'
- name: Change Maven version to release version
run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ github.event.inputs.releaseVersion }}
- name: Build with Maven
run: mvn --batch-mode -Pdefault,coverage install
- name: Run SonarCloud analysis
run: >
mvn --batch-mode -DskipTests sonar:sonar
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.organization=farao-community
-Dsonar.projectKey=farao-community_gridcapa-cse
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Commit and tag release version
uses: stefanzweifel/git-auto-commit-action@master
with:
branch: release-v${{ github.event.inputs.releaseVersion }}
create_branch: true
commit_message: Prepare release ${{ github.event.inputs.releaseVersion }}
tagging_message: v${{ github.event.inputs.releaseVersion }}
- name: Release Maven package
uses: samuelmeuli/action-maven-publish@v1.4.0
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
nexus_username: ${{ secrets.NEXUS_USERNAME }}
nexus_password: ${{ secrets.NEXUS_PASSWORD }}
maven_profiles: default,release
- name: Re-build with Maven to avoid multiple .jar achives
run: mvn --batch-mode -Pdefault,coverage clean install
- name: Build and publish Docker image for import corner
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: farao/gridcapa-cse-cc-import-runner
username: farao
password: ${{ secrets.DOCKERHUB_TOKEN }}
dockerfile: ImportDockerfile
tags: v${{ github.event.inputs.releaseVersion }}
- name: Build and publish Docker image for export corner
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: farao/gridcapa-cse-cc-export-runner
username: farao
password: ${{ secrets.DOCKERHUB_TOKEN }}
dockerfile: ExportDockerfile
tags: v${{ github.event.inputs.releaseVersion }}
- name: Change Maven version to next version
run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT
- name: Commit next version
uses: stefanzweifel/git-auto-commit-action@master
with:
branch: next-release-v${{ github.event.inputs.nextVersion }}
create_branch: true
commit_message: Prepare next release ${{ github.event.inputs.nextVersion }}
skip_fetch: true
skip_checkout: true
- name: Merge automatically into source branch
uses: devmasx/merge-branch@master
with:
type: now
from_branch: next-release-v${{ github.event.inputs.nextVersion }}
target_branch: ${{ github.ref_name }}
message: Automatic merge after release ${{ github.event.inputs.releaseVersion }}
github_token: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Delete merged branch
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branches: next-release-v${{ github.event.inputs.nextVersion }},release-v${{ github.event.inputs.releaseVersion }}