-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmvnw
More file actions
executable file
·60 lines (53 loc) · 2.2 KB
/
mvnw
File metadata and controls
executable file
·60 lines (53 loc) · 2.2 KB
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
#!/usr/bin/env bash
# mvnw wrapper to inject secrets env
# used in deploy script
# ref: https://jreleaser.org/guide/latest/examples/maven/maven-central.html#_maven
set -TCEeuo pipefail
# Define colors
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
if [ -z "$ORGANIZATION_PATH_NAME" ]; then
echo "ERROR: ORGANIZATION_PATH_NAME environment variable is not set"
exit 1
fi
# For release/snapshot
SONATYPE_USERNAME_PATH="$ORGANIZATION_PATH_NAME/sonatype/username"
if SONATYPE_USERNAME_VALUE=$(pass "$SONATYPE_USERNAME_PATH" 2> /dev/null); then
export JRELEASER_MAVENCENTRAL_USERNAME="$SONATYPE_USERNAME_VALUE"
# For snapshot
export JRELEASER_NEXUS2_USERNAME="${JRELEASER_MAVENCENTRAL_USERNAME}"
SONATYPE_PASSWORD_PATH="$ORGANIZATION_PATH_NAME/sonatype/password"
if SONATYPE_PASSWORD_VALUE=$(pass "$SONATYPE_PASSWORD_PATH" 2> /dev/null); then
export JRELEASER_MAVENCENTRAL_PASSWORD="$SONATYPE_PASSWORD_VALUE"
# For snapshot
export JRELEASER_NEXUS2_PASSWORD="${JRELEASER_MAVENCENTRAL_PASSWORD}"
else
echo -e "${RED}User $JRELEASER_MAVENCENTRAL_USERNAME found but no sonatype password found at $SONATYPE_PASSWORD_PATH${NC}"
exit 1
fi
else
echo -e "${YELLOW}Note: No maven central sonatype user found at: $SONATYPE_USERNAME_PATH${NC}"
fi
PASSPHRASE_PATH="$ORGANIZATION_PATH_NAME/gpg/software-signing-key-passphrase"
if ! PASSPHRASE_VALUE=$(pass "$PASSPHRASE_PATH" 2> /dev/null); then
echo -e "${YELLOW}Note: No gpg passphrase found at the pass path: $PASSPHRASE_PATH${NC}"
PASSPHRASE_VALUE="yolo"
fi
# JReleaser make it mandatory even if it's a command
export JRELEASER_GPG_PASSPHRASE="$PASSPHRASE_VALUE"
# Github
GITHUB_TOKEN_PATH="$ORGANIZATION_PATH_NAME/github/release-token"
if GITHUB_TOKEN_VALUE=$(pass "$GITHUB_TOKEN_PATH" 2> /dev/null); then
# for the docker upload
export JRELEASER_GITHUB_TOKEN="$GITHUB_TOKEN_VALUE"
export JRELEASER_DOCKER_GHCR_IO_PASSWORD="$GITHUB_TOKEN_VALUE"
else
echo -e "${YELLOW}Note: No github token found at the pass path: $GITHUB_TOKEN_PATH${NC}"
fi
# Run
# We select the second in path order
# Why? we get mvnw from the project.
# A third is really unlikely but who knows
# We take the second in order of priority
"$(which -a mvnw | sed -n '2p')" "$@"