make-release.sh 716 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. if [[ "${GITHUB_REF:-}" == refs/tags/* ]]; then
  4. version=${GITHUB_REF/refs\/tags\//}
  5. else
  6. version="v$(jq -r .version package.json)"
  7. if git ls-remote --tags --exit-code origin "$version"; then
  8. echo "Release $release_name already exists"
  9. exit 1
  10. fi
  11. fi
  12. release_name="typingfreaks-$version"
  13. npm run build
  14. function cleanup {
  15. rm -rf "$release_name"
  16. rm -f "$release_name.zip"
  17. }
  18. trap cleanup EXIT
  19. mkdir "$release_name"
  20. cp dist/bundle.{js,js.map} "$release_name"
  21. for file in $(git ls-files dist); do
  22. cp "$file" "$release_name"
  23. done
  24. zip -r "$release_name.zip" "$release_name"
  25. gh release create -d --notes "" "$version" "$release_name.zip"