Skip to content

5th try to release via GitHub actions to Maven Central #5

5th try to release via GitHub actions to Maven Central

5th try to release via GitHub actions to Maven Central #5

Workflow file for this run

name: CI/CD Spring Test Initializers
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build:
name: Build and Release
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15.4-alpine3.18
env:
POSTGRES_USER: ci-user
POSTGRES_PASSWORD: ci-pass
POSTGRES_DB: testsupport
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Set up Maven cache
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Wait for PostgreSQL to start
run: sleep 10
- name: Check PostgreSQL availability
run: ping -c 1 -W 5 postgres >/dev/null || { echo "Server is not reachable."; exit 1; }
- name: Build
run: mvn -B -ntp clean install
env:
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
POSTGRES_USER: ci-user
POSTGRES_PASSWORD: ci-pass
POSTGRES_DB: testsupport
- name: Release
if: >
github.event.release &&
github.ref_name == 'main'
run: |
git config --global user.email "[email protected]"
git config --global user.name "DenktMit eG"
mvn -Drevision=${{ github.event.release.tag_name }} -Dchangelist= -B -ntp -DskipTests -Pci-cd
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}