Skip to content

Commit

Permalink
circleci: update to use workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
  • Loading branch information
Ansuel committed Apr 16, 2019
1 parent ee09f47 commit ffc0c3b
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 48 deletions.
62 changes: 42 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2.1
jobs:
build:
prepare:
working_directory: ~/gui_build
docker:
- image: ansuel/gui-autobuild-image:2
Expand All @@ -9,55 +9,77 @@ jobs:
- run:
name: Check built type from last git log
command: bash ./scripts/0-detect-build-type.sh
#- restore_cache:
# keys: latest-file-key
- run:
name: Increment version from latest build
command: bash ./scripts/1-increment_autobuild_ver.sh
- run:
name: Minify css and javascript
command: bash ./scripts/1-compress_css_javascript.sh
- run:
name: Clone autobuild repo
command: bash ./scripts/2-clone_autobuild_dir.sh
- run:
name: Update po
command: python3 ./scripts/update_po.py
- persist_to_workspace:
root: ~/gui_build
paths:
- decompressed
- data
- scripts
- inizialize_gui.sh
init_and_update:
working_directory: ~/gui_build
docker:
- image: ansuel/gui-autobuild-image:2
steps:
- attach_workspace:
at: ~/gui_build
- run:
name: Clone autobuild repo
command: bash ./scripts/2-clone_autobuild_dir.sh
- run:
name: Inizialize Gui
command: bash ./inizialize_gui.sh
- run:
name: Upload new build, build and latest.version
command: bash ./scripts/3-update_autobuild_ver.sh
- run:
name: Committing updated po to master
command: bash ./scripts/6-commit_po.sh
#- save_cache:
# key: latest-file-key
# paths:
# - ~/gui-dev-build-auto/latest.version
- persist_to_workspace:
root: ~/gui_build
paths:
- compressed
- scripts
- data

publish-github-release:
commit_po_changes:
working_directory: ~/gui_build
docker:
- image: cibuilds/github:0.10
steps:
- checkout
- attach_workspace:
at: /tmp/gui_build
at: ~/gui_build
- run:
name: Committing updated po to master
command: bash ./scripts/6-commit_po.sh
publish_github_release:
working_directory: ~/gui_build
docker:
- image: cibuilds/github:0.10
steps:
- attach_workspace:
at: ~/gui_build
- run:
name: "Publish Release on GitHub"
command: bash /tmp/gui_build/scripts/7-push-release.sh
command: bash ./scripts/7-push-release.sh

workflows:
version: 2
build_and_deploy:
jobs:
- build
- publish-github-release:
- prepare
- commit_po_changes:
requires:
- prepare
- init_and_update:
requires:
- prepare
- publish_github_release:
requires:
- build
- init_and_update
3 changes: 2 additions & 1 deletion inizialize_gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ if [ "$1" == "dev" ]; then
fi

if [ $CI == "true" ]; then
if [ -f ~/.dev ]; then
TYPE="$(cat $HOME/gui_build/data/type)"
if [ $TYPE == "DEV" ]; then
type="_dev"
fi
fi
Expand Down
6 changes: 4 additions & 2 deletions scripts/0-detect-build-type.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
last_log="$(git log --oneline -n 1)"

mkdir $HOME/gui_build/data

if [ "$( echo "$last_log" | grep "\[STABLE\]" )" ]; then
echo "Detected STABLE build."
touch ~/.stable
echo STABLE > $HOME/gui_build/data/type
else
echo "Detected DEV build."
touch ~/.dev
echo DEV > $HOME/gui_build/data/type
fi
22 changes: 12 additions & 10 deletions scripts/1-increment_autobuild_ver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ rootdevice_file="decompressed/base/etc/init.d/rootdevice"

if [ "$(echo "$last_log" | grep -o "\[[0-9]\+\.[0-9]\+\.[0-9]\+\]" | tr -d [ | tr -d ])" ]; then
manual_ver="$(echo "$last_log" | grep -o "\[[0-9]\+\.[0-9]\+\.[0-9]\+\]" | tr -d [ | tr -d ])"
echo "Detected manual version: "$manual_ver
sed -i s#version_gui=TO_AUTO_COMPLETE#version_gui=$manual_ver# $rootdevice_file
echo "Detected manual version: "$ver
sed -i s#version_gui=TO_AUTO_COMPLETE#version_gui=$ver# $rootdevice_file
else
latest_version_link="https://raw.githubusercontent.com/Ansuel/gui-dev-build-auto/master/latest.version"
version=$(curl -s $latest_version_link)
cur_ver=$(curl -s $latest_version_link)

