diff --git a/.circleci/config.yml b/.circleci/config.yml index c6cd398150..7ac1911acc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -119,10 +119,14 @@ jobs: # Publish a new release. This only runs when a release is tagged (see # workflow below). release: - docker: - - image: nixos/nix:2.3 + machine: true steps: - checkout + - run: + name: Install Nix + command: | + curl -L https://nixos.org/nix/install | sh + echo "source $HOME/.nix-profile/etc/profile.d/nix.sh" >> $BASH_ENV - run: name: Install and use the Cachix binary cache command: | @@ -136,14 +140,13 @@ jobs: command: | export GITHUB_USERNAME="$CIRCLE_PROJECT_USERNAME" export GITHUB_REPONAME="$CIRCLE_PROJECT_REPONAME" - postgrest-release-github - - setup_remote_docker + postgrest-release-github $CIRCLE_TAG - run: name: Publish Docker images command: | export DOCKER_REPO=postgrest - docker login -u $DOCKER_USER -p $DOCKER_PASS - postgrest-release-dockerhub + postgrest-docker-login + postgrest-release-dockerhub $CIRCLE_TAG postgrest-release-dockerhubdescription # Build everything in default.nix, push to the Cachix binary cache and run tests @@ -161,6 +164,14 @@ jobs: command: | nix-env -iA cachix -f https://cachix.org/api/v1/install cachix use postgrest + - run: + name: Change postgrest.cabal if nightly + command: | + if test "$CIRCLE_TAG" = "nightly" + then + cabal_nightly_version=$(git show -s --format='%cd' --date='format:%Y%m%d') + sed -i "s/^version:.*/version:$cabal_nightly_version/" postgrest.cabal + fi - run: name: Build all derivations from default.nix and push results to Cachix command: | @@ -221,19 +232,27 @@ workflows: # Make sure that this job also runs when releases are tagged. filters: tags: - only: /v[0-9]+(\.[0-9]+)*/ + only: + - /v[0-9]+(\.[0-9]+)*/ + - nightly - stack-test: filters: tags: - only: /v[0-9]+(\.[0-9]+)*/ + only: + - /v[0-9]+(\.[0-9]+)*/ + - nightly - stack-test-memory: filters: tags: - only: /v[0-9]+(\.[0-9]+)*/ + only: + - /v[0-9]+(\.[0-9]+)*/ + - nightly - nix-build-test: filters: tags: - only: /v[0-9]+(\.[0-9]+)*/ + only: + - /v[0-9]+(\.[0-9]+)*/ + - nightly - release: requires: - style-check @@ -242,6 +261,8 @@ workflows: - nix-build-test filters: tags: - only: /v[0-9]+(\.[0-9]+)*/ + only: + - /v[0-9]+(\.[0-9]+)*/ + - nightly branches: ignore: /.*/ diff --git a/.cirrus.yml b/.cirrus.yml index 902cce05b1..abd11c3e98 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -2,14 +2,16 @@ freebsd_instance: image: freebsd-12-1-release-amd64 build_task: + env: + TOKEN: ENCRYPTED[c99babbf04e8a33962ffbbc75bf20d3abe408f9bede5ed5d8956cd24da6fdb34266c920984cc43f8106ef3423fba0e98] # caches the freebsd package downloads # saves probably just a couple of seconds, but hey... pkg_cache: folder: /var/cache/pkg install_script: - - pkg install -y postgresql95-client ghc hs-cabal-install - + - pkg install -y postgresql95-client ghc hs-cabal-install jq git + # cache the hackage index file and downloads which are # cabal v2-update downloads an incremental update, so we don't need to keep this up2date packages_cache: @@ -27,7 +29,41 @@ build_task: build_script: - cabal v2-update + - | + if test "$CIRRUS_TAG" = "nightly" + then + cabal_nightly_version=$(git show -s --format='%cd' --date='format:%Y%m%d') + sed -i '' "s/^version:.*/version:$cabal_nightly_version/" postgrest.cabal + fi - cabal v2-build - binaries_artifacts: - path: "dist-newstyle/build/x86_64-freebsd/ghc-8.6.5/postgrest-7.0.1/x/postgrest/build/postgrest/*" + publish_script: + - | + if test ! "$CIRRUS_TAG" + then + echo 'No tag pushed. Skip release.' + else + cabal v2-install + + bin_name="" + + if test $CIRRUS_TAG = "nightly" + then + suffix=$(git show -s --format="%cd-%h" --date="format:%Y-%m-%d-%H-%M") + bin_name=postgrest-nightly-$suffix-freebsd.tar.xz + else + bin_name=postgrest-$CIRRUS_TAG-freebsd.tar.xz + fi + + release_id=$(curl -s https://api.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/tags/$CIRRUS_TAG | jq .id) + + echo "Uploading $bin_name to gh release: $release_id" + + tar cvJf $bin_name --dereference -C /.cabal/bin postgrest + + ## We don't use ghr here because it doesn't provide freebsd binaries: https://github.com/tcnksm/ghr/issues/127 + curl -X POST --data-binary @$bin_name \ + -H "Authorization:token $TOKEN" \ + -H "Content-Type:application/octet-stream" \ + "https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/$release_id/assets?name=$bin_name" + fi \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 4d3af4c612..3ebaf5fbb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,12 @@ jobs: rm ghr.zip fi script: + - | + if test "$TRAVIS_TAG" = "nightly" + then + cabal_nightly_version=$(git show -s --format='%cd' --date='format:%Y%m%d') + sed -i '' "s/^version:.*/version:$cabal_nightly_version/" postgrest.cabal + fi ## Building the whole project can take longer than 50 minutes. Since Travis has a global timeout of 50 minutes ## we compile for 30 minutes tops(`gtimeout 1800`) and quit compiling with no error. ## Since we CACHE the compile results we can continue compiling from where we left off @@ -55,14 +61,22 @@ jobs: 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 + owner="$(echo "$TRAVIS_REPO_SLUG" | cut -f1 -d/)" + repo="$(echo "$TRAVIS_REPO_SLUG" | cut -f2 -d/)" + if test $TRAVIS_TAG = "nightly" + then + suffix=$(git show -s --format="%cd-%h" --date="format:%Y-%m-%d-%H-%M") + strip postgrest + tar cJf postgrest-nightly-$suffix-osx.tar.xz postgrest + ghr -t $GITHUB_TOKEN -u $owner -r $repo --replace nightly postgrest-nightly-$suffix-osx.tar.xz + else + start=$TRAVIS_TAG + 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 fi - name: Code Coverage diff --git a/appveyor.yml b/appveyor.yml index 356d45c68f..8863169376 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -23,6 +23,8 @@ install: - go get -u github.com/tcnksm/ghr build_script: +- ps: $env:cabal_nightly_version=(git show -s --format='%cd' --date='format:%Y%m%d') +- IF "%APPVEYOR_REPO_TAG_NAME%"=="nightly" bash -lc "sed -i -r \"s/^(version:\s+)\S+$/\1$cabal_nightly_version/\" postgrest.cabal" - stack setup --no-terminal > nul # Appveyor has a timeout of 60 mins, building can take longer, limit the time and make sure this succeeds, # previous work will get cached and finish on next commit @@ -32,5 +34,14 @@ artifacts: - path: postgrest.exe deploy_script: -- IF DEFINED APPVEYOR_REPO_TAG_NAME 7z a -tzip postgrest-%APPVEYOR_REPO_TAG_NAME%-windows-x64.zip postgrest.exe -- IF DEFINED APPVEYOR_REPO_TAG_NAME bash -lc " exec 0