nix: change release scripts to use a version arg

This commit is contained in:
steve-chavez
2020-11-10 22:47:58 -05:00
committed by Steve Chavez
parent 8fd9a9ab5d
commit 51b43f5605
2 changed files with 15 additions and 20 deletions
+2 -2
View File
@@ -140,13 +140,13 @@ jobs:
command: | command: |
export GITHUB_USERNAME="$CIRCLE_PROJECT_USERNAME" export GITHUB_USERNAME="$CIRCLE_PROJECT_USERNAME"
export GITHUB_REPONAME="$CIRCLE_PROJECT_REPONAME" export GITHUB_REPONAME="$CIRCLE_PROJECT_REPONAME"
postgrest-release-github postgrest-release-github $CIRCLE_TAG
- run: - run:
name: Publish Docker images name: Publish Docker images
command: | command: |
export DOCKER_REPO=postgrest export DOCKER_REPO=postgrest
postgrest-docker-login postgrest-docker-login
postgrest-release-dockerhub postgrest-release-dockerhub $CIRCLE_TAG
postgrest-release-dockerhubdescription postgrest-release-dockerhubdescription
# Build everything in default.nix, push to the Cachix binary cache and run tests # Build everything in default.nix, push to the Cachix binary cache and run tests
+13 -18
View File
@@ -12,35 +12,28 @@ let
# Version from the postgrest.cabal file (gotten with callCabal2nix). # Version from the postgrest.cabal file (gotten with callCabal2nix).
version = postgrest.version; version = postgrest.version;
# Set of files that will be published in the GitHub release.
releaseFiles =
runCommand "postgrest-release-files"
{ inherit postgrest version; }
''
set -euo pipefail
mkdir -p $out
tar cvJf "$out"/postgrest-v"$version"-linux-x64-static.tar.xz \
-C "$postgrest"/bin postgrest
'';
# Script for publishing a new release on GitHub. # Script for publishing a new release on GitHub.
github = github =
writeShellScriptBin "postgrest-release-github" writeShellScriptBin "postgrest-release-github"
'' ''
set -euo pipefail set -euo pipefail
changes="$(sed -n "1,/${version}/d;/## \[/q;p" ${../../CHANGELOG.md})" version=$1
changes="$(sed -n "1,/$version/d;/## \[/q;p" ${../../CHANGELOG.md})"
tar cvJf postgrest-$version-linux-x64-static.tar.xz \
-C ${postgrest}/bin postgrest
${ghr}/bin/ghr \ ${ghr}/bin/ghr \
-t "$GITHUB_TOKEN" \ -t "$GITHUB_TOKEN" \
-u "$GITHUB_USERNAME" \ -u "$GITHUB_USERNAME" \
-r "$GITHUB_REPONAME" \ -r "$GITHUB_REPONAME" \
-b "$changes" \ -b "$changes" \
--replace v${version} \ --replace $version \
${releaseFiles} postgrest-$version-linux-x64-static.tar.xz
''; '';
# Wrapper for login with docker. $DOCKER_USER/$DOCKER_PASS vars come from CircleCI. # Wrapper for login with docker. $DOCKER_USER/$DOCKER_PASS vars come from CircleCI.
# The DOCKER_USER is not the same as DOCKER_REPO because we use the https://hub.docker.com/u/postgrestbot account for uploading to dockerhub. # The DOCKER_USER is not the same as DOCKER_REPO because we use the https://hub.docker.com/u/postgrestbot account for uploading to dockerhub.
dockerLogin = dockerLogin =
@@ -57,13 +50,15 @@ let
'' ''
set -euo pipefail set -euo pipefail
version=$1
docker load -i ${docker.image} docker load -i ${docker.image}
docker tag postgrest:latest "$DOCKER_REPO"/postgrest:latest docker tag postgrest:latest "$DOCKER_REPO"/postgrest:latest
docker tag postgrest:latest "$DOCKER_REPO"/postgrest:v${version} docker tag postgrest:latest "$DOCKER_REPO"/postgrest:$version
docker push "$DOCKER_REPO"/postgrest:latest docker push "$DOCKER_REPO"/postgrest:latest
docker push "$DOCKER_REPO"/postgrest:v${version} docker push "$DOCKER_REPO"/postgrest:$version
''; '';
# Script for updating the repository description on Docker Hub. # Script for updating the repository description on Docker Hub.