First pass at a build/release script. Closes #2

This commit is contained in:
Gabe Kangas 2020-06-16 17:27:55 -07:00
parent 195fe5d9e3
commit c8fa2add17
2 changed files with 68 additions and 1 deletions

View file

@ -9,6 +9,11 @@ import (
log "github.com/sirupsen/logrus"
)
// Build-time injected values
var GitCommit string = "unknown"
var BuildVersion string = "0.0.0"
var BuildType string = "localdev"
var storage ChunkStorage
var configuration = getConfig()
var server *Server
@ -17,7 +22,8 @@ var stats *Stats
var usingExternalStorage = false
func main() {
log.Println("Starting up. Please wait...")
log.StandardLogger().Printf("Owncast v%s/%s (%s)", BuildVersion, BuildType, GitCommit)
resetDirectories(configuration)
checkConfig(configuration)
stats = getSavedStats()

61
scripts/build.sh Executable file
View file

@ -0,0 +1,61 @@
#!/bin/sh
# Human readable names of binary distributions
DISTRO=(macOS linux)
# Operating systems for the respective distributions
OS=(darwin linux)
# Architectures for the respective distributions
ARCH=(amd64 amd64)
# Version
VERSION=$1
[[ -z "${VERSION}" ]] && VERSION='unknownver' || VERSION="${VERSION}"
GIT_COMMIT=$(git rev-list -1 HEAD)
# Change to the root directory of the repository
cd $(git rev-parse --show-toplevel)
echo "Cleaning working directories..."
rm -rf ./webroot/hls/* ./hls/* ./webroot/thumbnail.png
echo "Creating version ${VERSION} from commit ${GIT_COMMIT}"
mkdir -p dist
build() {
NAME=$1
OS=$2
ARCH=$3
VERSION=$4
GIT_COMMIT=$5
echo "Building ${NAME} (${OS}/${ARCH}) release..."
mkdir -p dist/${NAME}/config
cp config/config-example.yaml dist/${NAME}/config/config.yaml
cp -R webroot/ dist/${NAME}/webroot/
cp -R doc/ dist/${NAME}/doc/
cp README.md dist/${NAME}
env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH go build -ldflags "-X main.GitCommit=$GIT_COMMIT -X main.BuildVersion=$VERSION -X main.BuildType=$NAME" -a -o dist/$NAME/owncast
pushd dist/${NAME} >> /dev/null
zip -r -q -8 ../owncast-$NAME-$VERSION.zip .
popd >> /dev/null
rm -rf dist/${NAME}/
}
for i in "${!DISTRO[@]}"; do
build ${DISTRO[$i]} ${OS[$i]} ${ARCH[$i]} $VERSION $GIT_COMMIT
done
# Create the tag
git tag -a "v${VERSION}" -m "Release build v${VERSION}"
# On macOS open the Github page for new releases so they can be uploaded
if test -f "/usr/bin/open"; then
open "https://github.com/gabek/owncast/releases/new"
open dist
fi