Add autorelease for linux distros, osx and windows (#923)
This commit is contained in:
@@ -0,0 +1,188 @@
|
|||||||
|
version: 2
|
||||||
|
|
||||||
|
build-distro-bin: &build-distro-bin
|
||||||
|
machine: true
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
# cannot interpolate env var and use as a cache key so just copy the Dockerfile to another filename
|
||||||
|
- run: cp docker/distro_release/Dockerfile.$CIRCLE_JOB docker/distro_release/Dockerfile
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- v1-{{ .Environment.CIRCLE_JOB }}-image-{{ checksum "docker/distro_release/Dockerfile" }}
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- v1-{{ .Environment.CIRCLE_JOB }}-dependencies-{{ checksum "postgrest.cabal" }}-{{ checksum "stack.yaml" }}
|
||||||
|
- run:
|
||||||
|
name: load or build docker image
|
||||||
|
command: |
|
||||||
|
if [[ -e ~/image.tar ]]; then
|
||||||
|
docker load -i ~/image.tar
|
||||||
|
else
|
||||||
|
docker build --rm=false -t $CIRCLE_JOB -f docker/distro_release/Dockerfile.$CIRCLE_JOB docker/distro_release/
|
||||||
|
docker save $CIRCLE_JOB > ~/image.tar
|
||||||
|
fi
|
||||||
|
- run:
|
||||||
|
name: build binary
|
||||||
|
command: |
|
||||||
|
docker run -it \
|
||||||
|
-v $HOME/.stack:/root/.stack \
|
||||||
|
-v $(pwd):/source \
|
||||||
|
-v $HOME/bin/:/root/.local/bin/ \
|
||||||
|
$CIRCLE_JOB build --allow-different-user --install-ghc --copy-bins
|
||||||
|
# volumes owned by root if chown is not done the save_cache step fails silently
|
||||||
|
sudo chown -R circleci:circleci ~/.stack .stack-work
|
||||||
|
- run:
|
||||||
|
name: compress binary
|
||||||
|
command: |
|
||||||
|
mkdir -p /tmp/workspace/bin
|
||||||
|
cd /tmp/workspace/bin
|
||||||
|
tar cvJf postgrest-$CIRCLE_TAG-$CIRCLE_JOB.tar.xz -C ~/bin postgrest
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: /tmp/workspace
|
||||||
|
paths:
|
||||||
|
- bin/*
|
||||||
|
- save_cache:
|
||||||
|
paths:
|
||||||
|
- ~/image.tar
|
||||||
|
key: v1-{{ .Environment.CIRCLE_JOB }}-image-{{ checksum "docker/distro_release/Dockerfile" }}
|
||||||
|
- save_cache:
|
||||||
|
paths:
|
||||||
|
- "~/.stack"
|
||||||
|
- ".stack-work"
|
||||||
|
key: v1-{{ .Environment.CIRCLE_JOB }}-dependencies-{{ checksum "postgrest.cabal" }}-{{ checksum "stack.yaml" }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-test:
|
||||||
|
machine: true
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- restore_cache:
|
||||||
|
keys:
|
||||||
|
- v1-stack-dependencies-{{ checksum "postgrest.cabal" }}-{{ checksum "stack.yaml" }}
|
||||||
|
- run:
|
||||||
|
name: install stack & dependencies
|
||||||
|
command: |
|
||||||
|
curl -L https://github.com/commercialhaskell/stack/releases/download/v1.1.2/stack-1.1.2-linux-x86_64.tar.gz | tar zx -C /tmp
|
||||||
|
sudo mv /tmp/stack-1.1.2-linux-x86_64/stack /usr/bin
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install libgmp-dev
|
||||||
|
sudo apt-get install --only-upgrade binutils
|
||||||
|
stack setup
|
||||||
|
rm -rf $(stack path --dist-dir) $(stack path --local-install-root)
|
||||||
|
stack install hlint packdeps cabal-install
|
||||||
|
- run:
|
||||||
|
name: build src and tests
|
||||||
|
command: |
|
||||||
|
stack build --fast -j1
|
||||||
|
stack build --fast --test --no-run-tests
|
||||||
|
- run:
|
||||||
|
name: run tests
|
||||||
|
command: |
|
||||||
|
sudo service postgresql start
|
||||||
|
POSTGREST_TEST_CONNECTION=$(test/create_test_db "postgres://circleci@localhost" postgrest_test) stack test
|
||||||
|
test/io-tests.sh
|
||||||
|
- run:
|
||||||
|
name: run linter
|
||||||
|
command: git ls-files | grep '\.l\?hs$' | xargs stack exec -- hlint -X QuasiQuotes -X NoPatternSynonyms "$@"
|
||||||
|
- run:
|
||||||
|
name: extra checks
|
||||||
|
command: |
|
||||||
|
stack exec -- cabal update
|
||||||
|
stack exec --no-ghc-package-path -- cabal install --only-d --dry-run
|
||||||
|
stack exec -- packdeps *.cabal || true
|
||||||
|
stack exec -- cabal check
|
||||||
|
stack haddock --no-haddock-deps
|
||||||
|
stack sdist
|
||||||
|
- save_cache:
|
||||||
|
paths:
|
||||||
|
- "~/.stack"
|
||||||
|
- ".stack-work"
|
||||||
|
key: v1-stack-dependencies-{{ checksum "postgrest.cabal" }}-{{ checksum "stack.yaml" }}
|
||||||
|
|
||||||
|
centos6:
|
||||||
|
<<: *build-distro-bin
|
||||||
|
|
||||||
|
centos7:
|
||||||
|
<<: *build-distro-bin
|
||||||
|
|
||||||
|
ubuntu:
|
||||||
|
<<: *build-distro-bin
|
||||||
|
|
||||||
|
ubuntui386:
|
||||||
|
<<: *build-distro-bin
|
||||||
|
|
||||||
|
release:
|
||||||
|
docker:
|
||||||
|
- image: circleci/golang:1.8
|
||||||
|
steps:
|
||||||
|
- attach_workspace:
|
||||||
|
at: /tmp/workspace
|
||||||
|
- checkout
|
||||||
|
- run:
|
||||||
|
name: add body and tars to github release
|
||||||
|
command: |
|
||||||
|
go get -u github.com/tcnksm/ghr
|
||||||
|
START=$(echo $CIRCLE_TAG | cut -c2-)
|
||||||
|
END='## \['
|
||||||
|
BODY=$(sed -n "1,/$START/d;/$END/q;p" CHANGELOG.md)
|
||||||
|
ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME -b "$BODY" --replace $CIRCLE_TAG /tmp/workspace/bin
|
||||||
|
- setup_remote_docker
|
||||||
|
- run:
|
||||||
|
name: publish docker image
|
||||||
|
command: |
|
||||||
|
docker build --build-arg POSTGREST_VERSION=$CIRCLE_TAG -t postgrest ./docker/
|
||||||
|
docker login -u $DOCKER_USER -p $DOCKER_PASS
|
||||||
|
docker tag postgrest postgrest/postgrest:$CIRCLE_TAG
|
||||||
|
docker push postgrest/postgrest:$CIRCLE_TAG
|
||||||
|
docker tag postgrest postgrest/postgrest:latest
|
||||||
|
docker push postgrest/postgrest:latest
|
||||||
|
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
build-test-release:
|
||||||
|
jobs:
|
||||||
|
- build-test:
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /v[0-9]+(\.[0-9]+)*/
|
||||||
|
- centos6:
|
||||||
|
requires:
|
||||||
|
- build-test
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /v[0-9]+(\.[0-9]+)*/
|
||||||
|
branches:
|
||||||
|
ignore: /.*/
|
||||||
|
- centos7:
|
||||||
|
requires:
|
||||||
|
- build-test
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /v[0-9]+(\.[0-9]+)*/
|
||||||
|
branches:
|
||||||
|
ignore: /.*/
|
||||||
|
- ubuntu:
|
||||||
|
requires:
|
||||||
|
- build-test
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /v[0-9]+(\.[0-9]+)*/
|
||||||
|
branches:
|
||||||
|
ignore: /.*/
|
||||||
|
- ubuntui386:
|
||||||
|
requires:
|
||||||
|
- build-test
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /v[0-9]+(\.[0-9]+)*/
|
||||||
|
branches:
|
||||||
|
ignore: /.*/
|
||||||
|
- release:
|
||||||
|
requires:
|
||||||
|
- centos6
|
||||||
|
- centos7
|
||||||
|
- ubuntu
|
||||||
|
- ubuntui386
|
||||||
|
filters:
|
||||||
|
tags:
|
||||||
|
only: /v[0-9]+(\.[0-9]+)*/
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
language: generic
|
||||||
|
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
os:
|
||||||
|
- osx
|
||||||
|
|
||||||
|
cache:
|
||||||
|
timeout: 1000
|
||||||
|
directories:
|
||||||
|
- $HOME/.stack
|
||||||
|
- $HOME/.local/bin
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- mkdir -p "$HOME/.local/bin"
|
||||||
|
- export PATH="$PATH:$HOME/.local/bin"
|
||||||
|
|
||||||
|
install:
|
||||||
|
- |
|
||||||
|
if test -f "$HOME/.local/bin/stack"
|
||||||
|
then
|
||||||
|
echo 'Stack is already installed.'
|
||||||
|
else
|
||||||
|
echo "Installing Stack..."
|
||||||
|
travis_retry curl -L https://www.stackage.org/stack/osx-x86_64 > stack.tar.gz
|
||||||
|
gunzip stack.tar.gz
|
||||||
|
tar -x -f stack.tar --strip-components 1
|
||||||
|
mv stack "$HOME/.local/bin/"
|
||||||
|
rm stack.tar
|
||||||
|
fi
|
||||||
|
- |
|
||||||
|
if test -f "$HOME/.local/bin/ghr"
|
||||||
|
then
|
||||||
|
echo 'ghr is already installed.'
|
||||||
|
else
|
||||||
|
echo "Installing ghr..."
|
||||||
|
travis_retry curl -L https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_darwin_386.zip > ghr.zip
|
||||||
|
unzip ghr.zip -d "$HOME/.local/bin"
|
||||||
|
rm ghr.zip
|
||||||
|
fi
|
||||||
|
|
||||||
|
script:
|
||||||
|
- gtimeout 1800 stack build --no-terminal --only-snapshot --install-ghc || true
|
||||||
|
- |
|
||||||
|
if test ! "$TRAVIS_TAG"
|
||||||
|
then
|
||||||
|
echo 'No tag pushed. Skipping build.'
|
||||||
|
else
|
||||||
|
stack build --no-terminal --copy-bins --local-bin-path .
|
||||||
|
fi
|
||||||
|
- |
|
||||||
|
if test ! "$TRAVIS_TAG"
|
||||||
|
then
|
||||||
|
echo 'No tag pushed. Skipping release.'
|
||||||
|
else
|
||||||
|
OWNER="$(echo "$TRAVIS_REPO_SLUG" | cut -f1 -d/)"
|
||||||
|
REPO="$(echo "$TRAVIS_REPO_SLUG" | cut -f2 -d/)"
|
||||||
|
START=$(echo $TRAVIS_TAG | cut -c2-)
|
||||||
|
END='## \['
|
||||||
|
BODY=$(sed -n "1,/$START/d;/$END/q;p" CHANGELOG.md)
|
||||||
|
strip postgrest
|
||||||
|
tar cjf postgrest-$TRAVIS_TAG-osx.tar.xz postgrest
|
||||||
|
ghr -t $GITHUB_TOKEN -u $OWNER -r $REPO -b "$BODY"--replace $TRAVIS_TAG postgrest-$TRAVIS_TAG-osx.tar.xz
|
||||||
|
fi
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
platform: x64
|
||||||
|
|
||||||
|
cache:
|
||||||
|
- "c:\\sr"
|
||||||
|
- .stack-work
|
||||||
|
|
||||||
|
environment:
|
||||||
|
global:
|
||||||
|
STACK_ROOT: "c:\\sr"
|
||||||
|
GOPATH: c:\gopath
|
||||||
|
|
||||||
|
test: off
|
||||||
|
|
||||||
|
skip_non_tags: true
|
||||||
|
|
||||||
|
skip_branch_with_pr: true
|
||||||
|
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
|
||||||
|
install:
|
||||||
|
- set PATH=C:\Program Files\PostgreSQL\9.6\bin\;%PATH%
|
||||||
|
- curl -sS -ostack.zip -L --insecure http://www.stackage.org/stack/windows-x86_64
|
||||||
|
- 7z x stack.zip stack.exe
|
||||||
|
- set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
|
||||||
|
- go get -u github.com/tcnksm/ghr
|
||||||
|
|
||||||
|
build_script:
|
||||||
|
- stack setup --no-terminal > nul
|
||||||
|
- stack build --copy-bins --local-bin-path .
|
||||||
|
|
||||||
|
artifacts:
|
||||||
|
- path: postgrest.exe
|
||||||
|
|
||||||
|
deploy_script:
|
||||||
|
- 7z a -tzip postgrest-%APPVEYOR_REPO_TAG_NAME%-windows-x64.zip postgrest.exe
|
||||||
|
- bash -lc "exec 0</dev/null && cd $APPVEYOR_BUILD_FOLDER && ghr -t $GITHUB_TOKEN -u $APPVEYOR_ACCOUNT_NAME -r $APPVEYOR_PROJECT_NAME -b \"$(sed -n \"1,/$(echo $APPVEYOR_REPO_TAG_NAME | cut -c2-)/d;/## \[/q;p\" CHANGELOG.md)\" --replace $APPVEYOR_REPO_TAG_NAME postgrest-$APPVEYOR_REPO_TAG_NAME-windows-x64.zip"
|
||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
dependencies:
|
|
||||||
cache_directories:
|
|
||||||
- "~/.stack"
|
|
||||||
- ".stack-work"
|
|
||||||
pre:
|
|
||||||
- curl -L https://github.com/commercialhaskell/stack/releases/download/v1.1.2/stack-1.1.2-linux-x86_64.tar.gz | tar zx -C /tmp
|
|
||||||
- sudo mv /tmp/stack-1.1.2-linux-x86_64/stack /usr/bin
|
|
||||||
- sudo apt-get update; sudo apt-get install --only-upgrade binutils
|
|
||||||
override:
|
|
||||||
- stack setup
|
|
||||||
- rm -fr $(stack path --dist-dir) $(stack path --local-install-root)
|
|
||||||
- stack install hlint packdeps cabal-install
|
|
||||||
- stack build --fast -j1
|
|
||||||
- stack build --fast --test --no-run-tests
|
|
||||||
|
|
||||||
test:
|
|
||||||
override:
|
|
||||||
- POSTGREST_TEST_CONNECTION=$(test/create_test_db "postgres://ubuntu@localhost" postgrest_test) stack test
|
|
||||||
- test/io-tests.sh
|
|
||||||
- git ls-files | grep '\.l\?hs$' | xargs stack exec -- hlint -X QuasiQuotes -X NoPatternSynonyms "$@"
|
|
||||||
- stack exec -- cabal update
|
|
||||||
- stack exec --no-ghc-package-path -- cabal install --only-d --dry-run
|
|
||||||
- stack exec -- packdeps *.cabal || true
|
|
||||||
- stack exec -- cabal check
|
|
||||||
- stack haddock --no-haddock-deps
|
|
||||||
- stack sdist
|
|
||||||
+4
-3
@@ -1,5 +1,7 @@
|
|||||||
FROM debian:jessie
|
FROM debian:jessie
|
||||||
|
|
||||||
|
ARG POSTGREST_VERSION
|
||||||
|
|
||||||
# Install libpq5
|
# Install libpq5
|
||||||
RUN apt-get -qq update && \
|
RUN apt-get -qq update && \
|
||||||
apt-get -qq install -y --no-install-recommends libpq5 && \
|
apt-get -qq install -y --no-install-recommends libpq5 && \
|
||||||
@@ -7,12 +9,11 @@ RUN apt-get -qq update && \
|
|||||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
# Install postgrest
|
# Install postgrest
|
||||||
RUN POSTGREST_VERSION="0.4.2.0" \
|
RUN BUILD_DEPS="curl ca-certificates xz-utils" && \
|
||||||
BUILD_DEPS="curl ca-certificates xz-utils" && \
|
|
||||||
apt-get -qq update && \
|
apt-get -qq update && \
|
||||||
apt-get -qq install -y --no-install-recommends $BUILD_DEPS && \
|
apt-get -qq install -y --no-install-recommends $BUILD_DEPS && \
|
||||||
cd /tmp && \
|
cd /tmp && \
|
||||||
curl -SLO https://github.com/begriffs/postgrest/releases/download/v${POSTGREST_VERSION}/postgrest-${POSTGREST_VERSION}-ubuntu.tar.xz && \
|
curl -SLO https://github.com/begriffs/postgrest/releases/download/${POSTGREST_VERSION}/postgrest-${POSTGREST_VERSION}-ubuntu.tar.xz && \
|
||||||
tar -xJvf postgrest-${POSTGREST_VERSION}-ubuntu.tar.xz && \
|
tar -xJvf postgrest-${POSTGREST_VERSION}-ubuntu.tar.xz && \
|
||||||
mv postgrest /usr/local/bin/postgrest && \
|
mv postgrest /usr/local/bin/postgrest && \
|
||||||
cd / && \
|
cd / && \
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
FROM centos:centos6
|
||||||
|
|
||||||
|
RUN yum -y update
|
||||||
|
RUN yum -y install perl make automake gcc gmp-devel libffi zlib zlib-devel xz tar
|
||||||
|
RUN yum -y install https://download.postgresql.org/pub/repos/yum/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-2.noarch.rpm
|
||||||
|
RUN yum -y install postgresql93-devel
|
||||||
|
RUN yum clean all
|
||||||
|
RUN curl -sSL https://get.haskellstack.org/ | sh
|
||||||
|
|
||||||
|
ENV PATH $PATH:/usr/pgsql-9.3/bin
|
||||||
|
|
||||||
|
# To disable warning when building
|
||||||
|
ENV PATH $PATH:/root/.local/bin
|
||||||
|
|
||||||
|
RUN mkdir /source
|
||||||
|
WORKDIR /source
|
||||||
|
|
||||||
|
ENTRYPOINT ["stack"]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
FROM centos:centos7
|
||||||
|
|
||||||
|
RUN yum -y update
|
||||||
|
RUN yum -y install perl make automake gcc gmp-devel libffi zlib zlib-devel xz tar
|
||||||
|
RUN yum -y install yum install https://download.postgresql.org/pub/repos/yum/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-2.noarch.rpm
|
||||||
|
RUN yum -y install postgresql93-devel
|
||||||
|
RUN yum clean all
|
||||||
|
RUN curl -sSL https://get.haskellstack.org/ | sh
|
||||||
|
|
||||||
|
ENV PATH $PATH:/usr/pgsql-9.3/bin
|
||||||
|
|
||||||
|
# To disable warning when building
|
||||||
|
ENV PATH $PATH:/root/.local/bin
|
||||||
|
|
||||||
|
RUN mkdir /source
|
||||||
|
WORKDIR /source
|
||||||
|
|
||||||
|
ENTRYPOINT ["stack"]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
|
RUN BUILD_DEPS="curl ca-certificates build-essential" && \
|
||||||
|
apt-get -qq update && \
|
||||||
|
apt-get -qqy --no-install-recommends install \
|
||||||
|
$BUILD_DEPS \
|
||||||
|
libpq-dev && \
|
||||||
|
curl -sSL https://get.haskellstack.org/ | sh && \
|
||||||
|
apt-get -qq clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
|
# To disable warning when building
|
||||||
|
ENV PATH $PATH:/root/.local/bin
|
||||||
|
|
||||||
|
RUN mkdir /source
|
||||||
|
WORKDIR /source
|
||||||
|
|
||||||
|
ENTRYPOINT ["stack"]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
FROM 32bit/ubuntu:16.04
|
||||||
|
|
||||||
|
RUN BUILD_DEPS="curl ca-certificates build-essential" && \
|
||||||
|
apt-get -qq update && \
|
||||||
|
apt-get -qqy --no-install-recommends install \
|
||||||
|
$BUILD_DEPS \
|
||||||
|
libpq-dev && \
|
||||||
|
curl -sSL https://get.haskellstack.org/ | sh && \
|
||||||
|
apt-get -qq clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
|
# To disable warning when building
|
||||||
|
ENV PATH $PATH:/root/.local/bin
|
||||||
|
|
||||||
|
RUN mkdir /source
|
||||||
|
WORKDIR /source
|
||||||
|
|
||||||
|
ENTRYPOINT ["stack"]
|
||||||
Reference in New Issue
Block a user