diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..f62c6d70d3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,152 @@ +# This workflow takes care of creating release archives for the +# Flint distribution. It is run for all PR and branch pushes as usual, +# but also on tags whose name starts with `vX.Y` with X, Y numbers +# (the idea is to use v1.2.3 or v1.2.3-beta3) +# +# For builds triggered by a tag, the tag is turned into a GitHub release and +# the produced archives are attached to that. +name: "Wrap releases" + +on: + workflow_dispatch: + pull_request: + push: + tags: + - v[1-9]+.[0-9]+.[0-9] # allow v1.2.3 + - v[1-9]+.[0-9]+.[0-9]-* # allow v1.2.3-beta3 etc. + branches: + - trunk + - flint-* + schedule: + # Every day at 3:33 AM UTC + - cron: '33 3 * * *' + +concurrency: + # group by workflow and ref; the last slightly strange component ensures that for pull + # requests, we limit to 1 concurrent job, but for the trunk branch we don't + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref != 'refs/heads/trunk' || github.run_number }} + # Cancel intermediate builds, but only if it is a pull request build. + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +jobs: + make-archive: + runs-on: ubuntu-latest + outputs: + get-version: ${{ steps.get-version.outputs.version }} + + steps: + - uses: actions/checkout@v4 + + - name: "Setup" + run: | + sudo apt install -y libgmp-dev + sudo apt install -y libmpfr-dev + sudo apt install -y autoconf + sudo apt install -y libtool-bin + gcc --version + gcov --version + make --version + autoconf --version + libtool --version + + # special treatment for tags: these are used for actual releases, + # so enforce that the version in configure.ac and in the tag match + - name: "Patch configure.ac" + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + run: | + version=${GITHUB_REF#refs/tags/v} + echo "version=$version" + sed -i -e "s/define(FLINT_VERSION,.*/define(FLINT_VERSION,[$version])/" configure.ac + git diff + + - name: "Configure" + run: | + ./bootstrap.sh + ./configure + + - name: "Record FLINT version" + id: get-version + run: | + version=$(make get_version) + echo "version=${version}" + echo "version=${version}" >> $GITHUB_OUTPUT + + - name: "Create source archive" + run: make dist + + - name: "Upload source archive as artifact" + uses: actions/upload-artifact@v3 + with: + if-no-files-found: error + name: flint + path: flint-${{ steps.get-version.outputs.version }}.tar.gz + retention-days: 1 + + test-archive: + needs: make-archive + runs-on: ubuntu-latest + env: + FLINT_VERSION: ${{ needs.make-archive.outputs.get-version }} + MAKE: "make -j --output-sync=target" + TESTCFLAGS: "-Wall -O1" + steps: + - name: "Download archive from previous job" + uses: actions/download-artifact@v3 + with: + name: flint + + - name: "Setup" + run: | + sudo apt install -y libgmp-dev + sudo apt install -y libmpfr-dev + # now *remove* autotools to verify we can build with out it + sudo apt remove -y autoconf + sudo apt remove -y automake + sudo apt remove -y libtool-bin + + - name: "Extract" + run: | + tar -xf flint-$FLINT_VERSION.tar.gz + mv flint-$FLINT_VERSION flint # to simplify code + + - name: "Configure" + run: | + cd flint + # *no* call to bootstrap.sh ! + ./configure + + - name: "Compile library" + run: | + cd flint + $MAKE + ldd libflint.so + + - name: "Compile tests" + run: | + cd flint + export FLINT_TEST_MULTIPLIER=0.1 + $MAKE tests + + - name: "Check" + run: | + cd flint + export FLINT_TEST_MULTIPLIER=0.1 + $MAKE check + + upload-archive: + needs: [make-archive, test-archive] + runs-on: ubuntu-latest + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + steps: + - name: "Download archive from previous job" + uses: actions/download-artifact@v3 + with: + name: flint + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: flint-${{ needs.make-archive.outputs.get-version }}.tar.gz + +# TODO: also trigger a documentation build and upload the result? +# TODO: if desired, we could e.g. also upload the archive to a server via scp diff --git a/.gitignore b/.gitignore index f03cf6985e..6401ddaf0e 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ src/fmpz/fmpz.c src/config.h src/config.h.in src/fft_tuning.h +src/flint.h src/flint-config.h build/ config/ diff --git a/Makefile.in b/Makefile.in index 922ba098bf..4bcf30290e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -16,9 +16,7 @@ ABS_FLINT_DIR:='$(patsubst %/,%, $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) ABS_SRC_DIR:=$(ABS_FLINT_DIR)/$(SRC_DIR) ABS_BUILD_DIR:=$(ABS_FLINT_DIR)/$(SRC_DIR) -FLINT_MAJOR:=@FLINT_MAJOR@ -FLINT_MINOR:=@FLINT_MINOR@ -FLINT_PATCH:=@FLINT_PATCH@ +FLINT_VERSION:=@FLINT_VERSION@ FLINT_MAJOR_SO:=@FLINT_MAJOR_SO@ FLINT_MINOR_SO:=@FLINT_MINOR_SO@ FLINT_PATCH_SO:=@FLINT_PATCH_SO@ @@ -786,8 +784,10 @@ endif ################################################################################ dist: - git archive --format tar --prefix flint-$(FLINT_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH)/ origin/flint-$(FLINT_MAJOR).$(FLINT_MINOR) > ../flint-$(FLINT_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH).tar; gzip ../flint-$(FLINT_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH).tar - git archive --format zip --prefix flint-$(FLINT_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH)/ origin/flint-$(FLINT_MAJOR).$(FLINT_MINOR) > ../flint-$(FLINT_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH).zip + dev/make_dist.sh $(FLINT_VERSION) + +get_version: + @echo $(FLINT_VERSION) ################################################################################ # debugging @@ -796,4 +796,6 @@ dist: print-%: @echo "$*=$($*)" -.PHONY: all library shared static examples profile tests check tune valgrind clean distclean install uninstall dist %_TEST_RUN %_VALGRIND_RUN print-% coverage +.PHONY: all library shared static examples profile tests check +.PHONY: tune valgrind clean distclean install uninstall dist get_version +.PHONY: %_TEST_RUN %_VALGRIND_RUN print-% coverage diff --git a/bootstrap.sh b/bootstrap.sh index c578848239..09b793ab49 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,8 +1,9 @@ #!/bin/sh +set -e rm -rf autom4te.cache -autoreconf -f -i -s -v -Wall +autoreconf -f -i -v -Wall # The following lines are from Semigroups/Semigroups, written by Max Horn. if ! test -x config.guess -a -x config.sub ; diff --git a/configure.ac b/configure.ac index 9e1a64f3eb..30d3ea402e 100644 --- a/configure.ac +++ b/configure.ac @@ -68,9 +68,6 @@ AC_LANG(C) # 3.0.0 => 18.0.0 # NOTE: This must be after AC_INIT -FLINT_MAJOR=3 -FLINT_MINOR=0 -FLINT_PATCH=0 FLINT_MAJOR_SO=18 FLINT_MINOR_SO=0 FLINT_PATCH_SO=0 @@ -984,6 +981,16 @@ fi # substitutions and definitions ################################################################################ +AC_SUBST([FLINT_VERSION], FLINT_VERSION) + +# split version into major/minor/patch using POSIX variable substitutions +tail=FLINT_VERSION +FLINT_MAJOR=${tail%%.*} +tail=${tail#*.} +FLINT_MINOR=${tail%%.*} +tail=${tail#*.} +FLINT_PATCH=${tail%-*} + AC_SUBST(FLINT_MAJOR) AC_SUBST(FLINT_MINOR) AC_SUBST(FLINT_PATCH) @@ -1096,7 +1103,7 @@ fi # epilog ################################################################################ -AC_CONFIG_FILES([Makefile flint.pc]) +AC_CONFIG_FILES([Makefile flint.pc src/flint.h]) AC_OUTPUT dnl Shorten the original help message diff --git a/dev/make_dist.sh b/dev/make_dist.sh new file mode 100755 index 0000000000..db5f69c569 --- /dev/null +++ b/dev/make_dist.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +set -ex + +flint_version=$1 +git_ref=${4:-HEAD} + +archive_prefix="flint-$flint_version" + +echo "Exporting from git" +git archive --format tar.gz --prefix "${archive_prefix}/" ${git_ref} > ${archive_prefix}.tar.gz + +echo "Extracting" +tar -xf ${archive_prefix}.tar.gz +rm ${archive_prefix}.tar.gz + +echo "Adding, patching or removing files" +# copy some files that should be included in the distribution archive +cp -r config ${archive_prefix}/ +cp configure ${archive_prefix}/ +cp src/config.h.in ${archive_prefix}/src/ + +# remove some things we don't want to install +cd ${archive_prefix} +rm -rf .[a-z]* # no dot files +rm -rf dev + +# patch configure.ac to have the right version in it +# (we don't use `sed -i` because it is not in POSIX and behaves differently +# for GNU and BSD sed) +mv configure.ac configure.ac.tmp +sed -e "s/define(FLINT_VERSION,.*/define(FLINT_VERSION,[$flint_version])/" configure.ac.tmp > configure.ac +rm configure.ac.tmp + +cd .. + +# now leave and re-create the source archive +echo "Create new tarball" +tar -cvzf ${archive_prefix}.tar.gz ${archive_prefix} diff --git a/src/flint.h b/src/flint.h.in similarity index 98% rename from src/flint.h rename to src/flint.h.in index 16de54d88b..11746bb73a 100644 --- a/src/flint.h +++ b/src/flint.h.in @@ -91,10 +91,10 @@ extern "C" { /* flint version number */ -#define __FLINT_VERSION 3 -#define __FLINT_VERSION_MINOR 0 -#define __FLINT_VERSION_PATCHLEVEL 0 -#define FLINT_VERSION "3.0.0-dev" +#define __FLINT_VERSION @FLINT_MAJOR@ +#define __FLINT_VERSION_MINOR @FLINT_MINOR@ +#define __FLINT_VERSION_PATCHLEVEL @FLINT_PATCH@ +#define FLINT_VERSION "@FLINT_VERSION@" #define __FLINT_RELEASE_NUM(a,b,c) ((a)*10000 + (b)*100 + (c)) #define __FLINT_RELEASE __FLINT_RELEASE_NUM(__FLINT_VERSION, __FLINT_VERSION_MINOR, __FLINT_VERSION_PATCHLEVEL)