github.com/beyonderyue/gochain/v3@v3.3.6-0.20200509024509-b25a97312b8c/release.sh (about)

     1  #!/bin/bash
     2  set -exuo pipefail
     3  
     4  user="gochain"
     5  image="gochain"
     6  gcr_project="gochain-core"
     7  # ensure working dir is clean
     8  git status
     9  if [[ -z $(git status -s) ]]
    10  then
    11    echo "tree is clean"
    12  else
    13    echo "tree is dirty, please commit changes before running this"
    14    exit 1
    15  fi
    16  
    17  version_file="params/version.go"
    18  docker create -v /params --name file alpine /bin/true
    19  docker cp $version_file file:/$version_file
    20  # Bump version, patch by default - also checks if previous commit message contains `[bump X]`, and if so, bumps the appropriate semver number - https://github.com/treeder/dockers/tree/master/bump
    21  docker run --rm -it --volumes-from file -w / treeder/bump --filename $version_file "$(git log -1 --pretty=%B)"
    22  docker cp file:/$version_file $version_file
    23  version=$(grep -m1 -Eo "[0-9]+\.[0-9]+\.[0-9]+" $version_file)
    24  echo "Version: $version"
    25  
    26  docker build . -t $user/$image
    27  git add -u
    28  git commit -m "$image: $version release [skip ci]"
    29  git tag -f -a "v$version" -m "version $version"
    30  git push
    31  git push origin v$version
    32  
    33  # Finally, push docker images
    34  docker tag $user/$image:latest $user/$image:$version
    35  docker push $user/$image:$version
    36  docker push $user/$image:latest
    37  
    38  #Push docker images to GCR
    39  ./tmp/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file=${HOME}/gcloud-service-key.json
    40  docker tag $user/$image:latest gcr.io/$gcr_project/$image:latest
    41  docker tag $user/$image:latest gcr.io/$gcr_project/$image:$version
    42  docker push gcr.io/$gcr_project/$image:latest
    43  docker push gcr.io/$gcr_project/$image:$version