Skip to content

Commit

Permalink
feat(ci): rename workflows, improve manual maven publish (#1450)
Browse files Browse the repository at this point in the history
* feat(ci): rename workflows, improve manual maven publish

* DEPENDENCIES

* add workflow_call triggers
  • Loading branch information
paullatzelsperger authored Jul 23, 2024
1 parent e5d11d1 commit 243d2b9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


---
name: "Create Docker images"
name: "Create and publish Docker images"

on:
workflow_dispatch:
Expand All @@ -33,14 +33,26 @@ on:
description: 'Explicitly specify the Docker tag. Note that SHA and latest are added automatically.'
required: false

workflow_call:
inputs:
namespace:
type: string
description: 'The namespace (=repo) in DockerHub'
required: false
default: "tractusx"
docker_tag:
type: string
description: 'Explicitly specify the Docker tag. Note that SHA and latest are added automatically.'
required: false

concurrency:
# cancel only running jobs on pull requests
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
create-docker-image:
name: "Create Docker Images for the ControlPlane"
name: "Build and push images"
runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,21 @@


---
name: "Manually publish Maven Artefacts to OSSRH"
name: "Publish Maven Artefacts to OSSRH"

on:
workflow_dispatch:
inputs:
version:
required: false
description: 'a semver string denoting the version. Append -SNAPSHOT for snapshots. If ommitted, the version is taken from gradle.properties'
description: 'a semver string denoting the version. Append -SNAPSHOT for snapshots. If omitted, the version is taken from gradle.properties'
workflow_call:
inputs:
version:
type: string
required: false
description: 'a semver string denoting the version. Append -SNAPSHOT for snapshots. If omitted, the version is taken from gradle.properties'


concurrency:
# cancel only running jobs on pull requests
Expand Down Expand Up @@ -58,12 +65,25 @@ jobs:
OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
OSSRH_USER: ${{ secrets.ORG_OSSRH_USERNAME }}
run: |-
if [ -z ${{ inputs.version }} ];
then
# check if version input was specified, else read from gradle.properties
if [ ! -z ${{ inputs.version }} ];
then
VERSION=${{ inputs.version }}
echo "Publishing using version from parameter: $VERSION"
else
VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')
echo "Publishing using version from gradle.properties: $VERSION"
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --no-parallel -Pversion=$VERSION -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase="${{ secrets.ORG_GPG_PASSPHRASE }}"
else
echo "Publishing using version from parameter: ${{ inputs.version }}"
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository --no-parallel -Pversion=${{ inputs.version }} -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase="${{ secrets.ORG_GPG_PASSPHRASE }}"
fi
# check if the version is a SNAPSHOT, and if not, append command to close staging repo
cmd=""
if [[ $VERSION != *-SNAPSHOT ]]
then
cmd="closeAndReleaseSonatypeStagingRepository";
fi
echo "Publishing Version $VERSION to Sonatype"
./gradlew publishToSonatype ${cmd} --no-parallel -Pversion=$VERSION -Psigning.gnupg.executable=gpg -Psigning.gnupg.passphrase="${{ secrets.ORG_GPG_PASSPHRASE }}"

0 comments on commit 243d2b9

Please sign in to comment.