if [ -f $HOME/gui-dev-build-auto/latest.version ]; then
echo "Detected cached latest.version file... Checking it..."
Expand All @@ -33,9 +33,9 @@ else

echo "Increment version as this is an autobuild"

major=$(echo $version | grep -Eo "^[0-9]+")
dev_num=$(echo $version | sed -E s/[0-9]+\.[0-9]+\.//)
minor=$(echo $version | sed s#$major\.## | sed s#\\.$dev_num## )
major=$(echo $cur_ver | grep -Eo "^[0-9]+")
dev_num=$(echo $cur_ver | sed -E s/[0-9]+\.[0-9]+\.//)
minor=$(echo $cur_ver | sed s#$major\.## | sed s#\\.$dev_num## )
if [ $((dev_num + 1)) -gt 99 ]; then
echo "dev_num greater than 99 increment minor"
Expand All @@ -51,10 +51,12 @@ else
dev_num=$((dev_num + 1))
fi
new_version=$major.$minor.$dev_num
ver=$major.$minor.$dev_num
echo "Detected version: "$version
echo "New version to apply: "$new_version
echo "Detected version: "$cur_ver
echo "New version to apply: "$ver
sed -i s#version_gui=TO_AUTO_COMPLETE#version_gui=$new_version# $rootdevice_file
sed -i s#version_gui=TO_AUTO_COMPLETE#version_gui=$ver# $rootdevice_file
fi
echo $ver > $HOME/gui_build/data/version
22 changes: 10 additions & 12 deletions scripts/3-update_autobuild_ver.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
if [ $CI == "true" ]; then
if [ -f ~/.dev ]; then
TYPE="$(cat ~/gui_build/data/type)"
if [ $TYPE == "DEV" ]; then
type="_dev"
elif [ -f ~/.stable ]; then
elif [ $TYPE == "STABLE" ]; then
stable_msg="STABLE"
fi
fi
md5sum=$(md5sum compressed/GUI$type.tar.bz2 | awk '{print $1}')
version=$(cat total/etc/init.d/rootdevice | grep -m1 version_gui | cut -d'=' -f 2)
version="$(cat ~/gui_build/data/version)"
if ! grep -w -q "$version" $HOME/gui-dev-build-auto/version ; then
echo "Adding md5sum of new GUI to version file"
echo "Version: "$version" Md5sum: "$md5sum
Expand All @@ -26,22 +27,19 @@ cp compressed/GUI$type.tar.bz2 $HOME/gui-dev-build-auto/ -r;
cd $HOME/gui-dev-build-auto/;

if [ $CI == "true" ]; then
if [ -f ~/.stable ]; then
build_type_name="STABLE"
echo $version > stable.version
elif [ -f ~/.dev ]; then
if [ ~/gui_build/data/type ]; then
build_type_name=$(cat ~/gui_build/data/type)
if [ $build_type_name == "STABLE" ]; then
echo $version > stable.version
fi
else
build_type_name="DEV"
fi
commit_link=https://github.com/Ansuel/tch-nginx-gui/commit/$CIRCLE_SHA1
fi

echo $version > latest.version

mkdir ~/gui_build/data

echo $version > ~/gui_build/data/version
echo $build_type_name > ~/gui_build/data/type

git add -A;
git commit -a -m "[$build_type_name] Version: $version Commit: $commit_link";
git push origin master;
Expand Down
4 changes: 4 additions & 0 deletions scripts/6-commit_po.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
git config --global user.name "CircleCI";
git config --global user.email "CircleCI";

ssh -o StrictHostKeyChecking=no git@github.com

cd $HOME/gui_build

Expand Down
6 changes: 3 additions & 3 deletions scripts/7-push-release.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

DIR="/tmp/gui_build/compressed"
VERSION="$(cat /tmp/gui_build/data/version)"
TYPE="$(cat /tmp/gui_build/data/type)"
DIR="$HOME/gui_build/compressed"
VERSION="$(cat $HOME/gui_build/data/version)"
TYPE="$(cat $HOME/gui_build/data/type)"
if [ $TYPE == "DEV" ]; then
PRERELEASE="-prerelease"
fi
Expand Down

0 comments on commit ffc0c3b

Please sign in to comment.