Skip to content

Commit b7059a2

Browse files
committed
fix: review issues; pass params as action_envs
1 parent 85f4027 commit b7059a2

File tree

5 files changed

+30
-22
lines changed

5 files changed

+30
-22
lines changed

.github/workflows/publish.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ jobs:
2121
- name: Publish package
2222
run: |
2323
bazel run \
24-
--define signing_key=${PGP_SECRET} \
25-
--define signing_passwd=${PGP_PASSPHRASE} \
26-
--define sonatype_token=$(printf $SONATYPE_USERNAME:$SONATYPE_PASSWORD | base64 -w0) \
27-
//server/install:publish
24+
//server/install:publish \
25+
--action_env=SONATYPE_USERNAME \
26+
--action_env=SONATYPE_PASSWORD \
27+
--action_env=SONATYPE_SIGNING_KEY \
28+
--action_env=SONATYPE_SIGNING_KEY_PASSWORD
2829
env:
2930
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
3031
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
31-
PGP_PASSPHRASE: $${{ secrets.PGP_PASSPHRASE }}
32-
PGP_SECRET: $${{ secrets.PGP_SECRET }}
32+
SONATYPE_SIGNING_KEY: $${{ secrets.PGP_SECRET }}
33+
SONATYPE_SIGNING_KEY_PASSWORD: $${{ secrets.PGP_PASSPHRASE }}

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ bazel_dep(name = "ape", version = "1.0.1")
1010
bazel_dep(name = "rules_shell", version = "0.5.0")
1111

1212
cosmos = use_extension("@ape//ape/cosmos:defs.bzl", "ape_cosmos")
13-
use_repo(cosmos, "curl", "md5sum", "sha1sum", "sha256sum", "sha512sum")
13+
use_repo(cosmos, "base64", "curl", "echo", "md5sum", "sha1sum", "sha256sum", "sha512sum")
1414

1515
register_toolchains(
1616
"//:kotlin_toolchain",

rules/publishing/MavenSigning.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public class MavenSigning {
3737

3838
public static void main(String[] args) {
3939
var toSign = Paths.get(System.getenv("MAVEN_SIGNING_TOSIGN"));
40-
var pass = System.getenv("MAVEN_SIGNING_PASSWD").strip();
41-
var key = System.getenv("MAVEN_SIGNING_KEY").strip();
40+
var pass = System.getenv("SONATYPE_SIGNING_KEY_PASSWORD").strip();
41+
var key = System.getenv("SONATYPE_SIGNING_KEY").strip();
4242
var output = Paths.get(System.getenv("MAVEN_SIGNING_OUTPUT_PATH"));
4343
Path result = null;
4444
try {

rules/publishing/publish_sonatype.bzl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,29 +101,31 @@ def publish_sonatype(
101101
tags = ["manual"],
102102
)
103103

104+
data = [
105+
"@curl",
106+
"@echo",
107+
"@base64",
108+
":{}_bundle".format(name),
109+
]
110+
104111
expand_template_rule(
105112
name = "{}.sh".format(name),
106-
data = [
107-
"@curl",
108-
":{}_bundle".format(name),
109-
],
113+
data = data,
110114
out = "{}_upload.sh".format(name),
111115
is_executable = True,
112116
substitutions = {
113117
"{CURL}": "$(rootpath @curl)",
118+
"{ECHO}": "$(rootpath @echo)",
119+
"{BASE64}": "$(rootpath @base64)",
114120
"{BUNDLE}": "$(rootpath :{}_bundle)".format(name),
115-
"{SONATYPE_TOKEN}": "$(sonatype_token)",
116121
},
117122
template = "//rules/publishing:upload.sh.tpl",
118123
tags = ["manual"],
119124
)
120125

121126
sh_binary(
122127
name = name,
123-
data = [
124-
"@curl",
125-
":{}_bundle".format(name),
126-
],
128+
data = data,
127129
srcs = [":{}.sh".format(name)],
128130
tags = ["manual"],
129131
)
@@ -154,8 +156,6 @@ def _sign(
154156
srcs = [artifact],
155157
outs = [out],
156158
cmd = """
157-
MAVEN_SIGNING_KEY=$(signing_key) \
158-
MAVEN_SIGNING_PASSWD=$(signing_passwd) \
159159
MAVEN_SIGNING_TOSIGN=$(location {}) \
160160
MAVEN_SIGNING_OUTPUT_PATH=$(location {}) \
161161
$(location //rules/publishing:pgp_signer)""".format(artifact, out),

rules/publishing/upload.sh.tpl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#!/usr/bin/env bash
22

3+
if [[ -z "${SONATYPE_USERNAME}" || -z ${SONATYPE_PASSWORD} ]]; then
4+
echo "Missing SONATYPE_PASSWORD and/or SONATYPE_USERNAME envs. Exiting with error." 1>&2
5+
exit -1
6+
fi
7+
8+
SONATYPE_TOKEN=$({ECHO} -n $SONATYPE_USERNAME:$SONATYPE_PASSWORD | {BASE64} -w0)
9+
310
{CURL} \
411
--request POST \
5-
--verbose \
6-
--header 'Authorization: Bearer {SONATYPE_TOKEN}' \
12+
--silent \
13+
--header 'Authorization: Bearer ${SONATYPE_TOKEN}' \
714
--form bundle=@{BUNDLE} \
815
https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC

0 commit comments

Comments
 (0)