Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] upload artifacts of production, rolling or daily #9364

Merged
merged 8 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 94 additions & 31 deletions .drone.star
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
"""oCIS CI definition
"""

# Production release tags
# NOTE: need to be updated if new production releases are determined
# - follow semver
# - omit 'v' prefix
PRODUCTION_RELEASE_TAGS = ["5.0", "7.0.0"]
micbar marked this conversation as resolved.
Show resolved Hide resolved

# images
ALPINE_GIT = "alpine/git:latest"
APACHE_TIKA = "apache/tika:2.8.0.0"
Expand Down Expand Up @@ -1264,20 +1270,43 @@ def logTracingResults():

def dockerReleases(ctx):
pipelines = []
for arch in config["dockerReleases"]["architectures"]:
pipelines.append(dockerRelease(ctx, arch))
docker_repos = []
build_type = "daily"

# dockerhub repo
# - "owncloud/ocis-rolling"
repo = ctx.repo.slug + "-rolling"
docker_repos.append(repo)

# production release repo
if ctx.build.event == "tag":
tag = ctx.build.ref.replace("refs/tags/v", "").lower()
for prod_tag in PRODUCTION_RELEASE_TAGS:
if tag.startswith(prod_tag):
docker_repos.append(ctx.repo.slug)
break

for repo in docker_repos:
repo_pipelines = []
if ctx.build.event == "tag":
build_type = "rolling" if "rolling" in repo else "production"

for arch in config["dockerReleases"]["architectures"]:
repo_pipelines.append(dockerRelease(ctx, arch, repo, build_type))

manifest = releaseDockerManifest(repo, build_type)
manifest["depends_on"] = getPipelineNames(repo_pipelines)
repo_pipelines.append(manifest)

manifest = releaseDockerManifest()
manifest["depends_on"] = getPipelineNames(pipelines)
pipelines.append(manifest)
readme = releaseDockerReadme(ctx, repo, build_type)
readme["depends_on"] = getPipelineNames(repo_pipelines)
repo_pipelines.append(readme)

readme = releaseDockerReadme(ctx)
readme["depends_on"] = getPipelineNames(pipelines)
pipelines.append(readme)
pipelines.extend(repo_pipelines)

return pipelines

