-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
673 additions
and
2 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
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,21 @@ | ||
## Overview | ||
|
||
Very cut back version of continuous integration build system for IBM Maximo Application Suite, based on Travis CI, utilizing automated semantic versioning of releases. | ||
|
||
## Concepts | ||
|
||
**Managed Branches** are ones where any commit will result in a new version being released. These branches take one of two forms: | ||
- `master` (current major version) | ||
- `v1.x`, `v2.x`, `v3.x`, `v4.x` etc | ||
|
||
Versioning is controlled by the GitHub commit messages: | ||
- A commit comment of `[patch] Fix the thing` will result in a version change from `1.0.0` to `1.0.1` | ||
- A commit comment of `[minor] Add the new feature` will result in a version change from `1.0.0` to `1.1.0` | ||
- A commit comment of `[major] Rewrite the thing` will result in a version change from `1.0.0` to `2.0.0` | ||
- A commit comment without any of the above will result in build with no new release being published | ||
- A commit comment of `[skip ci] Something not worth a new build` will result in Travis not even running | ||
|
||
When a build contains multiple commits the most significant commit "wins". | ||
|
||
Commits in **Unmanaged Branches** will still result in a new build, but any artifacts published will overwrite the previous release. Effectively there is only a latest version for these branches. | ||
|
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,68 @@ | ||
#!/bin/bash | ||
|
||
# GitHub Actions environment variables documentation: | ||
# https://docs.github.com/en/actions/learn-github-actions/environment-variables | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
export PATH=$PATH:$DIR:$DIR/ptc | ||
|
||
# Version file (semver) | ||
export VERSION_FILE=${GITHUB_WORKSPACE}/.version | ||
if [ -f "$VERSION_FILE" ]; then | ||
export VERSION=$(cat ${VERSION_FILE}) | ||
fi | ||
|
||
export VERSION_FILE_NOPREREL=${GITHUB_WORKSPACE}/.version-noprerel | ||
if [ -f "$VERSION_FILE_NOPREREL" ]; then | ||
export VERSION_NOPREREL=$(cat ${VERSION_FILE_NOPREREL}) | ||
fi | ||
|
||
# During initbuild we record the release level (aka the version bump from the last release) | ||
export SEMVER_RELEASE_LEVEL_FILE=${GITHUB_WORKSPACE}/.releaselevel | ||
if [ -f "$SEMVER_RELEASE_LEVEL_FILE" ]; then | ||
export SEMVER_RELEASE_LEVEL=$(cat ${SEMVER_RELEASE_LEVEL_FILE}) | ||
fi | ||
|
||
# Docker does not support "+" characters from semvar syntax so we replace "+" with "_" | ||
# We should not actually deploy any "+build" releases anyway | ||
export DOCKER_TAG=$(echo "$VERSION" | sed -e's/\+/_/g') | ||
|
||
if [ -z $BUILD_SYSTEM_ENV_LOADED ]; then | ||
echo "BUILD_SYSTEM_ENV_LOADED is not defined yet" | ||
export BUILD_SYSTEM_ENV_LOADED=1 | ||
|
||
if [ ! -z $GITHUB_ENV ]; then | ||
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#environment-files | ||
echo "GITHUB_ENV is defined, exporting properties to $GITHUB_ENV" | ||
|
||
echo "VERSION_FILE=$VERSION_FILE" >> $GITHUB_ENV | ||
echo "VERSION_FILE_NOPREREL=$VERSION_FILE_NOPREREL" >> $GITHUB_ENV | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
echo "VERSION_NOPREREL=$VERSION_NOPREREL" >> $GITHUB_ENV | ||
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV | ||
|
||
echo "SEMVER_RELEASE_LEVEL_FILE=$SEMVER_RELEASE_LEVEL_FILE" >> $GITHUB_ENV | ||
echo "SEMVER_RELEASE_LEVEL=$SEMVER_RELEASE_LEVEL" >> $GITHUB_ENV | ||
|
||
echo "BUILD_SYSTEM_ENV_LOADED=1" >> $GITHUB_ENV | ||
else | ||
echo "GITHUB_ENV is not defined" | ||
fi | ||
|
||
echo_h1 "Build Properties" | ||
echo_highlight "DIR ........................ $DIR" | ||
echo_highlight "PATH ....................... $PATH" | ||
echo_highlight "" | ||
echo_highlight "VERSION_FILE ............... $VERSION_FILE" | ||
echo_highlight "VERSION_FILE_NOPREREL ...... $VERSION_FILE_NOPREREL" | ||
echo_highlight "VERSION .................... $VERSION" | ||
echo_highlight "VERSION_NOPREREL ........... $VERSION_NOPREREL" | ||
echo_highlight "DOCKER_TAG ................. $DOCKER_TAG" | ||
echo_highlight "" | ||
echo_highlight "SEMVER_RELEASE_LEVEL_FILE .. $SEMVER_RELEASE_LEVEL_FILE" | ||
echo_highlight "SEMVER_RELEASE_LEVEL ....... $SEMVER_RELEASE_LEVEL" | ||
else | ||
echo "BUILD_SYSTEM_ENV_LOADED is already defined, skipping debug and export to GitHub env file" | ||
fi | ||
|
||
|
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,80 @@ | ||
#!/bin/bash | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# COLOR_RED=`tput setaf 1` | ||
# COLOR_GREEN=`tput setaf 2` | ||
# COLOR_YELLOW=`tput setaf 3` | ||
# COLOR_BLUE=`tput setaf 4` | ||
# COLOR_MAGENTA=`tput setaf 5` | ||
# COLOR_CYAN=`tput setaf 6` | ||
# TEXT_RESET=`tput sgr0` | ||
|
||
# tput doesn't work in GitHub actions | ||
# TODO: Integrate properly with GitHub actions to annotate the output as errors etc | ||
COLOR_RED="" | ||
COLOR_GREEN="" | ||
COLOR_YELLOW="" | ||
COLOR_BLUE="" | ||
COLOR_MAGENTA="" | ||
COLOR_CYAN="" | ||
TEXT_RESET="" | ||
|
||
|
||
function echo_h1() { | ||
echo "${COLOR_YELLOW}================================================================================" | ||
echo "${COLOR_YELLOW}$1" | ||
echo "${COLOR_YELLOW}================================================================================" | ||
} | ||
|
||
|
||
function echo_h2() { | ||
echo "${COLOR_YELLOW}$1" | ||
echo "${COLOR_YELLOW}--------------------------------------------------------------------------------" | ||
} | ||
|
||
|
||
function echo_warning() { | ||
echo "${COLOR_RED}$1" | ||
} | ||
|
||
|
||
function echo_highlight() { | ||
echo "${COLOR_MAGENTA}$1" | ||
} | ||
|
||
|
||
# Install yq | ||
# ---------- | ||
function install_yq() { | ||
python -m pip install yq || exit 1 | ||
} | ||
|
||
|
||
# These should be loaded already, but just incase! | ||
# ------------------------------------------------ | ||
if [[ -z "$BUILD_SYSTEM_ENV_LOADED" ]]; then | ||
source $DIR/.env.sh | ||
fi | ||
|
||
|
||
# Upload a file to Artifactory | ||
# ----------------------------------------------------------------------------- | ||
# Usage example: | ||
# artifactory_upload $FILE_PATH $TARGET_URL | ||
# | ||
function artifactory_upload() { | ||
if [ ! -e $1 ]; then | ||
echo_warning "Artifactory upload failed - $1 does not exist" | ||
exit 1 | ||
fi | ||
|
||
md5Value="`md5sum "$1"`" | ||
md5Value="${md5Value:0:32}" | ||
|
||
sha1Value="`sha1sum "$1"`" | ||
sha1Value="${sha1Value:0:40}" | ||
|
||
echo "Uploading $1 to $2" | ||
curl -H "Authorization:Bearer $ARTIFACTORY_TOKEN" -H "X-Checksum-Md5: $md5Value" -H "X-Checksum-Sha1: $sha1Value" -T $1 $2 || exit 1 | ||
} |
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,111 @@ | ||
#!/bin/bash | ||
|
||
# Simplified port of a portion of the MAS common build system for public GitHub | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
PATH=$PATH:$DIR | ||
|
||
pip install --quiet pyyaml yamllint | ||
|
||
# 1. Set up semantic versioning | ||
# ----------------------------------------------------------------------------- | ||
VERSION_FILE=$GITHUB_WORKSPACE/.version | ||
VERSION_FILE_NOPREREL=$GITHUB_WORKSPACE/.version-noprerel | ||
|
||
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then | ||
echo "Note: non-branch build for a tag named '${GITHUB_REF_NAME}'" | ||
TAG_BASED_RELEASE=true | ||
|
||
SEMVER_XYZ="(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)" | ||
SEMVER_PRE="(-(0|[1-9][0-9]*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*)?" | ||
SEMVER_BUILD="(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?" | ||
SEMVER_REGEXP="^${SEMVER_XYZ}${SEMVER_PRE}${SEMVER_BUILD}$" | ||
|
||
if [[ ! $GITHUB_REF_NAME =~ $SEMVER_REGEXP ]]; then | ||
echo "Aborting release build. Tag '$GITHUB_REF_NAME' does not match a valid semantic version string" | ||
exit 1 | ||
fi | ||
|
||
echo "${GITHUB_REF_NAME}" > $VERSION_FILE | ||
else | ||
# Finds the most recent tag that is reachable from a commit. If the tag points | ||
# to the commit, then only the tag is shown. Otherwise, it suffixes the tag name with the number | ||
# of additional commits on top of the tagged object and the abbreviated object name of the most | ||
# recent commit. | ||
echo "npm install of git-latest-semver-tag starting" | ||
npm install -g [email protected] | ||
echo "- npm install complete" | ||
SEMVER_LAST_TAG=$(git-latest-semver-tag 2>/dev/null) | ||
|
||
echo "LAST TAG = ${SEMVER_LAST_TAG}" | ||
|
||
if [ -z $SEMVER_LAST_TAG ]; then | ||
SEMVER_LAST_TAG="1.0.0" | ||
SEMVER_RELEASE_LEVEL="initial" | ||
echo "Creating $GITHUB_WORKSPACE/.changelog" | ||
# Obtain a list of commits since dawn of time | ||
git log --oneline -1 --pretty=%B > $GITHUB_WORKSPACE/.changelog | ||
else | ||
echo "Creating $GITHUB_WORKSPACE/.changelog (${SEMVER_LAST_TAG}..HEAD)" | ||
# Obtain a list of commits since ${SEMVER_LAST_TAG} | ||
git log ${SEMVER_LAST_TAG}..HEAD --oneline --pretty=%B > $GITHUB_WORKSPACE/.changelog | ||
|
||
echo "Changelog START:##################################################################" | ||
cat $GITHUB_WORKSPACE/.changelog | ||
echo "Changelog DONE:###################################################################" | ||
|
||
# Work out what has changed | ||
MAJOR_COUNT=`grep -ciF '[major]' $GITHUB_WORKSPACE/.changelog` | ||
echo "Major commits : ${MAJOR_COUNT}" | ||
|
||
MINOR_COUNT=`grep -ciF '[minor]' $GITHUB_WORKSPACE/.changelog` | ||
echo "Minor commits : ${MINOR_COUNT}" | ||
|
||
PATCH_COUNT=`grep -ciF '[patch]' $GITHUB_WORKSPACE/.changelog` | ||
echo "Patch commits : ${PATCH_COUNT}" | ||
|
||
if [ "$MAJOR_COUNT" -gt "0" ]; then | ||
SEMVER_RELEASE_LEVEL="major" | ||
elif [ "$MINOR_COUNT" -gt "0" ]; then | ||
SEMVER_RELEASE_LEVEL="minor" | ||
elif [ "$PATCH_COUNT" -gt "0" ]; then | ||
SEMVER_RELEASE_LEVEL="patch" | ||
fi | ||
fi | ||
|
||
echo "RELEASE LEVEL = ${SEMVER_RELEASE_LEVEL}" | ||
echo "${SEMVER_RELEASE_LEVEL}" > $GITHUB_WORKSPACE/.releaselevel | ||
|
||
# See: https://github.com/fsaintjacques/semver-tool/blob/master/src/semver | ||
if [ "${SEMVER_RELEASE_LEVEL}" == "initial" ]; then | ||
echo "1.0.0" > $VERSION_FILE | ||
echo "Configuring semver for initial release of $(cat $VERSION_FILE)" | ||
elif [[ "${SEMVER_RELEASE_LEVEL}" =~ ^(major|minor|patch)$ ]]; then | ||
semver bump ${SEMVER_RELEASE_LEVEL} ${SEMVER_LAST_TAG} > $VERSION_FILE | ||
echo "Configuring semver for ${SEMVER_RELEASE_LEVEL} bump from ${SEMVER_LAST_TAG} to $(cat $VERSION_FILE)" | ||
else | ||
# Default to a patch revision | ||
semver bump patch ${SEMVER_LAST_TAG} > $VERSION_FILE | ||
echo "Configuring semver for rebuild of ${SEMVER_LAST_TAG}: $(cat $VERSION_FILE)" | ||
fi | ||
fi | ||
|
||
|
||
# 2. Tweak version string for pre-release builds | ||
# ----------------------------------------------------------------------------- | ||
cp $VERSION_FILE $VERSION_FILE_NOPREREL | ||
if [[ "${GITHUB_REF_TYPE}" == "branch" ]]; then | ||
semver bump prerel pre.$GITHUB_REF_NAME $(cat $VERSION_FILE) > $VERSION_FILE | ||
echo "Pre-release build: $(cat $VERSION_FILE)" | ||
fi | ||
|
||
echo "Semantic versioning system initialized: $(cat $VERSION_FILE)" | ||
|
||
|
||
# 3. Version python modules (if they exist) | ||
# ----------------------------------------------------------------------------- | ||
if [ -f ${GITHUB_WORKSPACE}/setup.py ]; then | ||
sed -i "s/version='1.0.0'/version='${VERSION}'/" setup.py | ||
fi | ||
|
||
|
||
exit 0 |
Oops, something went wrong.