Skip to content

Commit

Permalink
Merge pull request #1994 from edgarcosta/release-version-3.1
Browse files Browse the repository at this point in the history
Cherry-picked changes from main branch to flint-3.1
  • Loading branch information
edgarcosta authored May 22, 2024
2 parents a300f5a + 2928fe5 commit e0926f1
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 33 deletions.
123 changes: 95 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ name: "Wrap releases"

on:
workflow_dispatch:
pull_request:
inputs:
tag_name:
description: 'Tag name for release'
required: false
default: nightly
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:
- main
- flint-*
schedule:
# Every day at 3:33 AM UTC
- cron: '33 3 * * *'
Expand All @@ -29,19 +30,27 @@ concurrency:
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
make-archive:
version_and_tag:
runs-on: ubuntu-latest
outputs:
get-version: ${{ steps.get-version.outputs.version }}
version: ${{ steps.get-version.outputs.version }}
tag_name: ${{ steps.get-tag_name.outputs.tag_name }}

steps:
- uses: actions/checkout@v4

- name: "Setup"
# figure out TAG_NAME
- if: github.event_name == 'push'
run: |
sudo apt-get install -y autoconf libtool-bin
autoconf --version
libtool --version
TAG_NAME=${{ github.ref }}
echo "TAG_NAME=${TAG_NAME#refs/tags/}" >> $GITHUB_ENV
- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
- if: github.event_name == 'schedule'
run: echo 'TAG_NAME=nightly' >> $GITHUB_ENV
- id: get-tag_name
run: |
echo "tag_name=${TAG_NAME}"
echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
- name: "Record FLINT version"
id: get-version
Expand All @@ -52,30 +61,46 @@ jobs:
version=${GITHUB_REF#refs/tags/v}
else
version=$(cat VERSION)
if [ ${TAG_NAME} = "nightly" ] ; then
version=${version}-$(date +"%Y%m%d")
fi
fi
echo "version=${version}"
echo "version=${version}" >> $GITHUB_OUTPUT
- name: "Bootstrap"
make-archive:
runs-on: ubuntu-latest
needs: version_and_tag
env:
FLINT_VERSION: ${{ needs.version_and_tag.outputs.version }}

steps:
- uses: actions/checkout@v4

- name: "Setup"
run: |
./bootstrap.sh
sudo apt-get install -y autoconf libtool-bin
autoconf --version
libtool --version
- name: "Create source archive"
run: dev/make_dist.sh ${{ steps.get-version.outputs.version }}
run: dev/make_dist.sh ${FLINT_VERSION}

- 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 }}.*
path: flint-${{ env.FLINT_VERSION }}.*
retention-days: 1

test-archive:
needs: make-archive
needs: [version_and_tag, make-archive]
runs-on: ubuntu-latest
env:
FLINT_VERSION: ${{ needs.make-archive.outputs.get-version }}
FLINT_VERSION: ${{ needs.version_and_tag.outputs.version }}
TAG_NAME: ${{ needs.version_and_tag.outputs.tag_name }}
steps:
- name: "Download archive from previous job"
uses: actions/download-artifact@v3
Expand All @@ -93,8 +118,8 @@ jobs:
- name: "Extract"
run: |
tar -xf flint-$FLINT_VERSION.tar.gz
mv flint-$FLINT_VERSION flint # to simplify code
tar -xf flint-${FLINT_VERSION}.tar.gz
mv flint-${FLINT_VERSION} flint # to simplify code
- name: "Configure"
run: |
Expand All @@ -121,23 +146,65 @@ jobs:
$MAKE check
upload-archive:
needs: [make-archive, test-archive]
needs: [version_and_tag, make-archive, test-archive]
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
env:
FLINT_VERSION: ${{ needs.version_and_tag.outputs.version }}
TAG_NAME: ${{ needs.version_and_tag.outputs.tag_name }}
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

permissions:
contents: write

# so it only publishes releases on the main repository
if: github.repository == 'flintlib/flint'

steps:
- name: "Download archive from previous job"
uses: actions/download-artifact@v3
with:
name: flint


# figure out SUBJECT and PRERELEASE
- if: env.TAG_NAME == 'nightly'
run: |
(echo 'SUBJECT=FLINT nightly release';
echo 'PRERELEASE=--prerelease --draft') >> $GITHUB_ENV
gh release delete nightly --yes || true
git push origin :nightly || true
- if: env.TAG_NAME != 'nightly'
run: |
(echo 'SUBJECT=FLINT release';
echo 'PRERELEASE=') >> $GITHUB_ENV
gh release delete stable --yes || true
git push origin :stable || true
- name: Generate checksums
run: |
printf '## SHA256 Checksums\n```\n' > $RUNNER_TEMP/notes.md
for ext in tar.gz tar.xz zip; do
fn=flint-${FLINT_VERSION}.$ext
# `sha256sum` outputs <sha> <path>,
sha256sum $fn >> $RUNNER_TEMP/notes.md
done
printf '```\n' >> $RUNNER_TEMP/notes.md
# - name: Release
# uses: softprops/action-gh-release@v1
# with:
# fail_on_unmatched_files: true
# files: |
# flint-${{ needs.make-archive.outputs.get-version }}.tar.gz
# flint-${{ needs.make-archive.outputs.get-version }}.tar.xz
# flint-${{ needs.make-archive.outputs.get-version }}.zip
- name: Release
uses: softprops/action-gh-release@v1
with:
fail_on_unmatched_files: true
files: |
flint-${{ needs.make-archive.outputs.get-version }}.tar.gz
flint-${{ needs.make-archive.outputs.get-version }}.tar.xz
flint-${{ needs.make-archive.outputs.get-version }}.zip
run: |
gh release create $TAG_NAME $PRERELEASE --notes-file "$RUNNER_TEMP/notes.md" --title "$SUBJECT" --target $GITHUB_SHA flint-${FLINT_VERSION}.{tar.gz,tar.xz,zip}
# TODO: we could / should perhaps also test `make install` ?
# TODO: also trigger a documentation build and upload the result?
Expand Down
14 changes: 9 additions & 5 deletions dev/make_dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,26 @@ echo "Extracting"
tar -xf ${archive_prefix}.tar.gz
rm ${archive_prefix}.tar.gz

# update VERSION file
printf $flint_version > VERSION

echo "Bootstrapping"
./bootstrap.sh

echo "Adding / patching / 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/
cp VERSION ${archive_prefix}/

# remove some things we don't want to install
cd ${archive_prefix}
pushd ${archive_prefix}
rm -rf .[a-z]* # no dot files
rm -rf dev

# update VERSION file
printf $flint_version > VERSION

# return to top directory
cd ..
popd

# create the source archives
echo "Create .tar.gz"
Expand Down

0 comments on commit e0926f1

Please sign in to comment.