-
Notifications
You must be signed in to change notification settings - Fork 6
79 lines (76 loc) · 3.11 KB
/
deploy-artifacts.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Deploy Artifacts
on:
workflow_call:
inputs:
should-deploy-artifacts:
description: Whether artifacts should be deployed.
required: true
type: string
outputs:
artifacts-deployed:
description: Whether artifacts were actually deployed.
value: ${{ jobs.deploy-artifacts.outputs.artifacts-deployed }}
project-version:
description: The project version extracted from the current branch/tag.
value: ${{ jobs.deploy-artifacts.outputs.project-version }}
secrets:
DEVELOCITY_ACCESS_KEY:
required: false
ARTIFACTORY_USERNAME:
required: false
ARTIFACTORY_PASSWORD:
required: false
OSSRH_S01_TOKEN_USERNAME:
required: false
OSSRH_S01_TOKEN_PASSWORD:
required: false
GPG_PRIVATE_KEY:
required: false
GPG_PASSPHRASE:
required: false
env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
OSSRH_TOKEN_USERNAME: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }}
OSSRH_TOKEN_PASSWORD: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }}
jobs:
deploy-artifacts:
name: Deploy Artifacts
if: ${{ inputs.should-deploy-artifacts == 'true' }}
runs-on: ubuntu-latest
outputs:
artifacts-deployed: ${{ steps.artifacts-deployed.outputs.result }}
project-version: ${{ steps.project-version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: spring-io/spring-gradle-build-action@v2
- id: project-version
name: Extract Project Version
run: echo "version=$(cat gradle.properties | grep 'version=' | awk -F'=' '{print $2}')" >> $GITHUB_OUTPUT
- id: branch-name
name: Extract Branch Name
env:
BRANCH: ${{ github.ref_name }}
VERSION: ${{ steps.project-version.outputs.version }}
run: |
branch=$BRANCH
if [[ "$branch" = "main" ]] ; then
branch="${VERSION%.*}.x"
fi
echo "branch=$branch" >> $GITHUB_OUTPUT
- name: Deploy Artifacts
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}
ARTIFACTORY_BUILD_NAME: ${{ github.event.repository.name }}-${{ steps.branch-name.outputs.branch }}
ARTIFACTORY_BUILD_NUMBER: ${{ github.run_id }}
ARTIFACTORY_BUILD_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
ARTIFACTORY_USER_AGENT_NAME: GitHub Actions
ARTIFACTORY_USER_AGENT_VERSION: Unknown
ARTIFACTORY_VCS_REVISION: ${{ github.sha }}
run: ./gradlew publishArtifacts finalizeDeployArtifacts -PossrhUsername="$OSSRH_TOKEN_USERNAME" -PossrhPassword="$OSSRH_TOKEN_PASSWORD" -PartifactoryUsername="$ARTIFACTORY_USERNAME" -PartifactoryPassword="$ARTIFACTORY_PASSWORD" --stacktrace
- id: artifacts-deployed
name: Artifacts Deployed
run: echo "result=true" >> $GITHUB_OUTPUT