-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First draft e2e test matrix build + release stage
- Docker build now only builds amd64 to work around limitations in multi arch image tooling (#179) - Run e2e tests in parallell via matrix build to speed up CI builds - Add make-release + script to create a release (untested and currently disabled) - Add push-container-image stage to push container image for master branch commit builds (untested and currently disabled)
- Loading branch information
Showing
5 changed files
with
199 additions
and
72 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
# Copyright 2022- The FIAAS Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
version: v1.0 | ||
name: Release fiaas-deploy-daemon | ||
agent: | ||
machine: | ||
type: e1-standard-2 | ||
os_image: ubuntu1804 | ||
blocks: | ||
- name: Make release for fiaas-deploy-daemon | ||
task: | ||
secrets: | ||
# TODO: gh release needs a github token | ||
- name: docker | ||
prologue: | ||
commands: | ||
- checkout | ||
- docker login --username "${DOCKER_USERNAME}" --password-stdin <<< "${DOCKER_PASSWORD}" | ||
- cache restore "${SEMAPHORE_PROJECT_NAME}-${SEMAPHORE_WORKFLOW_ID}-build" | ||
jobs: | ||
- name: Make a new release for a git tag | ||
commands: | ||
- bin/make_release "$SEMAPHORE_GIT_TAG_NAME" | ||
|
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
version: v1.0 | ||
name: Push container image | ||
agent: | ||
machine: | ||
type: e1-standard-2 | ||
os_image: ubuntu1804 | ||
blocks: | ||
- name: Push development container image | ||
task: | ||
secrets: | ||
- name: docker | ||
prologue: | ||
commands: | ||
- docker login --username "${DOCKER_USERNAME}" --password-stdin <<< "${DOCKER_PASSWORD}" | ||
- cache restore "${SEMAPHORE_PROJECT_NAME}-${SEMAPHORE_WORKFLOW_ID}-build" | ||
jobs: | ||
- name: 'docker push' | ||
commands: | ||
- VERSION="$(head -n1 build/version)" | ||
- docker image load --input build/fiaas-deploy-daemon.tar | ||
- docker image tag "fiaas/fiaas-deploy-daemon:$VERSION" fiaas/fiaas-deploy-daemon:latest | ||
- docker push "fiaas/fiaas-deploy-daemon:$VERSION" | ||
- docker push fiaas/fiaas-deploy-daemon:latest | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
# `make_release TAG` creates a Github release for git tag TAG | ||
|
||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
# the first parameter should be the name of an annotated tag in the git repo | ||
RELEASE="$1" | ||
IMAGE=fiaas/fiaas-deploy-daemon | ||
# the following files under build/ are artifacts expected to be created by the initial build stage | ||
# the container image tarball | ||
IMAGE_TARBALL=build/fiaas-deploy-daemon.tar | ||
# contains the container image version as a single line | ||
IMAGE_VERSION="$(< build/version)" | ||
# contains the path to the helm chart tarball including version as a single line. | ||
# the chart tarball should also be under build/ | ||
HELM_CHART_TARBALL="$(< build/chart-tarball)" | ||
|
||
function publish_helm_chart() { | ||
local release="$1" | ||
local chart_tarball="$2" | ||
|
||
local helm_repo_dir | ||
helm_repo_dir="$(mktemp -d)" | ||
trap 'rm -rf $helm_repo_dir' RETURN | ||
|
||
git clone https://github.com/fiaas/helm "$helm_repo_dir" | ||
mv "$chart_tarball" "$helm_repo_dir"/ | ||
|
||
pushd "$helm_repo_dir" | ||
helm repo index . --url https://fiaas.github.io/helm/ | ||
git add . | ||
git commit -a -m "Release fiaas-deploy-daemon ${release}" | ||
git push "https://${GITHUBKEY}@github.com/fiaas/helm" | ||
popd | ||
|
||
echo "Published helm chart $chart_tarball" | ||
} | ||
|
||
function tag_push_docker_image() { | ||
local tarball="$1" | ||
local version_tag="$2" | ||
local release_tag="$3" | ||
|
||
docker image load --input "$tarball" | ||
docker tag fiaas/fiaas-deploy-daemon:"${version_tag}" "$release_tag" | ||
|
||
docker push "$version_tag" | ||
echo "Pushed image $version_tag" | ||
docker push "$release_tag" | ||
echo "Pushed image $release_tag" | ||
} | ||
|
||
if [[ "${CI:-false}" != "true" ]]; then | ||
echo "$0 is intended to run only in CI, run CI=true $0 to override" | ||
exit 1 | ||
fi | ||
|
||
if gh release view "$RELEASE" &> /dev/null; then | ||
echo "The github release $RELEASE already exists, can't overwrite a existing release" | ||
exit 2 | ||
fi | ||
|
||
# get release notes from the content of the annotated release tag | ||
git tag --list --format='%(contents)' "$RELEASE" > build/release-notes | ||
|
||
# publish artifacts | ||
tag_push_docker_image "$IMAGE_TARBALL" "${IMAGE}:$IMAGE_VERSION" "${IMAGE}:$RELEASE" | ||
publish_helm_chart "$RELEASE" "$HELM_CHART_TARBALL" | ||
|
||
# create the github release | ||
gh release create --title "fiaas-deploy-daemon release $RELEASE" --notes-file build/release-notes |