Skip to content

Commit

Permalink
Enhance 'make dist', add GitHub release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Oct 10, 2023
1 parent 1c7c17b commit 69f1c37
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 4 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# 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-dev)
#
# 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]+.*
branches:
- trunk
- main
- master
- 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
- name: "Configure"
run: |
./bootstrap.sh
./configure
- name: "Record FLINT version"
id: get-version
run: |
FLINT_VERSION=$(make get_version)
echo "steps.get-version.outputs.version = ${FLINT_VERSION}"
echo "version=${FLINT_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
# TODO: if desired, we can then also upload it to a GitHub release, copy
# it via scp to a server, or something else

10 changes: 7 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,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_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH)

get_version:
@echo $(FLINT_MAJOR).$(FLINT_MINOR).$(FLINT_PATCH)

################################################################################
# debugging
Expand All @@ -798,4 +800,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
3 changes: 2 additions & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
@@ -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 ;
Expand Down
30 changes: 30 additions & 0 deletions dev/make_dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/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 and 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
cd ..

# now leave and re-create the source archive
echo "Create new tarball"
tar -cvzf ${archive_prefix}.tar.gz ${archive_prefix}

0 comments on commit 69f1c37

Please sign in to comment.