-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ryan Northey <[email protected]>
- Loading branch information
Showing
10 changed files
with
279 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
rootDir: /opt/build/cache/aptly | ||
FileSystemPublishEndpoints: | ||
public: | ||
rootDir: /opt/build/repo/repository | ||
rootDir: /opt/build/cache/html | ||
linkMethod: symlink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
|
||
common --color=yes | ||
common --action_env=APT_ROOT=apt | ||
common --host_action_env=APT_ROOT=apt | ||
|
||
common:ci --noshow_progress | ||
common:ci --noshow_loading_progress | ||
common:ci --test_output=errors | ||
common:ci --//:aptly-custom=//:.aptly-ci-override | ||
common:ci --action_env=APT_ROOT=/opt/build/cache | ||
common:ci --host_action_env=APT_ROOT=/opt/build/cache | ||
|
||
common:debs-ci --config=ci | ||
common:debs-ci --//debs:excludes=//debs:custom-excludes.txt | ||
# common:debs-ci --//debs:token=//debs:token.txt | ||
|
||
common:publish-ci --config=debs-ci | ||
common:publish-ci --//tools/tarball:target=//:html | ||
common:publish-ci --//tools/tarball:overwrite=//tools/tarball:true | ||
common:publish-ci --//debs:signing-token=//debs:signing-token.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,27 @@ exports_files([ | |
"envoy-maintainers-public.key", | ||
]) | ||
|
||
filegroup( | ||
name = "true", | ||
srcs = [], | ||
) | ||
|
||
filegroup( | ||
name = "false", | ||
srcs = [], | ||
) | ||
|
||
label_flag( | ||
name = "production", | ||
build_setting_default = ":false", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
config_setting( | ||
name = "production_build", | ||
flag_values = {":production": ":true"}, | ||
) | ||
|
||
# gazelle:prefix github.com/aptly-dev/aptly | ||
gazelle(name = "gazelle") | ||
|
||
|
@@ -91,3 +112,33 @@ jq( | |
.[0] * .[1] | ||
""", | ||
) | ||
|
||
HTML_BUILD_CMD = """ | ||
export APTLY_BIN="$(location @aptly)" | ||
export MAINTAINER_KEY="$(location //:envoy-maintainers-public.key)" | ||
export APTLY_CONF="$(location //:aptly-config)" | ||
export DEBS="$(location //debs)" | ||
export DEBS_ROOT="$${APT_ROOT}/repository" | ||
export SIGNING_TOKEN="$(location //debs:signing-token)" | ||
$(location //debs:publish) | ||
tar xf $(location //site) -C $${APT_ROOT}/html | ||
tar hcf $@ -C $${APT_ROOT}/html . | ||
""" | ||
|
||
genrule( | ||
name = "html", | ||
outs = ["html.tar.gz"], | ||
cmd = select({ | ||
":production_build": "export SIGNING_KEY=\"Envoy maintainers <[email protected]>\"", | ||
"//conditions:default": "export SIGNING_KEY=\"[email protected]\"", | ||
}) + HTML_BUILD_CMD, | ||
tools = [ | ||
"@aptly", | ||
"//:aptly-config", | ||
"//:envoy-maintainers-public.key", | ||
"//debs", | ||
"//debs:publish", | ||
"//debs:signing-token", | ||
"//site", | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,15 @@ NORMAL="\e[0m" | |
|
||
EXCLUDE_FILE=debs/custom-excludes.txt | ||
DEBS_ROOT=/opt/build/cache/repository | ||
SIGNING_KEY_PASSPHRASE="${SIGNING_KEY_PASSPHRASE:-Hackme}" | ||
|
||
|
||
finally () { | ||
rm -rf signing.key | ||
rm -rf debs/signing-token.txt | ||
} | ||
|
||
trap finally EXIT | ||
|
||
bold () { | ||
echo -n "${BOLD}${*}${NORMAL}" | ||
|
@@ -34,6 +43,57 @@ create_excludes () { | |
fi | ||
} | ||
|
||
import_public_key | ||
create_excludes | ||
bazel run --config=debs-ci //debs:publish | ||
generate_private_key () { | ||
echo -e "$(underline $(bold "Generate snakeoil private key: repository signing"))" | ||
gpg --batch --pinentry-mode loopback --passphrase "" --gen-key <<EOF | ||
%echo Generating a basic OpenPGP key | ||
Key-Type: 1 | ||
Key-Length: 4096 | ||
Subkey-Type: 1 | ||
Subkey-Length: 4096 | ||
Name-Real: Envoy CI | ||
Name-Email: [email protected] | ||
Expire-Date: 0 | ||
Passphrase: ${SIGNING_KEY_PASSPHRASE} | ||
%commit | ||
%echo done | ||
EOF | ||
} | ||
|
||
import_private_key () { | ||
echo -e "$(underline $(bold "Import maintainers private signing key: repository signing"))" | ||
echo "${SIGNING_KEY_0}${SIGNING_KEY_1}${SIGNING_KEY_2}${SIGNING_KEY_3}" | base64 -d > signing.key | ||
gpg --batch --pinentry-mode loopback --import signing.key | ||
} | ||
|
||
create_excludes () { | ||
if [[ -e "${DEBS_ROOT}" ]]; then | ||
ls "${DEBS_ROOT}" \ | ||
| (grep -E '^v[0-9]+\.[0-9]+\.[0-9]+' || echo '') \ | ||
| sort -u > debs/custom-excludes.txt | ||
else | ||
touch debs/custom-excludes.txt | ||
fi | ||
} | ||
|
||
main () { | ||
local bazel_args=(--config=publish-ci) | ||
import_public_key | ||
create_excludes | ||
echo "${SIGNING_KEY_PASSPHRASE}" > debs/signing-token.txt | ||
if [[ "$CONTEXT" == "deploy-preview" ]]; then | ||
import_private_key | ||
# generate_private_key | ||
else | ||
import_private_key | ||
bazel_args+=(--//:production=//:true) | ||
fi | ||
bazel run \ | ||
"${bazel_args[@]}" \ | ||
//tools/tarball:unpack \ | ||
/opt/build/repo/html | ||
} | ||
|
||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | ||
main | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,35 @@ MAINTAINER = "Envoy maintainers <[email protected]>" | |
exports_files([ | ||
"custom-excludes.txt", | ||
"token.txt", | ||
"signing-token.txt", | ||
]) | ||
|
||
genrule( | ||
name = "empty", | ||
outs = ["empty.txt"], | ||
cmd = """ | ||
touch $@ | ||
""", | ||
) | ||
|
||
label_flag( | ||
name = "excludes", | ||
build_setting_default = ":empty", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
label_flag( | ||
name = "token", | ||
build_setting_default = ":empty", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
label_flag( | ||
name = "signing-token", | ||
build_setting_default = ":empty", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
jq( | ||
name = "envoy_versions", | ||
srcs = ["@envoy_repo//:project"], | ||
|
@@ -103,24 +130,6 @@ jq( | |
visibility = ["//visibility:public"], | ||
) | ||
|
||
genrule( | ||
name = "empty", | ||
outs = ["empty.txt"], | ||
cmd = """ | ||
touch $@ | ||
""", | ||
) | ||
|
||
label_flag( | ||
name = "excludes", | ||
build_setting_default = ":empty", | ||
) | ||
|
||
label_flag( | ||
name = "token", | ||
build_setting_default = ":empty", | ||
) | ||
|
||
genrule( | ||
name = "debs", | ||
outs = ["debs.tar.gz"], | ||
|
@@ -141,22 +150,31 @@ genrule( | |
":excludes", | ||
":token", | ||
], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
PUBLISH_ENV = { | ||
"APTLY_BIN": "$(location @aptly)", | ||
"MAINTAINER_KEY": "$(location //:envoy-maintainers-public.key)", | ||
"APTLY_CONF": "$(location //:aptly-config)", | ||
"DEBS": "$(location :debs)", | ||
"DEBS_ROOT": "$${APT_ROOT}/repository", | ||
"SIGNING_TOKEN": "$(location :signing-token)", | ||
} | ||
|
||
sh_binary( | ||
name = "publish", | ||
srcs = ["publish.sh"], | ||
env = { | ||
"APTLY_BIN": "$(location @aptly)", | ||
"MAINTAINER_KEY": "$(location //:envoy-maintainers-public.key)", | ||
"APTLY_CONF": "$(location //:aptly-config)", | ||
"DEBS": "$(location :debs)", | ||
"DEBS_ROOT_DEFAULT": "/opt/build/cache/repository", | ||
}, | ||
env = PUBLISH_ENV | select({ | ||
"//:production_build": {"SIGNING_KEY": "Envoy maintainers <[email protected]>"}, | ||
"//conditions:default": {"SIGNING_KEY": "Envoy CI <[email protected]>"}, | ||
}), | ||
data = [ | ||
"@aptly", | ||
"//:aptly-config", | ||
"//:envoy-maintainers-public.key", | ||
":debs" | ||
":debs", | ||
":signing-token", | ||
], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.