From cb35c75277ed18f1996d6d5d7a926456894e1fb2 Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Sun, 18 Feb 2024 22:20:43 +0100 Subject: [PATCH] test publish --- .github/workflows/publish.yml | 47 ++++++++++++++++++++++++++++++ configure | 25 ++++++++++++++++ configure.ac | 7 +++++ utils/generate_version_git_file.sh | 28 ++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 .github/workflows/publish.yml create mode 100755 utils/generate_version_git_file.sh diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000000..85c456c93b5 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,47 @@ +--- +name: Publish GRASS + +on: + release: + types: [published] +env: + OUT_DIR: ${{ github.workspace }}/.g_outdir + GRASS: grass-${{ github.ref_name }} +permissions: + contents: write +jobs: + build-n-publish: + name: Build and publish GRASS + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + - name: Generate Git derived data files + run: | + ./utils/generate_version_git_file.sh + ./utils/generate_last_commit_file.py + - name: Create tarballs + run: | + mkdir ${{ env.OUT_DIR }} + cd .. + tar -cvf ${{ env.OUT_DIR }}/${{ env.GRASS }}.tar \ + --exclude=".gi*" --exclude=".tr*" grass + cd ${{ env.OUT_DIR }} + gzip -9k ${{ env.GRASS }}.tar + md5sum ${{ env.GRASS }}.tar.gz > ${{ env.GRASS }}.tar.gz.md5 + sha256sum ${{ env.GRASS }}.tar.gz > ${{ env.GRASS }}.tar.gz.sha256 + xz -9e ${{ env.GRASS }}.tar + md5sum ${{ env.GRASS }}.tar.xz > ${{ env.GRASS }}.tar.xz.md5 + sha256sum ${{ env.GRASS }}.tar.xz > ${{ env.GRASS }}.tar.xz.sha256 + - name: Publish distribution to GitHub + uses: softprops/action-gh-release@v1 + with: + files: | + ${{ env.OUT_DIR }}/${{ env.GRASS }}.tar.gz + ${{ env.OUT_DIR }}/${{ env.GRASS }}.tar.gz.md5 + ${{ env.OUT_DIR }}/${{ env.GRASS }}.tar.gz.sha256 + ${{ env.OUT_DIR }}/${{ env.GRASS }}.tar.xz + ${{ env.OUT_DIR }}/${{ env.GRASS }}.tar.xz.md5 + ${{ env.OUT_DIR }}/${{ env.GRASS }}.tar.xz.sha256 diff --git a/configure b/configure index cedd9e3d5a4..14da3087589 100755 --- a/configure +++ b/configure @@ -4939,6 +4939,7 @@ GRASS_BIN="${DSTDIR}/bin.${ARCH}" # Set GRASS_VERSION_* GRASS_VERSION_FILE=include/VERSION +GRASS_VERSION_GIT_FILE=include/VERSION_GIT GRASS_VERSION_MAJOR=`sed -n 1p "${GRASS_VERSION_FILE}"` GRASS_VERSION_MINOR=`sed -n 2p "${GRASS_VERSION_FILE}"` GRASS_VERSION_RELEASE=`sed -n 3p "${GRASS_VERSION_FILE}"` @@ -4996,6 +4997,25 @@ printf "%s\n" "no" >&6; } fi +as_ac_File=`printf "%s\n" "ac_cv_file_$GRASS_VERSION_GIT_FILE" | $as_tr_sh` +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $GRASS_VERSION_GIT_FILE" >&5 +printf %s "checking for $GRASS_VERSION_GIT_FILE... " >&6; } + +test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "$GRASS_VERSION_GIT_FILE"; then + eval "$as_ac_File=yes" +else + eval "$as_ac_File=no" +fi +eval ac_res=\$$as_ac_File + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +printf "%s\n" "$ac_res" >&6; } +if eval test \"x\$"$as_ac_File"\" = x"yes" +then : + +fi + if test "$GIT" != "no" ; then GRASS_VERSION_GIT=`$GIT rev-parse --short HEAD 2>/dev/null` if test -z "$GRASS_VERSION_GIT"; then @@ -5010,6 +5030,11 @@ if test "$GIT" != "no" ; then GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'` fi fi +if test $GRASS_VERSION_GIT == "exported" && \ + test "$ac_cv_file_include_VERSION_GIT" == "yes"; then + GRASS_HEADERS_GIT_HASH=$(sed -n 1p "${GRASS_VERSION_GIT_FILE}") + GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}") +fi diff --git a/configure.ac b/configure.ac index 2900d2689dd..763b9c53064 100644 --- a/configure.ac +++ b/configure.ac @@ -144,6 +144,7 @@ AC_SUBST(GRASS_BIN) # Set GRASS_VERSION_* GRASS_VERSION_FILE=include/VERSION +GRASS_VERSION_GIT_FILE=include/VERSION_GIT GRASS_VERSION_MAJOR=`sed -n 1p "${GRASS_VERSION_FILE}"` GRASS_VERSION_MINOR=`sed -n 2p "${GRASS_VERSION_FILE}"` GRASS_VERSION_RELEASE=`sed -n 3p "${GRASS_VERSION_FILE}"` @@ -160,6 +161,7 @@ GRASS_VERSION_GIT="exported" GRASS_HEADERS_GIT_HASH="${GRASS_VERSION_NUMBER}" GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'` AC_PATH_PROG(GIT, git, no) +AC_CHECK_FILE([$GRASS_VERSION_GIT_FILE]) if test "$GIT" != "no" ; then GRASS_VERSION_GIT=`$GIT rev-parse --short HEAD 2>/dev/null` if test -z "$GRASS_VERSION_GIT"; then @@ -174,6 +176,11 @@ if test "$GIT" != "no" ; then GRASS_HEADERS_GIT_DATE=`date -u +%FT%T%z | sed 's/\(..\)$/:\1/'` fi fi +if test $GRASS_VERSION_GIT == "exported" && \ + test "$ac_cv_file_include_VERSION_GIT" == "yes"; then + GRASS_HEADERS_GIT_HASH=$(sed -n 1p "${GRASS_VERSION_GIT_FILE}") + GRASS_HEADERS_GIT_DATE=$(sed -n 2p "${GRASS_VERSION_GIT_FILE}") +fi AC_SUBST(GRASS_VERSION_FILE) AC_SUBST(GRASS_VERSION_MAJOR) diff --git a/utils/generate_version_git_file.sh b/utils/generate_version_git_file.sh new file mode 100755 index 00000000000..a2eb7439e3f --- /dev/null +++ b/utils/generate_version_git_file.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +set -eu + +this_script=$(basename "$0") +version_file=include/VERSION +version_git_file=include/VERSION_GIT + +if [ ! -f "$version_file" ]; then + echo "Error: execute ${this_script} from repository top level." + exit 1 +fi + +if ! (git log -1 >/dev/null); then + echo "Error: git not available." + exit 1 +fi + +grass_version_git=$(git rev-parse --short HEAD) +gitdate_utc_local=$(TZ=UTC0 git log -1 --date=iso-local --pretty=format:"%cd" -- include) +grass_headers_git_date=$(echo "$gitdate_utc_local" \ + | sed 's/ /T/' | sed 's/ //' | sed 's/\(..\)$/:\1/') + +cat << EOF > "$version_git_file" +$grass_version_git +$grass_headers_git_date + +EOF