sign.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. #
  3. # Licensed to the Apache Software Foundation (ASF) under one or more
  4. # contributor license agreements. See the NOTICE file distributed with
  5. # this work for additional information regarding copyright ownership.
  6. # The ASF licenses this file to You under the Apache License, Version 2.0
  7. # (the "License"); you may not use this file except in compliance with
  8. # the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. # Use this to sign the tar balls generated from
  19. # python setup.py sdist --formats=gztar
  20. # ie. sign.sh <my_tar_ball>
  21. # you will still be required to type in your signing key password
  22. # or it needs to be available in your keychain
  23. # The name of the file/artifact to sign ${RELEASE}-source.tar.gz
  24. if [ -z "${1}" ]; then
  25. echo "Missing first parameter, usage: sign <FILE_NAME> <GPG KEY>"
  26. exit 1
  27. fi
  28. NAME="${1}"
  29. if [ -z "${2}" ]; then
  30. gpg --armor --output "${NAME}".asc --detach-sig "${NAME}"
  31. gpg --print-md SHA512 "${NAME}" > "${NAME}".sha512
  32. else
  33. # The GPG key name to use
  34. GPG_LOCAL_USER="${2}"
  35. gpg --local-user "${GPG_LOCAL_USER}" --armor --output "${NAME}".asc --detach-sig "${NAME}"
  36. gpg --local-user "${GPG_LOCAL_USER}" --print-md SHA512 "${NAME}" > "${NAME}".sha512
  37. fi