fixup! ci(refactor): extract setup logic into setup-build #932
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy | |
| on: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| env: | |
| FORM_IGNORE_DEPRECATION: 1 | |
| jobs: | |
| # Generate the tarball distribution, e.g., "form-v4.2.1.tar.gz" for v4.2.1. | |
| # The tarball will be tested in the following "build-bin" job. | |
| build-src: | |
| name: Build tarball distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # ensures a reachable tag | |
| - name: Set up build | |
| uses: ./.github/actions/setup-build | |
| - name: Build tarball distribution | |
| run: | | |
| distname="${{ env.DISTNAME }}" | |
| echo "distname=$distname" >>"$GITHUB_ENV" | |
| make distdir="$distname" dist-gzip | |
| - name: Print tarball information | |
| run: | | |
| ls -l "$distname.tar.gz" | |
| file "$distname.tar.gz" | |
| tar -tf "$distname.tar.gz" | |
| - name: Upload tarball as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: src | |
| path: '*.tar.gz' | |
| if-no-files-found: error | |
| # Build executables from the tarball distribution (w/o the Git repository). | |
| # The executables must not be too optimized for the build machine and must be | |
| # statically linked in such a way that they are suitable for binary distributions. | |
| build-bin: | |
| name: Build ${{ matrix.bin }} on ${{ matrix.os }} | |
| needs: build-src | |
| runs-on: ${{ matrix.os }} | |
| defaults: | |
| run: | |
| shell: ${{ matrix.shell }} {0} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - {os: ubuntu-24.04, shell: bash, bin: form} | |
| - {os: ubuntu-24.04, shell: bash, bin: tform} | |
| # To maximize compatibility, we build executables on the oldest | |
| # platforms available. | |
| - {os: ubuntu-24.04-arm, shell: bash, bin: form} | |
| - {os: ubuntu-24.04-arm, shell: bash, bin: tform} | |
| - {os: macos-13, shell: bash, bin: form} | |
| - {os: macos-13, shell: bash, bin: tform} | |
| # The macos-14 runner image is based on the arm64 architecture. | |
| - {os: macos-14, shell: bash, bin: form} | |
| - {os: macos-14, shell: bash, bin: tform} | |
| # NOTE: Windows native executables may have some problems. | |
| # Unfortunately, "allow-failure" is not available on GitHub Actions | |
| # (https://github.com/actions/toolkit/issues/399). | |
| # We have to use "continue-on-error", instead. | |
| - {os: windows-2022, shell: msys2, bin: form} | |
| - {os: windows-2022, shell: msys2, bin: tform} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: .github/actions | |
| sparse-checkout-cone-mode: false | |
| - name: Download tarball | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: src | |
| - name: Set up build | |
| uses: ./.github/actions/setup-build | |
| with: | |
| features: ${{ matrix.bin }} ${{ matrix.shell }} deploy | |
| - name: Build | |
| id: build | |
| continue-on-error: ${{ runner.os == 'Windows' }} | |
| run: make -j 4 | |
| - name: Test | |
| if: steps.build.outcome == 'success' && steps.build.conclusion == 'success' | |
| continue-on-error: ${{ runner.os == 'Windows' }} | |
| run: make check | |
| - name: Print executable information | |
| id: check-portability | |
| if: steps.build.outcome == 'success' && steps.build.conclusion == 'success' | |
| continue-on-error: ${{ runner.os == 'Windows' }} | |
| run: | | |
| binname=${{ matrix.bin }} | |
| if [ "$RUNNER_OS" == "Windows" ]; then | |
| binname=$binname.exe | |
| fi | |
| ls -l "sources/$binname" | |
| file "sources/$binname" | |
| if [ "$RUNNER_OS" == "macOS" ]; then | |
| otool -L "sources/$binname" | |
| # Check if brewed libraries are statically linked. | |
| if otool -L "sources/$binname" | grep -q '/usr/local/opt'; then | |
| echo 'Error: failed to statically link brewed libraries' >&2 | |
| exit 1 | |
| fi | |
| fi | |
| if [ "$RUNNER_OS" == "Windows" ]; then | |
| ldd "sources/$binname" | |
| # Check if MSYS2 DLLs are not linked. | |
| if ldd "sources/$binname" | grep -q 'msys'; then | |
| echo 'Error: failed to avoid to link with MSYS2 DLLs' >&2 | |
| exit 1 | |
| fi | |
| fi | |
| - name: Upload binary as artifact | |
| if: steps.check-portability.outcome == 'success' && steps.check-portability.conclusion == 'success' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.bin }}-${{ matrix.os }} | |
| path: | | |
| sources/${{ matrix.bin }} | |
| sources/${{ matrix.bin }}.exe | |
| if-no-files-found: error | |
| # Generate the PDF reference manual, e.g., "form-4.2.1-manual.pdf" for v4.2.1. | |
| build-doc-pdf: | |
| name: Build PDF document | |
| needs: build-src | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: .github/actions | |
| sparse-checkout-cone-mode: false | |
| - name: Download tarball | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: src | |
| - name: Set up build | |
| uses: ./.github/actions/setup-build | |
| with: | |
| features: latex | |
| - name: Build PDF file | |
| run: | | |
| distname="${{ env.DISTNAME }}-manual" | |
| echo "distname=$distname" >>"$GITHUB_ENV" | |
| make pdf | |
| mv doc/manual/manual.pdf "$distname.pdf" | |
| - name: Print document information | |
| run: | | |
| ls -l "$distname.pdf" | |
| file "$distname.pdf" | |
| - name: Upload document as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: doc-pdf | |
| path: '*.pdf' | |
| if-no-files-found: error | |
| # Generate the HTML reference manual packed as, e.g., | |
| # "form-4.2.1-manual-html.tar.gz" for v4.2.1. | |
| build-doc-html: | |
| name: Build HTML document | |
| needs: build-src | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: .github/actions | |
| sparse-checkout-cone-mode: false | |
| - name: Download tarball | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: src | |
| - name: Set up build | |
| uses: ./.github/actions/setup-build | |
| with: | |
| features: latex2html | |
| - name: Build HTML files | |
| run: | | |
| distname="${{ env.DISTNAME }}-manual-html" | |
| echo "distname=$distname" >>"$GITHUB_ENV" | |
| make -C doc/manual latex2html | |
| ( | |
| cd doc/manual/manual | |
| rm -f images.aux images.idx images.log images.pdf images.pl images.tex internals.pl labels.pl WARNINGS | |
| # Print generated files. | |
| ls -A -C | |
| # Check if there are no unexpected files. | |
| shopt -s nullglob | |
| for f in * .*; do | |
| case "$f" in | |
| index.html|manual.html|manual.css|img*.svg) | |
| ;; | |
| *) | |
| echo "Error: unexpected file: $f" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| done | |
| ) | |
| mv doc/manual/manual "$distname" | |
| tar -c "$distname"/* | gzip -c -9 > "$distname.tar.gz" | |
| - name: Print file information | |
| run: | | |
| ls -l "$distname.tar.gz" | |
| file "$distname.tar.gz" | |
| tar -tf "$distname.tar.gz" | |
| - name: Upload file as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: doc-html | |
| path: '*.tar.gz' | |
| if-no-files-found: error | |
| # Prepare binaries to be published in GitHub Releases. | |
| # They will be actually delivered when the commit has a tag | |
| # starting with "v" (e.g., v4.2.1). | |
| publish-binaries: | |
| name: Publish binaries to GitHub Releases | |
| needs: | |
| - build-src | |
| - build-bin | |
| - build-doc-pdf | |
| - build-doc-html | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| - name: Print all artifacts | |
| run: ls -l -R artifacts | |
| - name: Prepare distributions | |
| run: | | |
| distname=$(basename artifacts/src/*.tar.gz .tar.gz) | |
| mkdir dist | |
| mv artifacts/src/*.tar.gz dist | |
| mv artifacts/doc-html/*.tar.gz dist | |
| mv artifacts/doc-pdf/*.pdf dist | |
| make_tar_gz() { | |
| if [ -f "artifacts/$2" ]; then | |
| pkgname=$distname-$1 | |
| mkdir "$pkgname" | |
| mv "artifacts/$2" "$pkgname" | |
| chmod +x "$pkgname"/*form* | |
| tar -c "$pkgname"/* | gzip -c -9 >"dist/$pkgname.tar.gz" | |
| rm -rf "$pkgname" | |
| fi | |
| } | |
| make_zip() { | |
| if [ -f "artifacts/$2" ]; then | |
| pkgname=$distname-$1 | |
| mkdir "$pkgname" | |
| mv "artifacts/$2" "$pkgname" | |
| chmod +x "$pkgname"/*form* | |
| zip -9 "dist/$pkgname.zip" "$pkgname"/* | |
| rm -rf "$pkgname" | |
| fi | |
| } | |
| make_tar_gz x86_64-linux '*-ubuntu-24.04/*form' | |
| make_tar_gz arm64-linux '*-ubuntu-24.04-arm/*form' | |
| make_tar_gz x86_64-osx '*-macos-13/*form' | |
| make_tar_gz arm64-osx '*-macos-14/*form' | |
| make_zip x86_64-windows '*-windows-2022/*form.exe' | |
| - name: Summarize files for distribution | |
| run: | | |
| { | |
| echo "Number of files: $(find dist -type f | wc -l)" | |
| echo | |
| echo '| File Name | Size (bytes) |' | |
| echo '| --- | ---: |' | |
| find dist -type f -printf "| %f | %s |\n" | |
| } >>"$GITHUB_STEP_SUMMARY" | |
| # Upload the distributions as an artifact, regardless of whether | |
| # the commit has a versioning tag. This makes checking and debugging easy. | |
| - name: Upload distributions as artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: | | |
| dist/*.tar.gz | |
| dist/*.zip | |
| dist/*.pdf | |
| if-no-files-found: error | |
| # To prevent the distribution of Windows binaries, uncomment the following lines. | |
| # - name: Delete Windows binaries | |
| # run: rm -fv dist/*windows* | |
| # Publish the distributions to GitHub Releases, only if the commit has | |
| # a versioning tag. | |
| - name: Publish distributions | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: | | |
| dist/*.tar.gz | |
| dist/*.zip | |
| dist/*.pdf |