refactor(EWT-361): Workflows review #730
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reusable workflow to release to Nexus snapshot repository, referenced by workflow-*.yml pipelines. | |
name: Release to Nexus snapshots repository | |
on: | |
workflow_call: | |
inputs: | |
checkout_ref: | |
description: 'The reference to checkout before running the acceptance tests. Used to run the tests on a fork.' | |
required: true | |
type: string | |
project_version: | |
description: "The project version" | |
required: true | |
type: string | |
secrets: | |
sonatype_username: | |
required: true | |
sonatype_password: | |
required: true | |
jobs: | |
release-snapshot: | |
name: Release to Nexus snapshots repository | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.checkout_ref }} | |
- name: Setup JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: 'gradle' | |
- name: Validate Gradle wrapper | |
uses: gradle/wrapper-validation-action@v1 | |
- name: Create Snapshot version | |
run: | | |
CHECKOUT_REF=${{inputs.checkout_ref}} | |
STRIPPED_CHECKOUT_REF=${CHECKOUT_REF##*/} | |
echo "stripped_checkout_ref=$STRIPPED_CHECKOUT_REF" >> $GITHUB_ENV | |
echo "project_version_snapshot=${{inputs.project_version}}-$STRIPPED_CHECKOUT_REF-SNAPSHOT" >> $GITHUB_ENV | |
echo "Snapshot project version created: ${{env.project_version_snapshot}}" | |
- name: Snapshot version check | |
run: | | |
SNAPSHOT_VERSION_REGEX="^([0-9]+)\.([0-9]+)\.([0-9]+)-${{env.stripped_checkout_ref}}-SNAPSHOT$"; | |
if [[ "${{env.project_version_snapshot}}" =~ $SNAPSHOT_VERSION_REGEX ]]; then | |
echo "Project version ${{env.project_version_snapshot}} is valid" | |
else | |
echo "Project version ${{env.project_version_snapshot}} is not valid"; exit 1; | |
fi | |
- name: Publish to Sonatype snapshot repository | |
run: ./gradlew -Pversion=${{env.project_version_snapshot}} publishToSonatype | |
env: | |
SONATYPE_USERNAME: ${{ secrets.sonatype_username }} | |
SONATYPE_PASSWORD: ${{ secrets.sonatype_password }} |