github.com/aretext/aretext@v1.3.0/release.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -eu -o pipefail
     4  shopt -s failglob
     5  
     6  [ $# -ne 2 ] && { echo "Usage: $0 VERSION NAME"; exit 1; }
     7  
     8  RELEASE_VERSION=$1
     9  RELEASE_NAME=$2
    10  RELEASE_DIR=$(pwd)/dist
    11  
    12  echo "git reset and clean"
    13  git reset --hard && git clean -xfd
    14  
    15  echo "checking docs install version"
    16  if ! grep "$RELEASE_VERSION" ./docs/install.md;
    17  then
    18      echo "Docs install version does not match release version, aborting";
    19      exit 1;
    20  fi
    21  
    22  release_tag=v${RELEASE_VERSION}
    23  echo "git tag ${release_tag} ${RELEASE_NAME}"
    24  git tag -s -a "$release_tag" -m "$release_tag $RELEASE_NAME"
    25  
    26  build() {
    27      goos=$1
    28      goarch=$2
    29      dir=${RELEASE_DIR}/aretext_${RELEASE_VERSION}_${goos}_${goarch}
    30      echo "$dir"
    31      mkdir -p "$dir"
    32      GOOS=$1 GOARCH=$2 go build \
    33          -trimpath \
    34          -ldflags="-X 'main.version=${RELEASE_VERSION}'" \
    35          -o "$dir/aretext" \
    36          github.com/aretext/aretext
    37  
    38      cp LICENSE "$dir/"
    39      cp -r docs "$dir/"
    40  
    41      archive_cwd=$(dirname "$dir")
    42      archive_src=$(basename "$dir")
    43      archive_dst=$RELEASE_DIR/${archive_src}.tar.gz
    44      echo "$archive_dst"
    45      tar -czf "$archive_dst" -C "$archive_cwd" "$archive_src"
    46  }
    47  
    48  build linux amd64
    49  build linux arm64
    50  build linux 386
    51  build darwin amd64
    52  build darwin arm64
    53  build freebsd amd64
    54  build freebsd arm64
    55  
    56  checksums=aretext_${RELEASE_VERSION}_checksums.txt
    57  echo "$RELEASE_DIR/$checksums"
    58  (cd "$RELEASE_DIR" && shasum -a 256 ./*.tar.gz > "$checksums")
    59  
    60  signatures=$checksums.sig
    61  echo "$RELEASE_DIR/$signatures"
    62  (cd "$RELEASE_DIR" && gpg --output "$signatures" --detach-sig "$checksums")
    63  
    64  echo "verifying signature and checksums"
    65  (cd "$RELEASE_DIR" && gpg --verify "$signatures" "$checksums" && shasum -c "$checksums")
    66  
    67  echo "publishing git tag"
    68  git push origin "$release_tag"