Optimizations #1459
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: Build for release | |
| on: | |
| push: | |
| branches: [master] | |
| tags: [v*] | |
| pull_request: | |
| jobs: | |
| get-newest-supported-ghc: | |
| name: Get the newest supported GHC | |
| outputs: | |
| matrix: ${{ steps.add-exp.outputs.matrix }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Extract the tested GHC versions | |
| id: get-latest-version | |
| uses: Kleidukos/[email protected] | |
| with: | |
| cabal-file: jbeam-edit.cabal | |
| windows-version: latest | |
| version: 0.1.9.1 | |
| newest: true | |
| - uses: actions/checkout@v6 | |
| - name: Add experimental flags | |
| id: add-exp | |
| shell: bash | |
| run: bash ./.github/scripts/add_experimental_flags.sh | |
| env: | |
| CABAL_FILE: jbeam-edit.cabal | |
| MATRIX: ${{ steps.get-latest-version.outputs.matrix }} | |
| build-for-release: | |
| runs-on: windows-latest | |
| needs: get-newest-supported-ghc | |
| name: Build for release for ${{ matrix.ghc }} (${{ matrix.label}}) | |
| strategy: | |
| matrix: ${{ fromJSON(needs.get-newest-supported-ghc.outputs.matrix) }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up GHC latest and Cabal | |
| id: setup-ghc | |
| uses: haskell-actions/[email protected] | |
| with: | |
| ghc-version: ${{ matrix.ghc }} | |
| cabal-version: latest | |
| cabal-update: true | |
| - name: Configure | |
| run: bash ./.github/scripts/configure_project.sh | |
| env: | |
| LABEL: ${{ matrix.label }} | |
| MATRIX_FLAGS: ${{ matrix.flags }} | |
| - name: Freeze and check dependencies | |
| env: | |
| CABAL_PROJECT: cabal.project.release | |
| shell: bash | |
| run: bash ./.github/scripts/freeze_dependencies.sh | |
| - name: Cache GHC, Cabal store, and build artifacts | |
| uses: actions/[email protected] | |
| with: | |
| path: | | |
| dist-newstyle | |
| ${{ steps.setup-ghc.outputs.cabal-store }} | |
| key: >- | |
| ${{ runner.os }}-cabal-${{ | |
| matrix.ghc | |
| }}-${{ | |
| matrix.label | |
| }}-${{ | |
| hashFiles('**/dist-newstyle/**/plan.json') | |
| }} | |
| restore-keys: | | |
| ${{ runner.os }}-cabal-${{ matrix.ghc }}-${{ matrix.label }} | |
| - name: Build dependencies, good to do separate for caching | |
| run: cabal build --project-file cabal.project.release --only-dependencies | |
| - name: Build LSP executable | |
| shell: bash | |
| run: | | |
| cabal build exe:jbeam-lsp-server --project-file cabal.project.release || true | |
| LSP_FOLDER=$(find dist-newstyle -path '*/build/jbeam-lsp-server') | |
| cp -r examples $LSP_FOLDER/ | |
| - name: Build main executable | |
| run: cabal build exe:jbeam-edit --project-file cabal.project.release | |
| - name: Run tests (GHC ${{ matrix.ghc }}) | |
| run: cabal test --project-file cabal.project.release | |
| - name: Run benchmarks (GHC ${{ matrix.ghc }}) | |
| if: | | |
| contains(matrix.flags, ' +transformation ') && | |
| (github.ref == 'refs/heads/master' || | |
| contains(github.event.pull_request.labels.*.name, 'performance')) | |
| run: | | |
| echo "Running benchmarks for jbeam-edit" | |
| cabal bench --project-file cabal.project.release --benchmark-options="--verbosity=1" | |
| - name: Enforce CRLF newlines on windows | |
| run: bash ./.github/scripts/replace_newlines.sh | |
| shell: bash | |
| - name: Test executable | |
| shell: bash | |
| run: bash ./.github/scripts/prepare_installer.sh | |
| env: | |
| RELEASE_DIR: dist/release | |
| ZIP_DIR: dist/zip_temp | |
| DIST_NEWSTYLE: dist-newstyle | |
| CABAL_FILE: jbeam-edit.cabal | |
| LABEL: ${{ matrix.label}} | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: jbeam-edit-${{ matrix.ghc }}-${{ matrix.label }} | |
| path: dist | |
| prepare-for-release: | |
| runs-on: windows-latest | |
| needs: [build-for-release, get-newest-supported-ghc] | |
| name: Prepare release for Windows (${{ matrix.ghc }} (${{ matrix.label}}) | |
| strategy: | |
| matrix: ${{ fromJSON(needs.get-newest-supported-ghc.outputs.matrix) }} | |
| if: | | |
| startsWith(github.ref, 'refs/tags/') || | |
| contains(github.event.pull_request.labels.*.name, 'installer') | |
| env: | |
| RELEASE_DIR: ./dist/release | |
| ZIP_DIR: ./dist/zip_temp | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: jbeam-edit-${{ matrix.ghc }}-${{ matrix.label }} | |
| path: dist | |
| - name: Generate constants innosetup values which come from cabal file | |
| env: | |
| CABAL_FILE: jbeam-edit.cabal | |
| run: bash ./.github/scripts/gen_iss_constans.sh | |
| - name: Build Inno Setup Installer | |
| uses: Minionguyjpro/[email protected] | |
| with: | |
| path: installer/setup.iss | |
| options: /O+ | |
| - name: Prepare release | |
| shell: bash | |
| run: bash ./.github/scripts/prepare_release.sh | |
| env: | |
| LABEL: ${{ matrix.label}} | |
| - name: Upload zip artifact | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: jbeam-edit-${{ github.ref_name }}-${{ matrix.label }}.zip | |
| path: dist/jbeam-edit-${{ github.ref_name }}-${{ matrix.label }}.zip | |
| release: | |
| runs-on: windows-latest | |
| needs: [prepare-for-release] | |
| if: startsWith(github.ref, 'refs/tags/') | |
| name: Release for Windows | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download all prepared zip artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| pattern: jbeam-edit-${{ github.ref_name }}-*.zip | |
| path: dist | |
| - name: Collect zip files to single folder | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p dist_flat | |
| find dist -type f -name '*.zip' -print0 | xargs -0 -I{} mv {} dist_flat/ | |
| ls -la dist_flat | |
| - name: Create GitHub Release and upload zips | |
| uses: softprops/[email protected] | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| draft: true | |
| generate_release_notes: true | |
| files: dist_flat/*.zip |