11#! /bin/bash
2- # ######################DO NOT USE YET########################
32
4- # # Build a framework release branch
3+ # # Build framework release branch & distributables
54
65# ---------------------------------------------------
76# Setup variables
87
9- UPSTREAM=https://github.com/codeigniter4/CodeIgniter4.git
8+ . admin/config
9+
10+ # ---------------------------------------------------
11+ # Sanity check - are we underway already?
12+ if [ -n " $RELEASE " ]; then
13+ echo -e " ${BOLD}${ERROR} A release build is already underway${NORMAL} "
14+ exit 1
15+ fi
16+
1017action=test
1118version=4
1219qualifier=
1320
1421branch=release-
1522releasable=' application docs public system writable README.md composer.json contributing.md env license.txt spark'
16- release_empty=' tests tests/_support'
1723which=release
1824
19- BOLD=' \033[1m'
20- NORMAL=' \033[0m'
21- COLOR=' \033[1;31m'
22- ERROR=' \033[0;31m'
23-
2425echo -e " ${BOLD}${COLOR} CodeIgniter4 release builder${NORMAL} "
2526echo ' ----------------------------'
2627
@@ -29,7 +30,7 @@ echo '----------------------------'
2930echo -e " ${BOLD} Checking arguments...${NORMAL} "
3031
3132if [ $# -lt 1 ]; then
32- echo -e " ${BOLD} Usage: admin/release version# pre-release-qualifier${NORMAL} "
33+ echo -e " ${BOLD} Usage: admin/pre- release version# pre-release-qualifier${NORMAL} "
3334 exit 1
3435fi
3536
@@ -39,7 +40,8 @@ if [ $# -gt 1 ]; then
3940 qualifier=" -${2} "
4041 which=' pre-release'
4142fi
42- branch=" release-$version$qualifier "
43+ RELEASE=$version$qualifier
44+ branch=" release-$RELEASE "
4345
4446# ---------------------------------------------------
4547# Create the release branch
@@ -57,39 +59,51 @@ echo -e "${BOLD}Updating version dependencies${NORMAL}"
5759function check_unique {
5860 count=` grep -c ' $1' < $2 | wc -l`
5961 if [ $count -ne 1 ]; then
60- echo -e " ${BOLD}${COLOR} $2 has ${count} occurences of '$1 '${NORMAL} "
62+ echo -e " ${BOLD}${COLOR} $2 has ${count} occurrences of '$1 '${NORMAL} "
6163 exit 1
6264 fi
6365}
6466
6567# Make sure there is only one line to affect in each file
6668check_unique " const CI_VERSION" ' system/CodeIgniter.php'
6769check_unique " release =" ' user_guide_src/source/conf.py'
68- check_unique " |release|" ' user_guide_src/source/changelog .rst'
69- check_unique " Release Date.*Not Released" ' user_guide_src/source/changelog .rst'
70+ check_unique " |release|" ' user_guide_src/source/changelogs/index .rst'
71+ check_unique " Release Date.*Not Released" ' user_guide_src/source/changelogs/index .rst'
7072
7173# CI_VERSION definition in system/CodeIgniter.php
72- sed -i " /const CI_VERSION/s/'.*'/'${version}${qualifier } '/" system/CodeIgniter.php
74+ sed -i " /const CI_VERSION/s/'.*'/'${RELEASE } '/" system/CodeIgniter.php
7375
7476# release substitution variable in user_guide_src/source/conf.py
75- sed -i " /release =/s/'.*'/'${version}${qualifier } '/" user_guide_src/source/conf.py
77+ sed -i " /release =/s/'.*'/'${RELEASE } '/" user_guide_src/source/conf.py
7678
7779# version & date in user_guide_src/source/changelog.rst
78- sed -i " /|release|/s/|.*|/${version}${qualifier} /" user_guide_src/source/changelog.rst
79- sed -i " /Release Date/s/Not Released/$( date +' %B %d, %Y' ) /" user_guide_src/source/changelog.rst
80+ sed -i " /|release|/s/|.*|/${RELEASE} /" user_guide_src/source/changelogs/index.rst
81+ sed -i " /Release Date/s/Not Released/$( date +' %B %d, %Y' ) /" user_guide_src/source/changelogs/index.rst
82+
83+ # establish version-specific changelog
84+ mv user_guide_src/source/changelogs/next.rst user_guide_src/source/changelogs/${RELEASE} .rst
85+ # start new changelog for next version
8086
8187# ---------------------------------------------------
8288# Setup the distribution folders
89+ echo -e " ${BOLD} Building repo distributions${NORMAL} "
90+
91+ function setup_repo {
92+ mkdir dist/$1
93+ cd dist/$1
94+ git init
95+ git remote add origin ${CI_ORG} /$1
96+ git fetch
97+ }
8398
8499if [ -d dist ]; then
85100 rm -rf dist/
86101fi
87102mkdir dist
88103
89- if [ -d build ]; then
90- rm -rf build/
91- fi
92- mkdir build
104+ setup_repo framework
105+ setup_repo docs
106+ setup_repo app-starter
93107
94108# ---------------------------------------------------
95109# Generate the user guide
@@ -104,32 +118,34 @@ make epub
104118
105119cd ..
106120
107- mv user_guide_src/build/html build/docs
121+ cp -rf user_guide_src/build/html dist/docs
122+ mv user_guide_src/built/html dist/framework/docs
123+
124+ cd dist/docs
125+ git checkout gh-pages
126+ cp -r ../../docs .
108127
109128# ---------------------------------------------------
110129# And finally, get ready for merging
111130git add .
112- git commit -m " Release ${version}${qualifier } "
131+ git commit -m " Release ${RELEASE } "
113132
114133# ---------------------------------------------------
115134# Hide stuff from the release bundle
116135echo -e " ${BOLD} Build the distributables${NORMAL} "
117136
118- for f in $releasable ; do
119- cp -r $f build/
120- done
121- for f in $release_empty ; do
122- mkdir build/$f
123- done
124-
125137# add the docs
126- mv user_guide_src/build/epub/CodeIgniter4.epub dist/CodeIgniter-${version}${qualifier } .epub
138+ mv user_guide_src/build/epub/CodeIgniter4.epub dist/CodeIgniter-${BRANCH } .epub
127139
128140cd build
129- zip -r ../dist/v${version}${qualifier} .zip *
130- tar -zcf ../dist/v${version}${qualifier} .tar.gz *
141+ zip -r ../dist/v${RELEASE} .zip *
142+ tar -zcf ../dist/v${RELEASE} .tar.gz *
143+
144+ # ---------------------------------------------------
145+ # Save the in-progress branch designation for following steps
146+ sed -i " /RELEASE=/s/=.*/=${RELEASE} /" admin/config
131147
132148# ---------------------------------------------------
133149# Done for now
134150echo -e " ${BOLD} Your $branch branch is ready to inspect.${NORMAL} "
135- echo -e " ${BOLD} Follow the directions in release .md to continue.${NORMAL} "
151+ echo -e " ${BOLD} Follow the directions in workflow .md to continue.${NORMAL} "
0 commit comments