diff --git a/.circleci/config.yml b/.circleci/config.yml index 13e8269..0c151e1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: diff --git a/build.sh b/build.sh index 55e6413..7c3c14a 100755 --- a/build.sh +++ b/build.sh @@ -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/ diff --git a/deploy.py b/deploy.py index 069f282..ae50d6c 100644 --- a/deploy.py +++ b/deploy.py @@ -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( diff --git a/setup_env.sh b/setup_env.sh deleted file mode 100644 index 51dc93a..0000000 --- a/setup_env.sh +++ /dev/null @@ -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 diff --git a/tests/generate_tests.sh b/tests/generate_tests.sh index f62a5d9..dbc6cb6 100644 --- a/tests/generate_tests.sh +++ b/tests/generate_tests.sh @@ -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 <