@@ -9,14 +9,15 @@ name: "Wrap releases"
99
1010on :
1111 workflow_dispatch :
12- pull_request :
12+ inputs :
13+ tag_name :
14+ description : ' Tag name for release'
15+ required : false
16+ default : nightly
1317 push :
1418 tags :
1519 - v[1-9]+.[0-9]+.[0-9] # allow v1.2.3
1620 - v[1-9]+.[0-9]+.[0-9]-* # allow v1.2.3-beta3 etc.
17- branches :
18- - main
19- - flint-*
2021 schedule :
2122 # Every day at 3:33 AM UTC
2223 - cron : ' 33 3 * * *'
@@ -29,19 +30,27 @@ concurrency:
2930 cancel-in-progress : ${{ startsWith(github.ref, 'refs/pull/') }}
3031
3132jobs :
32- make-archive :
33+ version_and_tag :
3334 runs-on : ubuntu-latest
3435 outputs :
35- get-version : ${{ steps.get-version.outputs.version }}
36+ version : ${{ steps.get-version.outputs.version }}
37+ tag_name : ${{ steps.get-tag_name.outputs.tag_name }}
3638
3739 steps :
3840 - uses : actions/checkout@v4
39-
40- - name : " Setup "
41+ # figure out TAG_NAME
42+ - if : github.event_name == 'push'
4143 run : |
42- sudo apt-get install -y autoconf libtool-bin
43- autoconf --version
44- libtool --version
44+ TAG_NAME=${{ github.ref }}
45+ echo "TAG_NAME=${TAG_NAME#refs/tags/}" >> $GITHUB_ENV
46+ - if : github.event_name == 'workflow_dispatch'
47+ run : echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
48+ - if : github.event_name == 'schedule'
49+ run : echo 'TAG_NAME=nightly' >> $GITHUB_ENV
50+ - id : get-tag_name
51+ run : |
52+ echo "tag_name=${TAG_NAME}"
53+ echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
4554
4655 - name : " Record FLINT version"
4756 id : get-version
@@ -52,30 +61,46 @@ jobs:
5261 version=${GITHUB_REF#refs/tags/v}
5362 else
5463 version=$(cat VERSION)
64+ if [ ${TAG_NAME} = "nightly" ] ; then
65+ version=${version}-$(date +"%Y%m%d")
66+ fi
5567 fi
5668 echo "version=${version}"
5769 echo "version=${version}" >> $GITHUB_OUTPUT
5870
59- - name : " Bootstrap"
71+
72+ make-archive :
73+ runs-on : ubuntu-latest
74+ needs : version_and_tag
75+ env :
76+ FLINT_VERSION : ${{ needs.version_and_tag.outputs.version }}
77+
78+ steps :
79+ - uses : actions/checkout@v4
80+
81+ - name : " Setup"
6082 run : |
61- ./bootstrap.sh
83+ sudo apt-get install -y autoconf libtool-bin
84+ autoconf --version
85+ libtool --version
6286
6387 - name : " Create source archive"
64- run : dev/make_dist.sh ${{ steps.get-version.outputs.version } }
88+ run : dev/make_dist.sh ${FLINT_VERSION }
6589
6690 - name : " Upload source archive as artifact"
6791 uses : actions/upload-artifact@v3
6892 with :
6993 if-no-files-found : error
7094 name : flint
71- path : flint-${{ steps.get-version.outputs.version }}.*
95+ path : flint-${{ env.FLINT_VERSION }}.*
7296 retention-days : 1
7397
7498 test-archive :
75- needs : make-archive
99+ needs : [version_and_tag, make-archive]
76100 runs-on : ubuntu-latest
77101 env :
78- FLINT_VERSION : ${{ needs.make-archive.outputs.get-version }}
102+ FLINT_VERSION : ${{ needs.version_and_tag.outputs.version }}
103+ TAG_NAME : ${{ needs.version_and_tag.outputs.tag_name }}
79104 steps :
80105 - name : " Download archive from previous job"
81106 uses : actions/download-artifact@v3
93118
94119 - name : " Extract"
95120 run : |
96- tar -xf flint-$FLINT_VERSION.tar.gz
97- mv flint-$FLINT_VERSION flint # to simplify code
121+ tar -xf flint-${ FLINT_VERSION} .tar.gz
122+ mv flint-${ FLINT_VERSION} flint # to simplify code
98123
99124 - name : " Configure"
100125 run : |
@@ -121,23 +146,65 @@ jobs:
121146 $MAKE check
122147
123148 upload-archive :
124- needs : [make-archive, test-archive]
149+ needs : [version_and_tag, make-archive, test-archive]
125150 runs-on : ubuntu-latest
126- if : ${{ startsWith(github.ref, 'refs/tags/v') }}
151+ env :
152+ FLINT_VERSION : ${{ needs.version_and_tag.outputs.version }}
153+ TAG_NAME : ${{ needs.version_and_tag.outputs.tag_name }}
154+ GH_REPO : ${{ github.repository }}
155+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
156+
157+ permissions :
158+ contents : write
159+
160+ # so it only publishes releases on the main repository
161+ if : github.repository == 'flintlib/flint'
162+
127163 steps :
128164 - name : " Download archive from previous job"
129165 uses : actions/download-artifact@v3
130166 with :
131167 name : flint
132168
169+
170+ # figure out SUBJECT and PRERELEASE
171+ - if : env.TAG_NAME == 'nightly'
172+ run : |
173+ (echo 'SUBJECT=FLINT nightly release';
174+ echo 'PRERELEASE=--prerelease --draft') >> $GITHUB_ENV
175+ gh release delete nightly --yes || true
176+ git push origin :nightly || true
177+
178+
179+ - if : env.TAG_NAME != 'nightly'
180+ run : |
181+ (echo 'SUBJECT=FLINT release';
182+ echo 'PRERELEASE=') >> $GITHUB_ENV
183+ gh release delete stable --yes || true
184+ git push origin :stable || true
185+
186+ - name : Generate checksums
187+ run : |
188+ printf '## SHA256 Checksums\n```\n' > $RUNNER_TEMP/notes.md
189+ for ext in tar.gz tar.xz zip; do
190+ fn=flint-${FLINT_VERSION}.$ext
191+ # `sha256sum` outputs <sha> <path>,
192+ sha256sum $fn >> $RUNNER_TEMP/notes.md
193+ done
194+ printf '```\n' >> $RUNNER_TEMP/notes.md
195+
196+ # - name: Release
197+ # uses: softprops/action-gh-release@v1
198+ # with:
199+ # fail_on_unmatched_files: true
200+ # files: |
201+ # flint-${{ needs.make-archive.outputs.get-version }}.tar.gz
202+ # flint-${{ needs.make-archive.outputs.get-version }}.tar.xz
203+ # flint-${{ needs.make-archive.outputs.get-version }}.zip
204+
133205 - name : Release
134- uses : softprops/action-gh-release@v1
135- with :
136- fail_on_unmatched_files : true
137- files : |
138- flint-${{ needs.make-archive.outputs.get-version }}.tar.gz
139- flint-${{ needs.make-archive.outputs.get-version }}.tar.xz
140- flint-${{ needs.make-archive.outputs.get-version }}.zip
206+ run : |
207+ 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}
141208
142209# TODO: we could / should perhaps also test `make install` ?
143210# TODO: also trigger a documentation build and upload the result?
0 commit comments