def dockerRelease(ctx, arch):
def dockerRelease(ctx, arch, repo, build_type):
build_args = [
"REVISION=%s" % (ctx.build.commit),
"VERSION=%s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "latest"),
Expand All @@ -1290,7 +1319,7 @@ def dockerRelease(ctx, arch):
return {
"kind": "pipeline",
"type": "docker",
"name": "docker-%s" % (arch),
"name": "docker-%s-%s" % (arch, build_type),
"platform": {
"os": "linux",
"arch": arch,
Expand All @@ -1314,7 +1343,7 @@ def dockerRelease(ctx, arch):
"context": "ocis",
"tags": "linux-%s" % (arch),
"dockerfile": "ocis/docker/Dockerfile.linux.%s" % (arch),
"repo": ctx.repo.slug,
"repo": repo,
"build_args": build_args,
},
"when": {
Expand All @@ -1339,7 +1368,7 @@ def dockerRelease(ctx, arch):
"context": "ocis",
"auto_tag_suffix": "linux-%s" % (arch),
"dockerfile": "ocis/docker/Dockerfile.linux.%s" % (arch),
"repo": ctx.repo.slug,
"repo": repo,
"build_args": build_args,
},
"when": {
Expand All @@ -1364,25 +1393,55 @@ def dockerRelease(ctx, arch):

def binaryReleases(ctx):
pipelines = []
for os in config["binaryReleases"]["os"]:
pipelines.append(binaryRelease(ctx, os))
targets = []
build_type = "daily"

return pipelines

def binaryRelease(ctx, name):
# uploads binary to https://download.owncloud.com/ocis/ocis/daily/
target = "/ocis/%s/daily" % (ctx.repo.name.replace("ocis-", ""))
depends_on = getPipelineNames(testOcisAndUploadResults(ctx) + testPipelines(ctx))

if ctx.build.event == "tag":
# uploads binary to eg. https://download.owncloud.com/ocis/ocis/1.0.0-beta9/
folder = "stable"
buildref = ctx.build.ref.replace("refs/tags/v", "")
buildref = buildref.lower()
depends_on = []

buildref = ctx.build.ref.replace("refs/tags/v", "").lower()
target_path = "/ocis/%s" % ctx.repo.name.replace("ocis-", "")

if buildref.find("-") != -1: # "x.x.x-alpha", "x.x.x-beta", "x.x.x-rc"
folder = "testing"
target = "/ocis/%s/%s/%s" % (ctx.repo.name.replace("ocis-", ""), folder, buildref)
depends_on = []
target = "%s/%s/%s" % (target_path, folder, buildref)
targets.append(target)
build_type = "testing"
else:
# uploads binary to eg. https://download.owncloud.com/ocis/ocis/rolling/1.0.0/
folder = "rolling"
target = "%s/%s/%s" % (target_path, folder, buildref)
targets.append(target)

for prod_tag in PRODUCTION_RELEASE_TAGS:
if buildref.startswith(prod_tag):
# uploads binary to eg. https://download.owncloud.com/ocis/ocis/stable/2.0.0/
folder = "stable"
target = "%s/%s/%s" % (target_path, folder, buildref)
targets.append(target)
break

else:
targets.append(target)

for target in targets:
if "rolling" in target:
build_type = "rolling"
elif "stable" in target:
build_type = "production"
elif "testing" in target:
build_type = "testing"

for os in config["binaryReleases"]["os"]:
pipelines.append(binaryRelease(ctx, os, build_type, target, depends_on))

return pipelines

def binaryRelease(ctx, arch, build_type, target, depends_on = []):
settings = {
"endpoint": {
"from_secret": "upload_s3_endpoint",
Expand All @@ -1405,7 +1464,7 @@ def binaryRelease(ctx, name):
return {
"kind": "pipeline",
"type": "docker",
"name": "binaries-%s" % (name),
"name": "binaries-%s-%s" % (arch, build_type),
"platform": {
"os": "linux",
"arch": "amd64",
Expand All @@ -1418,7 +1477,7 @@ def binaryRelease(ctx, name):
"image": OC_CI_GOLANG,
"environment": DRONE_HTTP_PROXY_ENV,
"commands": [
"make -C ocis release-%s" % (name),
"make -C ocis release-%s" % (arch),
],
},
{
Expand Down Expand Up @@ -1627,11 +1686,15 @@ def licenseCheck(ctx):
"volumes": [pipelineVolumeGo],
}]

def releaseDockerManifest():
def releaseDockerManifest(repo, build_type):
spec = "manifest.tmpl"
if "rolling" not in repo:
spec = "manifest-production.tmpl"

return {
"kind": "pipeline",
"type": "docker",
"name": "manifest",
"name": "manifest-%s" % build_type,
"platform": {
"os": "linux",
"arch": "amd64",
Expand All @@ -1647,7 +1710,7 @@ def releaseDockerManifest():
"password": {
"from_secret": "docker_password",
},
"spec": "ocis/docker/manifest.tmpl",
"spec": "ocis/docker/%s" % spec,
"auto_tag": True,
"ignore_missing": True,
},
Expand Down Expand Up @@ -1730,11 +1793,11 @@ def changelog():
},
}]

def releaseDockerReadme(ctx):
def releaseDockerReadme(ctx, repo, build_type):
return {
"kind": "pipeline",
"type": "docker",
"name": "readme",
"name": "readme-%s" % build_type,
"platform": {
"os": "linux",
"arch": "amd64",
Expand All @@ -1750,7 +1813,7 @@ def releaseDockerReadme(ctx):
"DOCKER_PASS": {
"from_secret": "docker_password",
},
"PUSHRM_TARGET": "owncloud/${DRONE_REPO_NAME}",
"PUSHRM_TARGET": repo,
"PUSHRM_SHORT": "Docker images for %s" % (ctx.repo.name),
"PUSHRM_FILE": "README.md",
},
Expand Down
17 changes: 17 additions & 0 deletions ocis/docker/manifest.production.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
image: owncloud/ocis:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: owncloud/ocis:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
- image: owncloud/ocis:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
architecture: arm64
variant: v8
os: linux
6 changes: 3 additions & 3 deletions ocis/docker/manifest.tmpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
image: owncloud/ocis:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
image: owncloud/ocis-rolling:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
micbar marked this conversation as resolved.
Show resolved Hide resolved
{{#if build.tags}}
tags:
{{#each build.tags}}
- {{this}}
{{/each}}
{{/if}}
manifests:
- image: owncloud/ocis:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
- image: owncloud/ocis-rolling:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
platform:
architecture: amd64
os: linux
- image: owncloud/ocis:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
- image: owncloud/ocis-rolling:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
platform:
architecture: arm64
variant: v8
Expand Down