build.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/sh
  2. set -e
  3. if [ -z "$GITHUB_REF" ]; then
  4. BRANCH=$(git symbolic-ref --short -q HEAD)
  5. else
  6. BRANCH=${GITHUB_REF#refs/heads/}
  7. fi
  8. # Get the latest commit message
  9. COMMIT_MSG=$(git log -1 --pretty=%B)
  10. # Public only if the commit message is in the correct format
  11. if echo "$COMMIT_MSG" | grep -qE '^\[haxe\] Release [0-9]+\.[0-9]+\.[0-9]+$'; then
  12. VERSION=$(echo "$COMMIT_MSG" | sed -E 's/^\[haxe\] Release ([0-9]+\.[0-9]+\.[0-9]+)$/\1/')
  13. echo "Building spine-haxe $BRANCH artifacts (version $VERSION)"
  14. if [ ! -z "$HAXE_UPDATE_URL" ] && [ ! -z "$BRANCH" ]; then
  15. echo "Deploying spine-haxe $BRANCH artifacts (version $VERSION)"
  16. zip -r "spine-haxe-$VERSION.zip" \
  17. haxelib.json \
  18. LICENSE \
  19. README.md \
  20. spine-haxe
  21. curl -f -F "file=@spine-haxe-$VERSION.zip" "$HAXE_UPDATE_URL$BRANCH"
  22. else
  23. echo "Not deploying artifacts. HAXE_UPDATE_URL and/or BRANCH not set."
  24. fi
  25. else
  26. echo "The commit is not a release - do not publish."
  27. echo "To release the commit has to be in the for: \"[haxe] Release x.y.z\""
  28. fi