-
Notifications
You must be signed in to change notification settings - Fork 8
56 lines (54 loc) · 2.14 KB
/
release-snapshot.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# 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 }}