release_if_new_version.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env bash
  2. set -e
  3. PROJECT_ROOT=$(git rev-parse --show-toplevel)
  4. browsh_version=$($PROJECT_ROOT/interfacer/contrib/get_browsh_version.sh)
  5. latest_tagged_version=$(git tag --sort=v:refname --list 'v*.*.*' | tail -n1 | sed -e "s/^v//")
  6. echo "Browsh version: $browsh_version"
  7. echo "Latest tag: $latest_tagged_version"
  8. if [[ "$browsh_version" == "$latest_tagged_version" ]]; then
  9. echo "Not running release as there's no new version."
  10. exit 0
  11. fi
  12. git tag v$browsh_version
  13. git show v$browsh_version --quiet
  14. git config --global user.email "builds@travis-ci.com"
  15. git config --global user.name "Travis CI"
  16. # `/dev/null` needed to prevent Github token appearing in logs
  17. git push --tags --quiet https://$GITHUB_TOKEN@github.com/browsh-org/browsh > /dev/null 2>&1
  18. git reset --hard v$browsh_version
  19. cd $PROJECT_ROOT/webext
  20. BROWSH_ENV=RELEASE npm run build
  21. cd $PROJECT_ROOT/interfacer/src
  22. curl -sL http://git.io/goreleaser | bash
  23. cd $HOME
  24. git clone https://github.com/browsh-org/www.brow.sh.git
  25. cd www.brow.sh
  26. echo "latest_version: $browsh_version" > _data/browsh.yml
  27. git add _data/browsh.yml
  28. git commit -m "(Travis CI) Updated Browsh version to $browsh_version"
  29. # `/dev/null` needed to prevent Github token appearing in logs
  30. git push --quiet https://$GITHUB_TOKEN@github.com/browsh-org/www.brow.sh > /dev/null 2>&1
  31. # Manually also include the signed Mozilla web extension in the release archives
  32. $PROJECT_ROOT/contrib/upload_github_release_asset.sh \
  33. github_api_token=$GITHUB_TOKEN \
  34. owner=browsh-org \
  35. repo=browsh \
  36. tag=v$browsh_version \
  37. filename=$PROJECT_ROOT/webext/dist/web-ext-artifacts/browsh-$browsh_version-an+fx.xpi