97 lines
3.4 KiB
YAML
97 lines
3.4 KiB
YAML
name: Release the current version
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
paths:
|
|
- '.github/project.yaml'
|
|
|
|
env:
|
|
COMMON_MAVEN_OPTS: "-e -B --fae"
|
|
|
|
jobs:
|
|
release:
|
|
name: Execute the release
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout the code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Retrieve project metadata
|
|
uses: https://github.com/radcortez/project-metadata-action@main
|
|
id: metadata
|
|
with:
|
|
metadata-file-path: '.github/project.yaml'
|
|
local-file: true
|
|
|
|
- name: Validate current version
|
|
if: contains(steps.metadata.outputs.current-version, 'SNAPSHOT')
|
|
run: |
|
|
echo '::error::Cannot release a SNAPSHOT version.'
|
|
exit 1
|
|
|
|
- name: Validate next version
|
|
if: contains(steps.metadata.outputs.next-version, 'SNAPSHOT') == 'false'
|
|
run: |
|
|
echo '::error::Next development version should be a SNAPSHOT version.'
|
|
exit 1
|
|
|
|
- name: Set environment variables
|
|
run: |
|
|
echo "CURRENT_VERSION=${{steps.metadata.outputs.current-version}}" >> $GITHUB_ENV
|
|
echo "NEXT_VERSION=${{steps.metadata.outputs.next-version}}" >> $GITHUB_ENV
|
|
|
|
- name: Configure SSH and Git
|
|
env:
|
|
SSH_DIR: /root/.ssh
|
|
MAVEN_RELEASE_SSH_KEY: ${{ secrets.MAVEN_RELEASE_SSH_KEY }}
|
|
run: |
|
|
mkdir -p ${SSH_DIR}/
|
|
touch ${SSH_DIR}/known_hosts
|
|
ssh-keyscan -t rsa -p 2222 git-ssh.kvant.cloud >> ${SSH_DIR}/known_hosts
|
|
echo "${MAVEN_RELEASE_SSH_KEY}" | base64 -d >> ${SSH_DIR}/id_rsa
|
|
chmod 600 ${SSH_DIR}/id_rsa
|
|
git config --global user.name 'maven_release_technical_account'
|
|
git config --global user.email 'maven-release-bot@phoenix-technologies.ch'
|
|
git config --global commit.gpgsign true
|
|
git config --global gpg.format ssh
|
|
git config --global user.signingkey ${SSH_DIR}/id_rsa
|
|
|
|
- name: Set up JDK 21
|
|
uses: https://github.com/actions/setup-java@v4
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '21'
|
|
|
|
- name: Generate cache keys
|
|
id: cache-key
|
|
run: |
|
|
CURRENT_BRANCH="${{ github.ref_name }}"
|
|
CURRENT_MONTH=$(/bin/date -u "+%Y-%m")
|
|
CURRENT_DAY=$(/bin/date -u "+%d")
|
|
ROOT_CACHE_KEY="m2-cache-quarkus-commons"
|
|
echo "m2-monthly-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}" >> $GITHUB_OUTPUT
|
|
echo "m2-monthly-branch-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}" >> $GITHUB_OUTPUT
|
|
echo "m2-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}-${CURRENT_DAY}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Cache Maven Repository
|
|
id: cache-maven
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.m2/repository
|
|
# The cache is per branch but in case we don't find a branch for a given branch, we will get a cache from another branch.
|
|
key: ${{ steps.cache-key.outputs.m2-cache-key }}
|
|
restore-keys: |
|
|
${{ steps.cache-key.outputs.m2-monthly-branch-cache-key }}
|
|
${{ steps.cache-key.outputs.m2-monthly-cache-key }}
|
|
|
|
- name: Make maven wrapper executable
|
|
run: chmod +x mvnw
|
|
|
|
- name: Download dependencies
|
|
run: ./mvnw $COMMON_MAVEN_OPTS quarkus:go-offline
|
|
|
|
- name: Prepare release
|
|
run: ./mvnw $COMMON_MAVEN_OPTS release:prepare -DreleaseVersion=${CURRENT_VERSION} -DdevelopmentVersion=${NEXT_VERSION}
|