Skip to content

Commit

Permalink
Update build script and add config-only build mode (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Apr 28, 2022
1 parent db70303 commit e9deb56
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ There is a detailled end-user manual available [in German](https://gbv.github.io

## Configuration

For the pre-built version, configuration options can be overridden by using `cocoda.json` in the root of the directory. The default options are given in the file [`config/cocoda.default.json`](https://github.com/gbv/cocoda/blob/dev/config/cocoda.default.json) (please consult this file for examples on how to use the configuration options). When using a manual build, create file `config/cocoda.json` and rebuild (`npm run build`) after editing. The following fields are recognized so far:
For the pre-built version, configuration options can be overridden by using `cocoda.json` in the root of the directory. The default options are given in the file [`config/cocoda.default.json`](https://github.com/gbv/cocoda/blob/dev/config/cocoda.default.json) (please consult this file for examples on how to use the configuration options). When using a manual build, create file `config/cocoda.json` and rebuild (`npm run build`) after editing (you can also run `npm run build -- --config-only` if you already have a build in folder `dist/` and only need to update the config file). The following fields are recognized so far:

* **title**: the main title of the instance as plain string

Expand Down
31 changes: 21 additions & 10 deletions build/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/bash

# check if build script is run as config-only
CONFIG_ONLY=
if [[ \ $*\ == *\ --config-only\ * ]]; then
CONFIG_ONLY=yes
fi

# get github-milestones.json if it doesn't exist yet
DELETE_TEMP=
if [ ! -e ./temp/github-milestones.json ]; then
Expand All @@ -18,7 +24,6 @@ echo "Building for branch $GIT_BRANCH ($GIT_COMMIT_SHORT)..."

# if there was no config file before, remember this and delete the generated config at the end of the script
USERCONFIG=
MALFORMED_CONFIG=

if [ -e ./config/cocoda.json ]; then
# Check for JSON validity
Expand All @@ -36,21 +41,27 @@ fi
# make sure a cocoda.json file exists in all cases
[ ! -e ./config/cocoda.json ] && echo "Using empty user config for build..." && echo -n "{}" > ./config/cocoda.json

# build the app
vite build
success=$?
# build the app OR copy config file
if [ $CONFIG_ONLY ]; then
echo "--config-only is given; copying cocoda.json to dist/"
cp ./config/cocoda.json ./dist/cocoda.json
success=$?
else
vite build
success=$?
fi

if [ $success -ne 0 ]; then
echo "Build has failed!"
fi

if [ $success -eq 0 ]; then
if [ $success -eq 0 ] && [ ! $CONFIG_ONLY ]; then
# remove previous dist directory
[ -e dist/ ] && [ -e dist-temp/ ] && rm -r dist
# rename dist-temp to dist
[ -e dist-temp/ ] && mv dist-temp dist
else
echo "Build has failed!"
fi

# create and move user manual
if [ $success -eq 0 ]; then
# create and move user manual
PANDOC=$(pandoc --version 2>/dev/null | awk 'NR==1 && $2>=2 {print}')
MODIFIED_DOCS=$(git show --pretty="" --name-only HEAD docs/)
TAGGED_COMMIT=$(git describe --exact-match --tags 2>/dev/null)
Expand Down

0 comments on commit e9deb56

Please sign in to comment.