Update CI setup

This commit is contained in:
Abhilash Raj
2021-09-17 19:55:49 +00:00
committed by GitHub
parent 9fc4fbb12a
commit a5c591226d
5 changed files with 19 additions and 62 deletions

View File

@@ -1,7 +1,11 @@
version: '2'
version: '2.1'
jobs:
build:
parameters:
rolling:
type: string
default: "no"
machine:
image: ubuntu-2004:202010-01
docker_layer_caching: true
@@ -10,9 +14,6 @@ jobs:
BUILDKIT_PROGRESS: plain
steps:
- checkout
- run:
name: Setup Environment
command: source setup_env.sh
- run:
name: Install Python dependencies
command: python3 -m pip install packaging
@@ -21,7 +22,7 @@ jobs:
- python-deps-cache-v1
- run:
name: Building Container Images
command: ./build.sh
command: ./build.sh << parameters.rolling >>
- save_cache:
key: python-deps-cache-v1
paths:
@@ -48,6 +49,7 @@ workflows:
build-and-deploy-workflow:
jobs:
- build:
rolling: "no"
filters:
tags:
only: /^v\d+\.\d+\.\d+$/
@@ -61,11 +63,13 @@ workflows:
only: main
jobs:
- build:
rolling: "yes"
context: org-global
rolling-workflow:
jobs:
- build:
rolling: "yes"
context: org-global
filters:
branches:

View File

@@ -2,16 +2,13 @@
set -ex
# Set the default value of BUILD_ROLLING to no.
export BUILD_ROLLING="${1:-no}"
DOCKER=docker
# Set the env variable to later test this release before it is deployed.
if [ "$1" = "dev" ]; then
export DEV=true
fi
REG_URL=${REGISTRY}_URL
if [ "$EVENT_TYPE" = "cron" ] || [ "$DEV" = "true" ]; then
if [ "$BUILD_ROLLING" = "yes" ]; then
echo "Building rolling releases..."
python3 -m venv venv
source venv/bin/activate
pip install python-gitlab
@@ -46,6 +43,7 @@ if [ "$EVENT_TYPE" = "cron" ] || [ "$DEV" = "true" ]; then
--build-arg DJ_MM3_REF=$DJ_MM3_REF \
-t maxking/mailman-web:rolling web/
# build the postorius image.
$DOCKER build -f postorius/Dockerfile.dev\
--label version.git_commit="$COMMIT_ID"\
--label version.postorius="$POSTORIUS_REF" \
@@ -56,7 +54,8 @@ if [ "$EVENT_TYPE" = "cron" ] || [ "$DEV" = "true" ]; then
--build-arg DJ_MM3_REF=$DJ_MM3_REF \
-t maxking/postorius:rolling postorius/
else
# Do the normal building process.
echo "Building stable releases..."
# Build the stable releases.
$DOCKER build -t maxking/mailman-core:rolling core/
$DOCKER build -t maxking/mailman-web:rolling web/
$DOCKER build -t maxking/postorius:rolling postorius/

View File

@@ -34,6 +34,7 @@ USER = 'maxking'
TAG_VAR = 'CIRCLE_TAG'
BRANCH_VAR = 'CIRCLE_BRANCH'
PRIMARY_BRANCH = 'main'
ROLLING_VAR = "BUILD_ROLLING"
def tag(original, final):
@@ -112,8 +113,7 @@ def main():
if img_tag.startswith('v'):
img_tag = img_tag[1:]
is_release = True
elif os.environ.get(BRANCH_VAR) == PRIMARY_BRANCH:
elif os.environ.get(BRANCH_VAR) == PRIMARY_BRANCH and os.environ.get(ROLLING_VAR) == "yes":
img_tag = 'rolling'
else:
print('Not running on {PRIMARY_BRANCH} branch or Git tag so not publishing...'.format(

View File

@@ -1,38 +0,0 @@
# Script to setup environment variables.
set -ex
set_var () {
echo $1=$2 >> $BASH_ENV
export $1=$2
}
setup_env () {
CI_NAME=$1
# Set the current branch name.
BRANCH_NAME=${CI_NAME}_BRANCH
set_var BRANCH ${!BRANCH_NAME}
}
if [ "$TRAVIS" ]; then
# Set environments picked up from Circle CI.
set_var EVENT_TYPE "$TRAVIS_EVENT_TYPE"
set_var COMMIT_ID $TRAVIS_COMMIT
# Setup some generic environment vars.
setup_env TRAVIS
elif [ "$CIRCLECI" ]; then
# Set environments picked up from Circle CI.
set_var EVENT_TYPE "push"
set_var COMMIT_ID $CIRCLE_SHA1
# Setup some generic environment vars.
setup_env CIRCLE
fi
if [ "$BRANCH" = "master" ]; then
set_var TAG "latest"
else
set_var TAG "$COMMIT_ID"
fi
set_var REG_URL ${REGISTRY}_URL

View File

@@ -1,13 +1,5 @@
#!/bin/sh
if [ "$EVENT_TYPE" = "cron" ] || [ ! -z $DEV ] ; then
echo "Event type is: $EVENT_TYPE"
echo "This is a development version build: $DEV"
TAG="rolling"
fi
cat > docker-test.yaml <<EOF
version: '2'