Skip to content

Commit dff126f

Browse files
committed
Updates
1 parent abc9a26 commit dff126f

File tree

6 files changed

+673
-2
lines changed

6 files changed

+673
-2
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ _build/*
1515
src/wiotp_sdk.egg-info/*
1616
MANIFEST
1717
README.txt
18-
build/*
1918
dist/*
2019
.coverage
2120
tox.out
@@ -25,5 +24,6 @@ samples/*.exe
2524
samples/rbac-config.yaml
2625
test/.DS_Store
2726
/venv
27+
/.venv
2828
pandoc-*-amd64.deb
29-
README.rst
29+
README.rst

build/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Overview
2+
3+
Very cut back version of continuous integration build system for IBM Maximo Application Suite, based on Travis CI, utilizing automated semantic versioning of releases.
4+
5+
## Concepts
6+
7+
**Managed Branches** are ones where any commit will result in a new version being released. These branches take one of two forms:
8+
- `master` (current major version)
9+
- `v1.x`, `v2.x`, `v3.x`, `v4.x` etc
10+
11+
Versioning is controlled by the GitHub commit messages:
12+
- A commit comment of `[patch] Fix the thing` will result in a version change from `1.0.0` to `1.0.1`
13+
- A commit comment of `[minor] Add the new feature` will result in a version change from `1.0.0` to `1.1.0`
14+
- A commit comment of `[major] Rewrite the thing` will result in a version change from `1.0.0` to `2.0.0`
15+
- A commit comment without any of the above will result in build with no new release being published
16+
- A commit comment of `[skip ci] Something not worth a new build` will result in Travis not even running
17+
18+
When a build contains multiple commits the most significant commit "wins".
19+
20+
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.
21+

build/bin/.env.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
3+
# GitHub Actions environment variables documentation:
4+
# https://docs.github.com/en/actions/learn-github-actions/environment-variables
5+
6+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7+
export PATH=$PATH:$DIR:$DIR/ptc
8+
9+
# Version file (semver)
10+
export VERSION_FILE=${GITHUB_WORKSPACE}/.version
11+
if [ -f "$VERSION_FILE" ]; then
12+
export VERSION=$(cat ${VERSION_FILE})
13+
fi
14+
15+
export VERSION_FILE_NOPREREL=${GITHUB_WORKSPACE}/.version-noprerel
16+
if [ -f "$VERSION_FILE_NOPREREL" ]; then
17+
export VERSION_NOPREREL=$(cat ${VERSION_FILE_NOPREREL})
18+
fi
19+
20+
# During initbuild we record the release level (aka the version bump from the last release)
21+
export SEMVER_RELEASE_LEVEL_FILE=${GITHUB_WORKSPACE}/.releaselevel
22+
if [ -f "$SEMVER_RELEASE_LEVEL_FILE" ]; then
23+
export SEMVER_RELEASE_LEVEL=$(cat ${SEMVER_RELEASE_LEVEL_FILE})
24+
fi
25+
26+
# Docker does not support "+" characters from semvar syntax so we replace "+" with "_"
27+
# We should not actually deploy any "+build" releases anyway
28+
export DOCKER_TAG=$(echo "$VERSION" | sed -e's/\+/_/g')
29+
30+
if [ -z $BUILD_SYSTEM_ENV_LOADED ]; then
31+
echo "BUILD_SYSTEM_ENV_LOADED is not defined yet"
32+
export BUILD_SYSTEM_ENV_LOADED=1
33+
34+
if [ ! -z $GITHUB_ENV ]; then
35+
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#environment-files
36+
echo "GITHUB_ENV is defined, exporting properties to $GITHUB_ENV"
37+
38+
echo "VERSION_FILE=$VERSION_FILE" >> $GITHUB_ENV
39+
echo "VERSION_FILE_NOPREREL=$VERSION_FILE_NOPREREL" >> $GITHUB_ENV
40+
echo "VERSION=$VERSION" >> $GITHUB_ENV
41+
echo "VERSION_NOPREREL=$VERSION_NOPREREL" >> $GITHUB_ENV
42+
echo "DOCKER_TAG=$DOCKER_TAG" >> $GITHUB_ENV
43+
44+
echo "SEMVER_RELEASE_LEVEL_FILE=$SEMVER_RELEASE_LEVEL_FILE" >> $GITHUB_ENV
45+
echo "SEMVER_RELEASE_LEVEL=$SEMVER_RELEASE_LEVEL" >> $GITHUB_ENV
46+
47+
echo "BUILD_SYSTEM_ENV_LOADED=1" >> $GITHUB_ENV
48+
else
49+
echo "GITHUB_ENV is not defined"
50+
fi
51+
52+
echo_h1 "Build Properties"
53+
echo_highlight "DIR ........................ $DIR"
54+
echo_highlight "PATH ....................... $PATH"
55+
echo_highlight ""
56+
echo_highlight "VERSION_FILE ............... $VERSION_FILE"
57+
echo_highlight "VERSION_FILE_NOPREREL ...... $VERSION_FILE_NOPREREL"
58+
echo_highlight "VERSION .................... $VERSION"
59+
echo_highlight "VERSION_NOPREREL ........... $VERSION_NOPREREL"
60+
echo_highlight "DOCKER_TAG ................. $DOCKER_TAG"
61+
echo_highlight ""
62+
echo_highlight "SEMVER_RELEASE_LEVEL_FILE .. $SEMVER_RELEASE_LEVEL_FILE"
63+
echo_highlight "SEMVER_RELEASE_LEVEL ....... $SEMVER_RELEASE_LEVEL"
64+
else
65+
echo "BUILD_SYSTEM_ENV_LOADED is already defined, skipping debug and export to GitHub env file"
66+
fi
67+
68+

build/bin/.functions.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
5+
# COLOR_RED=`tput setaf 1`
6+
# COLOR_GREEN=`tput setaf 2`
7+
# COLOR_YELLOW=`tput setaf 3`
8+
# COLOR_BLUE=`tput setaf 4`
9+
# COLOR_MAGENTA=`tput setaf 5`
10+
# COLOR_CYAN=`tput setaf 6`
11+
# TEXT_RESET=`tput sgr0`
12+
13+
# tput doesn't work in GitHub actions
14+
# TODO: Integrate properly with GitHub actions to annotate the output as errors etc
15+
COLOR_RED=""
16+
COLOR_GREEN=""
17+
COLOR_YELLOW=""
18+
COLOR_BLUE=""
19+
COLOR_MAGENTA=""
20+
COLOR_CYAN=""
21+
TEXT_RESET=""
22+
23+
24+
function echo_h1() {
25+
echo "${COLOR_YELLOW}================================================================================"
26+
echo "${COLOR_YELLOW}$1"
27+
echo "${COLOR_YELLOW}================================================================================"
28+
}
29+
30+
31+
function echo_h2() {
32+
echo "${COLOR_YELLOW}$1"
33+
echo "${COLOR_YELLOW}--------------------------------------------------------------------------------"
34+
}
35+
36+
37+
function echo_warning() {
38+
echo "${COLOR_RED}$1"
39+
}
40+
41+
42+
function echo_highlight() {
43+
echo "${COLOR_MAGENTA}$1"
44+
}
45+
46+
47+
# Install yq
48+
# ----------
49+
function install_yq() {
50+
python -m pip install yq || exit 1
51+
}
52+
53+
54+
# These should be loaded already, but just incase!
55+
# ------------------------------------------------
56+
if [[ -z "$BUILD_SYSTEM_ENV_LOADED" ]]; then
57+
source $DIR/.env.sh
58+
fi
59+
60+
61+
# Upload a file to Artifactory
62+
# -----------------------------------------------------------------------------
63+
# Usage example:
64+
# artifactory_upload $FILE_PATH $TARGET_URL
65+
#
66+
function artifactory_upload() {
67+
if [ ! -e $1 ]; then
68+
echo_warning "Artifactory upload failed - $1 does not exist"
69+
exit 1
70+
fi
71+
72+
md5Value="`md5sum "$1"`"
73+
md5Value="${md5Value:0:32}"
74+
75+
sha1Value="`sha1sum "$1"`"
76+
sha1Value="${sha1Value:0:40}"
77+
78+
echo "Uploading $1 to $2"
79+
curl -H "Authorization:Bearer $ARTIFACTORY_TOKEN" -H "X-Checksum-Md5: $md5Value" -H "X-Checksum-Sha1: $sha1Value" -T $1 $2 || exit 1
80+
}

build/bin/initbuild.sh

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/bin/bash
2+
3+
# Simplified port of a portion of the MAS common build system for public GitHub
4+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5+
PATH=$PATH:$DIR
6+
7+
pip install --quiet pyyaml yamllint
8+
9+
# 1. Set up semantic versioning
10+
# -----------------------------------------------------------------------------
11+
VERSION_FILE=$GITHUB_WORKSPACE/.version
12+
VERSION_FILE_NOPREREL=$GITHUB_WORKSPACE/.version-noprerel
13+
14+
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
15+
echo "Note: non-branch build for a tag named '${GITHUB_REF_NAME}'"
16+
TAG_BASED_RELEASE=true
17+
18+
SEMVER_XYZ="(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)"
19+
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-]*))*)?"
20+
SEMVER_BUILD="(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?"
21+
SEMVER_REGEXP="^${SEMVER_XYZ}${SEMVER_PRE}${SEMVER_BUILD}$"
22+
23+
if [[ ! $GITHUB_REF_NAME =~ $SEMVER_REGEXP ]]; then
24+
echo "Aborting release build. Tag '$GITHUB_REF_NAME' does not match a valid semantic version string"
25+
exit 1
26+
fi
27+
28+
echo "${GITHUB_REF_NAME}" > $VERSION_FILE
29+
else
30+
# Finds the most recent tag that is reachable from a commit. If the tag points
31+
# to the commit, then only the tag is shown. Otherwise, it suffixes the tag name with the number
32+
# of additional commits on top of the tagged object and the abbreviated object name of the most
33+
# recent commit.
34+
echo "npm install of git-latest-semver-tag starting"
35+
npm install -g git-latest-semver-tag@1.0.2
36+
echo "- npm install complete"
37+
SEMVER_LAST_TAG=$(git-latest-semver-tag 2>/dev/null)
38+
39+
echo "LAST TAG = ${SEMVER_LAST_TAG}"
40+
41+
if [ -z $SEMVER_LAST_TAG ]; then
42+
SEMVER_LAST_TAG="1.0.0"
43+
SEMVER_RELEASE_LEVEL="initial"
44+
echo "Creating $GITHUB_WORKSPACE/.changelog"
45+
# Obtain a list of commits since dawn of time
46+
git log --oneline -1 --pretty=%B > $GITHUB_WORKSPACE/.changelog
47+
else
48+
echo "Creating $GITHUB_WORKSPACE/.changelog (${SEMVER_LAST_TAG}..HEAD)"
49+
# Obtain a list of commits since ${SEMVER_LAST_TAG}
50+
git log ${SEMVER_LAST_TAG}..HEAD --oneline --pretty=%B > $GITHUB_WORKSPACE/.changelog
51+
52+
echo "Changelog START:##################################################################"
53+
cat $GITHUB_WORKSPACE/.changelog
54+
echo "Changelog DONE:###################################################################"
55+
56+
# Work out what has changed
57+
MAJOR_COUNT=`grep -ciF '[major]' $GITHUB_WORKSPACE/.changelog`
58+
echo "Major commits : ${MAJOR_COUNT}"
59+
60+
MINOR_COUNT=`grep -ciF '[minor]' $GITHUB_WORKSPACE/.changelog`
61+
echo "Minor commits : ${MINOR_COUNT}"
62+
63+
PATCH_COUNT=`grep -ciF '[patch]' $GITHUB_WORKSPACE/.changelog`
64+
echo "Patch commits : ${PATCH_COUNT}"
65+
66+
if [ "$MAJOR_COUNT" -gt "0" ]; then
67+
SEMVER_RELEASE_LEVEL="major"
68+
elif [ "$MINOR_COUNT" -gt "0" ]; then
69+
SEMVER_RELEASE_LEVEL="minor"
70+
elif [ "$PATCH_COUNT" -gt "0" ]; then
71+
SEMVER_RELEASE_LEVEL="patch"
72+
fi
73+
fi
74+
75+
echo "RELEASE LEVEL = ${SEMVER_RELEASE_LEVEL}"
76+
echo "${SEMVER_RELEASE_LEVEL}" > $GITHUB_WORKSPACE/.releaselevel
77+
78+
# See: https://github.com/fsaintjacques/semver-tool/blob/master/src/semver
79+
if [ "${SEMVER_RELEASE_LEVEL}" == "initial" ]; then
80+
echo "1.0.0" > $VERSION_FILE
81+
echo "Configuring semver for initial release of $(cat $VERSION_FILE)"
82+
elif [[ "${SEMVER_RELEASE_LEVEL}" =~ ^(major|minor|patch)$ ]]; then
83+
semver bump ${SEMVER_RELEASE_LEVEL} ${SEMVER_LAST_TAG} > $VERSION_FILE
84+
echo "Configuring semver for ${SEMVER_RELEASE_LEVEL} bump from ${SEMVER_LAST_TAG} to $(cat $VERSION_FILE)"
85+
else
86+
# Default to a patch revision
87+
semver bump patch ${SEMVER_LAST_TAG} > $VERSION_FILE
88+
echo "Configuring semver for rebuild of ${SEMVER_LAST_TAG}: $(cat $VERSION_FILE)"
89+
fi
90+
fi
91+
92+
93+
# 2. Tweak version string for pre-release builds
94+
# -----------------------------------------------------------------------------
95+
cp $VERSION_FILE $VERSION_FILE_NOPREREL
96+
if [[ "${GITHUB_REF_TYPE}" == "branch" ]]; then
97+
semver bump prerel pre.$GITHUB_REF_NAME $(cat $VERSION_FILE) > $VERSION_FILE
98+
echo "Pre-release build: $(cat $VERSION_FILE)"
99+
fi
100+
101+
echo "Semantic versioning system initialized: $(cat $VERSION_FILE)"
102+
103+
104+
# 3. Version python modules (if they exist)
105+
# -----------------------------------------------------------------------------
106+
if [ -f ${GITHUB_WORKSPACE}/setup.py ]; then
107+
sed -i "s/version='1.0.0'/version='${VERSION}'/" setup.py
108+
fi
109+
110+
111+
exit 0

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy