diff --git a/.gitea/workflows/source-release.yml b/.gitea/workflows/source-release.yml index c9ab834..0b59e48 100644 --- a/.gitea/workflows/source-release.yml +++ b/.gitea/workflows/source-release.yml @@ -29,6 +29,8 @@ jobs: run: | git fetch --force --tags echo "describe:" + git describe --tags --long --match 'v*' --always || true + echo "exact tag:" git describe --tags --exact-match || true echo "points-at-head:" git tag --points-at HEAD || true @@ -54,20 +56,48 @@ jobs: - name: Determine version id: version + env: + REF_TYPE: ${{ gitea.ref_type || github.ref_type }} + REF_NAME: ${{ gitea.ref_name || github.ref_name }} + SHA: ${{ gitea.sha || github.sha }} run: | set -e - VERSION="$(sed -n 's/^AC_INIT(\[\[ncpfs\]\],\[\[\([^]]*\)\]\].*/\1/p' configure.ac)" + BASE_VERSION="$(sed -n 's/^AC_INIT(\[\[ncpfs\]\],\[\[\([^]]*\)\]\].*/\1/p' configure.ac)" - if [ -z "$VERSION" ]; then + if [ -z "$BASE_VERSION" ]; then echo "Could not determine version from configure.ac" exit 1 fi - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - echo "distfile=ncpfs-${VERSION}.tar.gz" >> "$GITHUB_OUTPUT" + if [ "$REF_TYPE" = "tag" ]; then + VERSION="$BASE_VERSION" + DISTFILE="ncpfs-${VERSION}.tar.gz" + PREFIX="ncpfs-${VERSION}/" + else + DESCRIBE="$(git describe --tags --long --match 'v*' --always)" + COUNT="$(printf '%s' "$DESCRIBE" | sed -nE 's/^v?[0-9][^-]*-([0-9]+)-g[0-9a-f]+$/\1/p')" + GITID="$(printf '%s' "$DESCRIBE" | sed -nE 's/^v?[0-9][^-]*-[0-9]+-(g[0-9a-f]+)$/\1/p')" - echo "Version: $VERSION" + if [ -z "$COUNT" ] || [ -z "$GITID" ]; then + COUNT="$(git rev-list --count HEAD)" + GITID="g$(printf '%s' "$SHA" | cut -c1-7)" + fi + + VERSION="${BASE_VERSION}-dev.${COUNT}-${GITID}" + DISTFILE="ncpfs-${VERSION}.tar.gz" + PREFIX="ncpfs-${VERSION}/" + fi + + echo "base_version=$BASE_VERSION" >> "$GITHUB_OUTPUT" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "distfile=$DISTFILE" >> "$GITHUB_OUTPUT" + echo "prefix=$PREFIX" >> "$GITHUB_OUTPUT" + + echo "Base version: $BASE_VERSION" + echo "Package version: $VERSION" + echo "Distfile: $DISTFILE" + echo "Prefix: $PREFIX" - name: Regenerate configure files run: | @@ -170,10 +200,11 @@ jobs: VERSION="${{ steps.version.outputs.version }}" DISTFILE="${{ steps.version.outputs.distfile }}" + PREFIX="${{ steps.version.outputs.prefix }}" git archive \ --format=tar \ - --prefix="ncpfs-${VERSION}/" \ + --prefix="${PREFIX}" \ HEAD | gzip -9 > "../${DISTFILE}" FILE="$(realpath "../${DISTFILE}")" @@ -187,6 +218,13 @@ jobs: tar -tzf "$FILE" > tarball-list.txt sed -n '1,20p' tarball-list.txt + echo + echo "Checking archive exclusions..." + if grep -E '(^[^/]+/\.gitea/|^[^/]+/\.github/|^[^/]+/contrib/php/build/|^[^/]+/contrib/php/autom4te.cache/)' tarball-list.txt; then + echo "Archive contains excluded CI/build paths" + exit 1 + fi + - name: Decide release target id: target env: