github.com/pojntfx/hydrapp/hydrapp@v0.0.0-20240516002902-d08759d6ca9f/pkg/builders/binaries/entrypoint.sh (about)

     1  #!/bin/bash
     2  
     3  set -e
     4  
     5  # Setup PGP
     6  echo "${PGP_KEY_PASSWORD}" | base64 -d >'/tmp/pgp-pass'
     7  mkdir -p "${HOME}/.gnupg"
     8  cat >"${HOME}/.gnupg/gpg.conf" <<EOT
     9  yes
    10  passphrase-file /tmp/pgp-pass
    11  pinentry-mode loopback
    12  EOT
    13  
    14  echo "${PGP_KEY}" | base64 -d >'/tmp/private.pgp'
    15  gpg --import /tmp/private.pgp
    16  
    17  # Prepare build environment
    18  export BASEDIR="${PWD}/${GOMAIN}"
    19  
    20  # Configure Go
    21  export GOPROXY='https://proxy.golang.org,direct'
    22  
    23  # Install host packages
    24  if [ "${HOST_PACKAGES}" != "" ]; then
    25      apt update
    26      apt install -y ${HOST_PACKAGES}
    27  fi
    28  
    29  # Generate dependencies
    30  GOFLAGS="${GOFLAGS}" sh -c "${GOGENERATE}"
    31  
    32  # Build
    33  CGO_ENABLED=0 bagop -j "$(nproc)" -b "${APP_ID}" -x "${GOEXCLUDE}" -d /hydrapp/dst -p "go build -o \$DST -ldflags='-X github.com/pojntfx/hydrapp/hydrapp/pkg/update.BranchTimestampRFC3339=${BRANCH_TIMESTAMP_RFC3339} -X github.com/pojntfx/hydrapp/hydrapp/pkg/update.BranchID=${BRANCH_ID}' ${GOMAIN}"
    34  
    35  for FILE in /hydrapp/dst/*; do
    36      gpg --detach-sign --armor "${FILE}"
    37  done
    38  
    39  cd /hydrapp/dst
    40  
    41  gpg --output "repo.asc" --armor --export
    42  tree -T "${APP_NAME}" --du -h -D -H . -I 'index.html|index.json' -o 'index.html'
    43  tree -J . -I 'index.html|index.json' | jq '.[0].contents' | jq ". |= map( . + {time: \"${BRANCH_TIMESTAMP_RFC3339}\"} )" | tee 'index.json'
    44  
    45  if [ "${DST_UID}" != "" ] && [ "${DST_GID}" != "" ]; then
    46      chown -R "${DST_UID}:${DST_GID}" /hydrapp/dst
    47  fi