~mna/snow unlisted

snow/scripts/release.sh -rwxr-xr-x 654 bytes
424066c5Martin Angers doc: v0.0.5 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash

set -euo pipefail

function run {
  local pwd=""; pwd=$(pwd)
  if [[ ${pwd} != *snow ]]; then
    echo "must be run from the root of the repository"
    exit 1
  fi

  local tag=""; tag=$(git tag -l --points-at HEAD | head -n 1)
  local hash=""; hash=$(git rev-parse --short HEAD)
  local date=""; date=$(date -u "+%Y-%m-%d+%H:%M:%S")

  for dir in ./cmd/*; do
    local base=""; base=$(basename "${dir}")
    if [[ "${base}" == "internal" ]]; then
      continue
    fi
    if [[ -d "${dir}" ]]; then
      go build -o "bin/${base}" -ldflags "-X main.version=${tag:-${hash}} -X main.buildDate=${date}" "${dir}"
    fi
  done
}

run