Skip to content

Commit

Permalink
ci: fix release pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
copernican committed Aug 25, 2020
1 parent d29773f commit 199d186
Showing 1 changed file with 31 additions and 26 deletions.
57 changes: 31 additions & 26 deletions .drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ local r_versions = [

local ecr_repo_base = "906087756158.dkr.ecr.us-east-1.amazonaws.com";

local s3_url_base = "s3://mpn.metworx.dev/releases";
local s3_bucket = "mpn.metworx.dev";
local s3_target = "/releases";

local default_git_user = "Drony";
local default_git_email = "[email protected]";
Expand Down Expand Up @@ -186,17 +187,35 @@ local pull_image(image, volumes=[]) = {
local run_r_expression(r_path, expr) =
std.join(" ", [r_path, "-e", std.escapeStringBash(expr)]);

# Sync to S3
# Drone step to copy a tagged release to S3
#
# local_path path to local object
# remote_path path to S3 location
local s3_sync(local_path, remote_path) = std.format(
"aws s3 sync %(local)s %(remote)s",
{
"local": local_path,
"remote": remote_path,
# source_tag source tag name
# target_tag target "tag" name (allows for renaming tag)
# temp volume object
local s3_publish_tag(source_tag, target_tag, temp) = {
local strip_prefix = std.join("/", [temp.path, source_tag]),

"name": "Publish package: " + target_tag,
# s3-sync plugin does not appear to support volumes (/tmp appears as
# /drone/src/tmp), and may not be under active development
# https://github.com/drone-plugins/drone-s3-sync/issues/17#issuecomment-374286940
"image": "plugins/s3",
"pull": "if-not-exists",
"volumes": [add_step_volume(temp)],
"settings": {
"bucket": s3_bucket,
"source": std.join("/", [strip_prefix, "**/*"]),
"target": std.join(
"/",
[
s3_target,
"${DRONE_REPO_NAME}",
target_tag
]
),
"strip_prefix": strip_prefix + "/",
},
);
};

# Set up a Docker pipeline
#
Expand Down Expand Up @@ -375,22 +394,8 @@ local release(name, r_major_minor, image) =
),
],
},
{
"name": "Publish package",
"image": image_uri,
"pull": "never",
"volumes": [add_step_volume(v) for v in [temp_volume]],
"commands": [
s3_sync(
std.join("/", [temp_volume.path, "${DRONE_TAG}"]),
std.join("/", [s3_url_base, "${DRONE_REPO_NAME}", "${DRONE_TAG}"]),
),
s3_sync(
std.join("/", [temp_volume.path, "${DRONE_TAG}"]),
std.join("/", [s3_url_base, "${DRONE_REPO_NAME}", "latest_tag"]),
),
],
},
s3_publish_tag("${DRONE_TAG}", "${DRONE_TAG}", temp_volume),
s3_publish_tag("${DRONE_TAG}", "latest_tag", temp_volume),
],
};

Expand Down

0 comments on commit 199d186

Please sign in to comment.