new-release 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # Copyright (C) 2015 Alex-Daniel Jakimenko <alex.jakimenko@gmail.com>
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU Affero General Public License as
  6. # published by the Free Software Foundation, either version 3 of the
  7. # License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU Affero General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Affero General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. set -e
  17. RELEASE_LOCK='../data/releaselock'
  18. ODDMUSE_LOCATION='../data/oddmuse-for-releases/'
  19. WIKIPUT='../config/oddmuse/scripts/cli/wikiput'
  20. WIKI_LOCATION='https://oddmuse.org/wiki/'
  21. USER_NAME='Alexine'
  22. clean() {
  23. rmdir -- "$RELEASE_LOCK"
  24. }
  25. [[ -d $ODDMUSE_LOCATION ]] || git clone -- 'https://github.com/kensanata/oddmuse.git' "$ODDMUSE_LOCATION"
  26. if mkdir -- "$RELEASE_LOCK"; then # only one instance running
  27. trap clean EXIT
  28. else
  29. exit 0
  30. fi
  31. git=('git' '--git-dir' "$ODDMUSE_LOCATION/.git" '--work-tree' "$ODDMUSE_LOCATION")
  32. "${git[@]}" fetch # get latest changes
  33. "${git[@]}" reset --hard origin/master # move to the last commit
  34. # lastRelease=$("${git[@]}" tag -l --sort='-version:refname' | head -n 1) # old git versions can't do that
  35. lastRelease=$("${git[@]}" tag -l | sort -rV | head -n 1)
  36. pageText=$(curl -- "$WIKI_LOCATION/Local_Intermap?raw=1")
  37. "$WIKIPUT" -u "$USER_NAME" -s 'New release' -z 'ham' "$WIKI_LOCATION/Local_Intermap" < <(sed 's/[0-9]\+\.[0-9]\+\.[0-9]\+'"/$lastRelease/g" <<< "$pageText")