-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
114 lines (96 loc) · 4.12 KB
/
action.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: CI Artifactory Build for Gradle
description: 'Builds the project with Gradle and Artifactory plugin.
If `releaseVersion` input is not provided, the SNAPSHOT is uploaded.
The buildName for build-info is based on the repository name and `releaseVersion` input if provided.
Otherwise the `github.ref_name` is used if it is not `main`.
When `github.ref_name` is `main`, the `version` is read from gradle.properties and last number is replaced with `x`.
The `ARTIFACTORY_USERNAME` and `ARTIFACTORY_PASSWORD` environment variables must be before using this action.'
inputs:
artifactoryUrl:
description: 'The Artifactory Server'
required: true
artifactoryUsername:
description: 'The Artifactory User'
required: true
artifactoryPassword:
description: 'The Artifactory Password'
required: true
targetRepository:
description: 'The Artifactory Repository to upload artifacts to'
required: true
artifactoryProjectKey:
description: 'The Artifactory project key'
required: false
gradleTasks:
description: 'Additional Gradle tasks. The `build` and `artifactoryPublish` are included.'
required: false
releaseVersion:
description: 'The optional release version. Otherwise builds SNAPSHOT'
required: false
gpgPrivateKey:
description: 'A PGP/GPG signing key that will be used to sign artifacts before they are deployed'
required: false
gpgPassphrase:
description: 'Passphrase of the signing key'
required: false
outputs:
buildName:
description: "The name of the build for Artifactory"
value: ${{ steps.build-name.outputs.buildName }}
buildNumber:
description: "The number of the build for Artifactory"
value: ${{ steps.build-name.outputs.buildNumber }}
runs:
using: composite
steps:
- name: Set up Gradle
uses: spring-io/spring-gradle-build-action@v2
- name: Set Release Version
if: inputs.releaseVersion
shell: bash
run: |
echo Set Release Version
sed -i "s/version=.*/version=${{ inputs.releaseVersion }}/" gradle.properties
- name: Build and Publish
id: build-and-publish
shell: bash
run: |
echo Build and Publish
cp spring-github-workflows/utils/*.gradle $HOME/.gradle/init.d
# See utils/deployment-repository-init.gradle
gradle clean build ${{ inputs.gradleTasks }} publishAllPublicationsToDeploymentRepository
env:
ARTIFACTORY_USERNAME: ${{ inputs.artifactoryUsername }}
ARTIFACTORY_PASSWORD: ${{ inputs.artifactoryPassword }}
- name: Evaluate Build Name
id: build-name
shell: bash
run: |
echo Evaluate Build Name
branchVersion=${{ github.ref_name }}
if [ $branchVersion = 'main' ]; then
snapshotVersion=$(cat gradle.properties | sed -n '/^version=/ { s/^version=//;p }')
branchVersion=${snapshotVersion%.*}.x
fi
buildName=${{ github.event.repository.name }}-$branchVersion${{ inputs.releaseVersion != '' && '-release' || '' }}
buildNumber=${{ github.run_number }}
echo buildName=$buildName >> $GITHUB_OUTPUT
echo buildNumber=$buildNumber >> $GITHUB_OUTPUT
echo "::notice title=Artifactory Build Name & Number::$buildName/$buildNumber"
- name: Deploy
uses: spring-io/artifactory-deploy-action@v0.0.1
with:
uri: ${{ inputs.artifactoryUrl == '' && 'https://repo.spring.io' || inputs.artifactoryUrl }}
project: ${{ inputs.artifactoryProjectKey }}
username: ${{ inputs.artifactoryUsername }}
password: ${{ inputs.artifactoryPassword }}
build-name: ${{ steps.build-name.outputs.buildName }}
repository: ${{ inputs.targetRepository == '' && 'libs-snapshot-local' || inputs.targetRepository }}
folder: 'deployment-repository'
artifact-properties: |
/**/*.zip::zip.name=${{ github.event.repository.name }},zip.deployed=false
/**/*docs.zip::zip.type=docs
/**/*dist.zip::zip.type=dist
threads: 10
signing-key: ${{ inputs.gpgPrivateKey }}
signing-passphrase: ${{ inputs.gpgPassphrase }}