get latest tag in a pure git way

This commit is contained in:
Gwenhael Le Moine 2022-01-21 11:29:29 +01:00
parent f19a34fa01
commit fb1323d55e
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
3 changed files with 44 additions and 11 deletions

View file

@ -12,7 +12,7 @@ PKG=$TMP/pkg-$PRGNAM
REPOSITORY=/home/installs/SlackBuilds/repositories/$PRGNAM
GITHUB_REPO=Fred78290/nct6687d
VERSION=${VERSION:-$(curl -s https://api.github.com/repos/${GITHUB_REPO}/releases/latest | jq -r .tag_name | sed 's|^null$|trunk|')} # or VERSION=trunk
VERSION=${VERSION:-"latest"}
KERNEL_VERSION=$(uname -r)
ARCH=$(uname -m)
@ -34,8 +34,18 @@ rm -fr $PKG $TMP/$PRGNAM
cp -R $REPOSITORY $TMP/$PRGNAM
cd $TMP/$PRGNAM
[ "x$VERSION" == "xtrunk" ] && VERSION="git_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)" || git checkout $VERSION
case $VERSION in
trunk)
VERSION="git_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)"
;;
latest)
VERSION=$(git for-each-ref --sort=taggerdate --format '%(tag)' | tail -n1)
git checkout $VERSION
;;
*)
git checkout $VERSION
;;
esac
# compilation
make

View file

@ -2,7 +2,7 @@
# variables
GITHUB_REPO=swaywm/sway
VERSION=${VERSION:-$(curl -s https://api.github.com/repos/${GITHUB_REPO}/releases/latest | jq -r .tag_name | sed 's|^null$|trunk|')} # or VERSION=trunk
VERSION=${VERSION:-"latest"}
BUILD=2
TAG=gwh
@ -29,9 +29,20 @@ cd $REPOSITORY
git pull --all
cp -R $REPOSITORY $TMP/
cd $TMP/$PRGNAM/
[ "x$VERSION" == "xtrunk" ] && VERSION="git_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)" || git checkout $VERSION
cd $TMP/$PRGNAM/
case $VERSION in
trunk)
VERSION="git_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)"
;;
latest)
VERSION=$(git for-each-ref --sort=taggerdate --format '%(tag)' | tail -n1)
git checkout $VERSION
;;
*)
git checkout $VERSION
;;
esac
for p in $CWD/patches/*.patch; do
git am $p
@ -120,4 +131,4 @@ EOF
# empaquetage
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$(echo $VERSION | tr - _)-$ARCH-$BUILD$TAG.txz

View file

@ -1,10 +1,11 @@
#!/bin/bash -e
#!/bin/bash
set -e
# variables
VERSION=${VERSION:-"trunk"}
VERSION=${VERSION:-"latest"}
BUILD=1
TAG=gwh
OUTPUT=/tmp
TMP=/tmp/$TAG
@ -31,7 +32,18 @@ git pull --all
cp -R $REPOSITORY $TMP/
cd $TMP/$PRGNAM/
[ "x$VERSION" == "xtrunk" ] && VERSION="git_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)" || git checkout $VERSION
case $VERSION in
trunk)
VERSION="git_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)"
;;
latest)
VERSION=$(git for-each-ref --sort=taggerdate --format '%(tag)' | tail -n1)
git checkout $VERSION
;;
*)
git checkout $VERSION
;;
esac
meson setup \
--prefix /usr \