diff --git a/.travis.yml b/.travis.yml index ca6ac1a..7d79d31 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,6 @@ env: cache: directories: - "$HOME/.choosenim" - - "$TRAVIS_BUILD_DIR/git" addons: apt: @@ -19,38 +18,34 @@ addons: 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}" diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..7088e8d --- /dev/null +++ b/build.sh @@ -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 diff --git a/choosenim.nimble b/choosenim.nimble index 68eb429..fbf80a2 100644 --- a/choosenim.nimble +++ b/choosenim.nimble @@ -1,6 +1,6 @@ # Package -version = "0.6.0" +version = "0.6.1" author = "Dominik Picheta" description = "The Nim toolchain installer." license = "MIT" diff --git a/src/choosenimpkg/common.nim b/src/choosenimpkg/common.nim index 43da328..b48b72e 100644 --- a/src/choosenimpkg/common.nim +++ b/src/choosenimpkg/common.nim @@ -4,7 +4,7 @@ type ChooseNimError* = object of NimbleError const - chooseNimVersion* = "0.6.0" + chooseNimVersion* = "0.6.1" proxies* = [ "nim",