build: setup for local development

This commit is contained in:
JoniVR 2021-12-11 17:14:43 +01:00
parent e8db504745
commit c2a5fc60c6
No known key found for this signature in database
GPG key ID: 3C8F6B8A7809ACDA
5 changed files with 26 additions and 72 deletions

5
.gitignore vendored
View file

@ -1,2 +1,7 @@
### macOS ###
.DS_Store
# jekyll local
.jekyll-cache
.sass-cache
_site

View file

@ -1,5 +1,17 @@
This branch is reserved for the project GitHub pages.
# MonitorControl Github Pages
To test Github pages locally, follow:
## Development
### Using Docker (recommended)
See [starefossen/github-pages](https://github.com/Starefossen/docker-github-pages):
```sh
docker run -it --rm -v "$PWD":/usr/src/app -p "4000:4000" starefossen/github-pages
```
or run the handy `docker.sh` script.
### Using jekyll local install
<https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/testing-your-github-pages-site-locally-with-jekyll>

4
docker.sh Normal file
View file

@ -0,0 +1,4 @@
#!/bin/bash
cd docs
docker run -it --rm -v "$PWD":/usr/src/app -p "4000:4000" starefossen/github-pages

View file

@ -3,3 +3,6 @@ defaults:
path: 'wiki'
values:
layout: 'wiki'
repository: MonitorControl/MonitorControl
theme: jekyll-theme-primer

View file

@ -1,70 +0,0 @@
#!/bin/bash
# Note: Make sure to only run this script after posting release notes in Github with a release!
# Could be expanded to also do appcast.xml updates?
exists() {
type "$1" &>/dev/null && return 0 || return 1
}
show_error() {
local msg="Error!"
if [ ! -z "$1" ]; then
msg="$1"
fi
echo -e "\033[0;31m${msg}\033[0m"
}
show_warning() {
local msg="Warning!"
if [ ! -z "$1" ]; then
msg="$1"
fi
echo -e "\033[0;33m${msg}\033[0m"
}
show_success() {
local msg="Success!"
if [ ! -z "$1" ]; then
msg="$1"
fi
echo -e "\033[0;32m${msg}\033[0m"
}
if ! exists jq; then
show_error "\`jq\` is required but not installed. Install using: brew install jq"
exit 127
fi
if ! exists pandoc; then
show_error "\`pandoc\` is required but not installed. Install using: brew install pandoc"
exit 127
fi
# TODO: Expand to check last x (per_page) releases (input parameter or fallback)
URL="https://api.github.com/repos/MonitorControl/MonitorControl/releases?per_page=1"
# store the whole response
HTTP_RESPONSE=$(curl --fail -s $URL)
if [ $? != 0 ]; then
show_error "Something went wrong getting Github Release info. Exiting..."
exit 1
fi
TAG=`echo $HTTP_RESPONSE | jq '.[0].tag_name' -r`
DIR="`dirname $0`/../docs/changelogs/"
FILE_NAME="${TAG}.html"
FILE="$DIR$FILE_NAME"
if [ -f $FILE ]; then
show_warning "\"$FILE_NAME\" Already exists! Will be overwritten.."
fi
echo $HTTP_RESPONSE | jq '.[0].body' -r | pandoc --template $DIR/template.html --metadata title="$TAG" -o $FILE
if [ $? -eq 0 ]; then
show_success "\"$FILE_NAME\" Created at \"$DIR\""
fi
exit