Skip to content

Commit

Permalink
Post all builds on master
Browse files Browse the repository at this point in the history
  • Loading branch information
genotrance authored and dom96 committed Oct 16, 2020
1 parent a076af9 commit f64db90
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 28 deletions.
47 changes: 21 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,41 @@ env:
cache:
directories:
- "$HOME/.choosenim"
- "$TRAVIS_BUILD_DIR/git"

addons:
apt:
update: true
packages:
- musl-tools

install:
# Use common Travis script maintained as a gist
# https://gist.github.com/genotrance/fb53504a4fba88bc5201d3783df5c522
- curl https://gist.github.com/genotrance/fb53504a4fba88bc5201d3783df5c522/raw/travis.sh -LsSf -o travis.sh
- source travis.sh

script:
- nimble install -y -d
- nim c src/choosenim
- nimble test
- yes | ./bin/choosenim stable # Workaround tester overwriting our Nimble install.
- export VERSION="$(./bin/choosenim --version | cut -f2,2 -d' ' | sed 's/v//')"
- export EXT=""
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then export EXT=".exe"; fi
- export OSNAME="$TRAVIS_OS_NAME"
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export OSNAME="macosx"; fi
- export ARCH="amd64"
- mv "bin/choosenim${EXT}" "bin/choosenim-${VERSION}_${OSNAME}_${ARCH}_debug${EXT}"
- nimble build -d:release
- mv "bin/choosenim${EXT}" "bin/choosenim-${VERSION}_${OSNAME}_${ARCH}${EXT}"
- ls -l bin
- source build.sh

notifications:
irc: "chat.freenode.net#nimbuild"

before_deploy:
- git config --local user.name "${GIT_TAG_USER_NAME}"
- git config --local user.email "${GIT_TAG_USER_EMAIL}"

deploy:
provider: releases
api_key:
secure: "h7HQnn/pVHyR119IViY811WeX4lMl+hLpmMMND09r3LVOaH9MpMSkwQXa4aYF+/YV3vHaQINOExqTOXpzc/nP5O5VJMzfaEdA+o6HtkVgY1qsWllquUt0xnrvcFCLHcNQc/fwoS6Cow4yINsRTyGgo7p4zLnk5+yGSQTJiLTiMWHQiiRyCdrywBHFzcXG63MqRD7JJveA0OE/JoRNBNESGP6JTK6V7W2eanmlAjbjH8+dUJsxDr5LjoeRUUF+A+4AfulAOCsbPtURW3CIBD1jqYrFXzBYRgxbHaHwY5XxfPjHnWPHONYIruXx9oYyjL8uyrHzYSNCEnoQtBY0gzYOBFfUCNB3bcNDrSkzTXnRlnMcWcC6XyrTxUI7Lc+bZB5OFGoqYJzZK54qd5wmIDqZ+Wa2n1vq/hNfZ+95fYhG7oXgW/zeLWFdr8i46dRoBDfcD2e+OhJLk73FoGVwySffR2p5hCGWLdXFyMKiph1RC8JPiwMr4l6n9LmO1fbOwAjwTEXzj645mC1ExmsiTckGlOQC8UuvnxWg9xNggO40PCTuO64hF4YucDi6SzYttNn5VNli2XoWz9SkgQiKAxf4u2VN+S2Vt0Mtue8Z6CTb2GjEO+QrmVrW3oQmiCFM0LkiAo+0zoo8JK7PuT5EoAabfc0aZt/Ds8cLhPpoHQFxMY="
- provider: releases
api_key: "${GITHUB_OAUTH_TOKEN}"
file_glob: true
file: bin/choosenim-*
skip_cleanup: true
overwrite: true
prerelease: false
on:
tags: true
condition: "-z ${PRERELEASE+x}"
- provider: releases
api_key: "${GITHUB_OAUTH_TOKEN}"
file_glob: true
file: bin/*
file: bin/choosenim-*
skip_cleanup: true
overwrite: true
prerelease: true
on:
repo: dom96/choosenim
tags: true
condition: "! -z ${PRERELEASE+x}"
68 changes: 68 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#! /bin/bash

# Use common Travis script - https://github.com/genotrance/nim-travis
curl https://raw.githubusercontent.com/genotrance/nim-travis/master/travis.sh -LsSf -o travis.sh
source travis.sh

# Skip building autotagged version
export COMMIT_TAG=`git tag --points-at HEAD | head -n 1`
export CURRENT_BRANCH="${TRAVIS_BRANCH}"
echo "Commit tag: ${COMMIT_TAG}"
echo "Current branch: ${CURRENT_BRANCH}"
if [[ "${COMMIT_TAG}" =~ ^v[0-9.]+-[0-9]+$ ]]; then
echo "Skipping build since autotagged version"
else
# Environment vars
if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
export EXT=".exe"
else
export EXT=""
fi

if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
export OSNAME="macosx"
else
export OSNAME="$TRAVIS_OS_NAME"
fi

# Build and test
nimble install -y -d
nim c src/choosenim

# Set version and tag info
export CHOOSENIM_VERSION="$(./src/choosenim --version | cut -f2,2 -d' ' | sed 's/v//')"
echo "Version: v${CHOOSENIM_VERSION}"
if [[ -z "${COMMIT_TAG}" ]]; then
# Create tag with date, not an official tagged release
export VERSION_TAG="${CHOOSENIM_VERSION}-$(date +'%Y%m%d')"
if [[ "${CURRENT_BRANCH}" == "master" ]]; then
# Deploy only on main branch
export TRAVIS_TAG="v${VERSION_TAG}"
export PRERELEASE=true
fi
elif [[ "${COMMIT_TAG}" == "v${CHOOSENIM_VERSION}" ]]; then
# Official tagged release
export VERSION_TAG="${CHOOSENIM_VERSION}"
export TRAVIS_TAG="${COMMIT_TAG}"
else
echo "Tag does not match choosenim version"
echo " Commit tag: ${COMMIT_TAG}"
echo " Version: v${CHOOSENIM_VERSION}"
echo " Current branch: ${CURRENT_BRANCH}"
travis_terminate 1
fi
echo "Travis tag: ${TRAVIS_TAG}"
echo "Prerelease: ${PRERELEASE}"
export FILENAME="bin/choosenim-${VERSION_TAG}_${OSNAME}_${TRAVIS_CPU_ARCH}"
echo "Filename: ${FILENAME}"

# Run tests
nimble test
yes | ./bin/choosenim stable # Workaround tester overwriting our Nimble install.
mv "bin/choosenim${EXT}" "${FILENAME}_debug${EXT}"

# Build release version
nimble build -d:release
strip "bin/choosenim${EXT}"
mv "bin/choosenim${EXT}" "${FILENAME}${EXT}"
fi
2 changes: 1 addition & 1 deletion choosenim.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.6.0"
version = "0.6.1"
author = "Dominik Picheta"
description = "The Nim toolchain installer."
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/choosenimpkg/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type
ChooseNimError* = object of NimbleError

const
chooseNimVersion* = "0.6.0"
chooseNimVersion* = "0.6.1"

proxies* = [
"nim",
Expand Down

0 comments on commit f64db90

Please sign in to comment.