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 REPOSITORY=/home/installs/SlackBuilds/repositories/$PRGNAM
GITHUB_REPO=Fred78290/nct6687d 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) KERNEL_VERSION=$(uname -r)
ARCH=$(uname -m) ARCH=$(uname -m)
@ -34,8 +34,18 @@ rm -fr $PKG $TMP/$PRGNAM
cp -R $REPOSITORY $TMP/$PRGNAM cp -R $REPOSITORY $TMP/$PRGNAM
cd $TMP/$PRGNAM cd $TMP/$PRGNAM
case $VERSION in
[ "x$VERSION" == "xtrunk" ] && VERSION="git_$(git log -1 --format=%h_%ad --date=format:%Y.%m.%d)" || git checkout $VERSION 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 # compilation
make make

View file

@ -2,7 +2,7 @@
# variables # variables
GITHUB_REPO=swaywm/sway 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 BUILD=2
TAG=gwh TAG=gwh
@ -29,9 +29,20 @@ cd $REPOSITORY
git pull --all git pull --all
cp -R $REPOSITORY $TMP/ 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 for p in $CWD/patches/*.patch; do
git am $p git am $p
@ -120,4 +131,4 @@ EOF
# empaquetage # empaquetage
rm -f $PKG/{,usr/}lib$(uname -m | grep -o 64)/*.la 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 # variables
VERSION=${VERSION:-"trunk"} VERSION=${VERSION:-"latest"}
BUILD=1 BUILD=1
TAG=gwh TAG=gwh
OUTPUT=/tmp OUTPUT=/tmp
TMP=/tmp/$TAG TMP=/tmp/$TAG
@ -31,7 +32,18 @@ git pull --all
cp -R $REPOSITORY $TMP/ cp -R $REPOSITORY $TMP/
cd $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
meson setup \ meson setup \
--prefix /usr \ --prefix /usr \