Skip to content

Commit

Permalink
test publish
Browse files Browse the repository at this point in the history
  • Loading branch information
nilason committed Feb 18, 2024
1 parent 4d2dac4 commit cb35c75
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`
Expand Down Expand Up @@ -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
Expand All @@ -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



Expand Down
7 changes: 7 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`
Expand All @@ -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
Expand All @@ -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)
Expand Down
28 changes: 28 additions & 0 deletions utils/generate_version_git_file.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit cb35c75

Please sign in to comment.