Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit 716c1d7

Browse files
authored
CI Updates (#3)
# Added - Deployment step in CI - Initial commit of Docker, CI build, and configuration - Move `certbot` directory from `moodle-docker` to this repo - CONTRIBUTION.md # Changed - Clean up CI configuration - Update scripts - tag checking - docker publish
1 parent 85059af commit 716c1d7

6 files changed

Lines changed: 90 additions & 23 deletions

File tree

.travis.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
1+
# Define build stages
22
stages:
33
- Tests
44
- SDLC Tasks
55
- Build and Publish
66

7+
# Use minimal image
8+
language: minimal
9+
710
jobs:
811
include:
912
- stage: Tests
1013
name: Shellcheck
1114
env:
1215
- SHELLCHECK_OPTS="-e SC1008 -e SC2154"
13-
language: bash
1416
script:
1517
- shellcheck $(find . -type f -name '*.sh')
1618
- name: Dockerfile linter
17-
language: minimal
1819
script:
1920
- docker run --rm -v $PWD:/root/ projectatomic/dockerfile-lint dockerfile_lint -f ./Dockerfile
2021
- stage: "SDLC Tasks"
2122
name: Tag & iteration update
2223
sudo: required
23-
language: bash
2424
script:
2525
- bash bin/travis-ci/check_tag.sh
2626
- stage: Build and Publish
@@ -29,11 +29,15 @@ jobs:
2929
- secure: "syHwTME2FzcgZnn8VZgi2WGSctRlhYmt+6F3KVwhOUfgwRLqJZuohXSWm7/siS6BAqtk6poXIjpn7uAJXk+h7gEefQPaqe4GwwXJAn+zNq7K1Q1DCOhHlTjWdEn0dd1lH1rc8PnrS48U+TkP5yjQ24Y/20MnJy2omQ2awxBphZbBK1X5L8DIeYeMXi39/qhY+yUdmkS7kmC0eYMGK0ijVhDCQGt+MBkTPtdq2XwtGy0L5wHGeGz+epXRSLU8JIN1w29dTbEIR+SfrRfOB3fJo8rNoIecMt68+Jb5Xg33AehYL4t65Cx2z9+KtGvWeLIQEGlsG9gntJjMHqTUjcZnrO7b5ynSUKn5loaHJc4oM8IA2cpwidDHGVD1hNqo9Bg4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fKYhitXDDOngqBiJclRMV6zJfBzNKig/a3ouXQHbMybjxiAcH3kBYBzZEpkf7nf/R2xH0TfiMQS34b17VU0yYkOHjDe9NIWLZ8qDHPOMa3p0vuw23WpIaU6HaoD2Pzn/YqD79HlDwo4x+9FA4ffF0iYzRhRAlMK05WNXX0ZMoEvTMKwyGkVgu0U7kI+Tzj4z0O3ZIEc0tmthBuhOdjxc9FPjIN09tRhh15HeV55gn/uoZN79AOgBUG1ZLRahMEEXSGMtiWbBE8RRH8u46mP/bR6SLfqZ5whsDzQ4d8a1uNB7GRxaTHLZW+6Ij3YyNP6xtHQJiGk6U9iYTf4yUI4C2SkcDH+Zq+ipNuyJI4JduH5H1mQaK28I5Mu/s/BBVp6PJ7B/V3YKbv4Rv/DwiC8tGAfR+EQ/DGOvu69xiIKLc3IC4wI9TtLRQWrm7KZnPI1KlfFtYE7O/GotxoAbf/8kQ1HXfx1q0mP3o4ithtsz8XQX3h63jhD4hsBmNfiwEJCxO6Qwtq7ihxJOOh2rM9YGv8Ib3JQ6r+SLyfCO6Uhz0/buE/Xg+Xo1J8hMHmfy3T/d+MU7g+oOO2Oj9dxTSDiH7aLWwOlG653ltIM="
32-
language: minimal
3332
sudo: required
3433
services:
3534
- docker
3635
script:
3736
- bash bin/travis-ci/docker_upgrade.sh
3837
- bash bin/travis-ci/docker_build.sh
39-
- if [[ ${TRAVIS_BRANCH} = "master" ]]; then bash bin/travis-ci/docker_publish.sh; fi
38+
deploy:
39+
skip_cleanup: true
40+
provider: script
41+
script: bash bin/travis-ci/docker_publish.sh
42+
on:
43+
tags: true

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [v0.1.2] - 2018-10-02
8+
### Added
9+
- Deployment step in CI
10+
- Initial commit of Docker, CI build, and configuration
11+
- Move `certbot` directory from `moodle-docker` to this repo
12+
- CONTRIBUTION.md
13+
14+
### Changed
15+
- Clean up CI configuration
16+
- Update scripts
17+
- tag checking
18+
- docker publish
19+
720
## [v0.1.1] - 2018-10-02
821
### Added
922
- Project `CHANGELOG.md`, `README.md`, and `LICENSE`
1023
- Initial commit of Docker, CI build, and configuration
11-
- Move `certbot` directory from `moodle-docker` to this repo
24+
- Move `certbot` directory from `moodle-docker` to this repo

CONTRIBUTING.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Contributing to `certbot-docker`
2+
3+
## Tags
4+
### Summary
5+
* Tag `develop` after merging feature branches
6+
* Tag `master` after merging `develop`
7+
* Tag creation generate DEB package and pushes container to registry
8+
* See `.travis.yml` and `bin/travis-ci/*.sh` for details
9+
10+
### Procedure
11+
1. Push changes to appropriate branch (See [Pull Requests](#pull-requests))
12+
* In addition to any code changes, add a new entry in `CHANGELOG.md` with version bump and update `BUILD_VERSION` in `.env` to match
13+
2. Create PR
14+
3. Verify that all status checks pass
15+
4. Merge PR once approved
16+
5. Create a tag on the appropriate branch
17+
18+
## Pull Requests
19+
20+
### Feature Pull Requests
21+
* Base: `develop`
22+
* Increment PATCH version (e.g. `v0.1.12` -> `v0.1.13`)
23+
* Tag `master` after merging PR
24+
25+
### `master` Pull Requests
26+
* Base: `master`
27+
* Increment MINOR version (e.g. `v0.1.12` -> `v0.2.0`)
28+
* Tag `master` after merging PR

bin/travis-ci/check_tag.sh

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,49 @@
1717

1818
set -eo pipefail
1919

20-
# echo "Installing shtdlib"
20+
echo "Installing shtdlib"
2121
shtdlib_local_path="/usr/local/bin/shtdlib.sh"
2222
sudo curl -s -L -o "${shtdlib_local_path}" https://github.com/sdelements/shtdlib/raw/master/shtdlib.sh
2323
sudo chmod 775 "${shtdlib_local_path}"
2424
# shellcheck disable=SC1091,SC1090
2525
source "${shtdlib_local_path}"
2626
color_echo green "shtdlib.sh installed successfully"
2727

28+
version_pattern='v\d+\.\d+\.\d+(?:qa)?'
29+
version_pattern_line="^${version_pattern}$"
30+
2831
# Get the latest tag from GitHub
2932
latest_tag="$(git fetch -t && git tag -l | sort --version-sort | tail -n1)"
30-
color_echo green "Latest Git tag: '${latest_tag}'"
33+
color_echo green "Latest Git tag from repo: '${latest_tag}'"
3134

3235
# Get the latest tag from the CHANGELOG
33-
changelog_ver="$(grep -oP '\[v\d\.\d\.\d\]' CHANGELOG.md | tr -d '[]' | sort -nr | head -n1)"
36+
changelog_ver="$(grep -oP "\[${version_pattern}\]" CHANGELOG.md | tr -d '[]' | sort --version-sort -r | head -n1)"
3437
color_echo green "CHANGELOG version: '${changelog_ver}'"
3538

3639
# Validate version strings
37-
version_pattern='^v\d\.\d\.\d$'
38-
echo "${latest_tag}" | grep -qP ${version_pattern} || ( color_echo red "Invalid tag from repo: '${latest_tag}'" && exit 1 )
39-
echo "${changelog_ver}" | grep -qP ${version_pattern} || ( color_echo red "Invalid tag from CHANGELOG: '${changelog_ver}'" && exit 1 )
40-
41-
# Ensure tags in CHANGELOG and iteration are greater than highest repo tag
42-
if [ "${latest_tag}" = "${changelog_ver}" ] \
43-
|| ! compare_versions "${latest_tag}" "${changelog_ver}"; then
44-
color_echo red "Error: Version in CHANGELOG.md not updated"
45-
exit 1
40+
echo "${latest_tag}" | grep -qP "${version_pattern_line}" || ( color_echo red "Invalid tag from repo: '${latest_tag}'" && exit 1 )
41+
echo "${changelog_ver}" | grep -qP "${version_pattern_line}" || ( color_echo red "Invalid tag from CHANGELOG: '${changelog_ver}'" && exit 1 )
42+
43+
# Check if a tag triggered the build
44+
if [[ -z "${TRAVIS_TAG}" ]]; then
45+
# Ensure tags in CHANGELOG and iteration are greater than highest repo tag
46+
if [ "${latest_tag}" = "${changelog_ver}" ] \
47+
|| ! compare_versions "${latest_tag}" "${changelog_ver}"; then
48+
color_echo red "Error: Incorrect version update. CHANGELOG.md (${changelog_ver}) not updated"
49+
exit 1
50+
else
51+
color_echo green "Version bumps PASS!"
52+
fi
4653
else
47-
color_echo green "Version bumps PASS!"
54+
color_echo green "Newly created tag: '${TRAVIS_TAG}'"
55+
# Validate version strings
56+
echo "${TRAVIS_TAG}" | grep -qP "${version_pattern_line}" || ( color_echo red "Invalid tag name created: '${TRAVIS_TAG}'" && exit 1 )
57+
58+
# Ensure all the tags match up
59+
if [ ! "${TRAVIS_TAG}" = "${changelog_ver}" ]; then
60+
color_echo red "Error: tag version (${TRAVIS_TAG}) should match CHANGELOG.md (${changelog_ver})"
61+
exit 1
62+
else
63+
color_echo green "Version bumps PASS!"
64+
fi
4865
fi

bin/travis-ci/docker_build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
set -eo pipefail
1919

2020
# Build image
21-
docker build --no-cache --tag "${DOCKER_REGISTRY_URL}/postfix" .
21+
docker build --no-cache --tag "${DOCKER_REGISTRY_URL}/certbot" .
2222
docker images

bin/travis-ci/docker_publish.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ set -eo pipefail
2020
# Log into our Docker registry
2121
echo "${DOCKER_REGISTRY_PASSWORD}" | docker login -u "${DOCKER_REGISTRY_USER}" --password-stdin "${DOCKER_REGISTRY_URL}"
2222

23-
# Push image
24-
docker push "${DOCKER_REGISTRY_URL}/postfix:latest"
23+
echo "Tagging container"
24+
docker tag "${DOCKER_REGISTRY_URL}/certbot:latest" "${DOCKER_REGISTRY_URL}/certbot:${TRAVIS_TAG}"
25+
26+
# Push images
27+
docker push "${DOCKER_REGISTRY_URL}/certbot:latest"
28+
docker push "${DOCKER_REGISTRY_URL}/certbot:${TRAVIS_TAG}"
29+
docker images

0 commit comments

Comments
 (0)