Skip to content

tmp

tmp #1331

name: Build for release
on:
push:
branches: [master, conditionally-enable-read-instances]
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/get-tested@v0.1.9.1
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/setup@v2.9.0
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/cache@v5.0.1
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 }})
if: startsWith(github.ref, 'refs/heads/master')
run: cabal test --project-file cabal.project.release
- name: Run benchmarks (GHC ${{ matrix.ghc }})
if: contains(matrix.flags, ' +transformation ')
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) }}
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: Build Inno Setup Installer
uses: Minionguyjpro/Inno-Setup-Action@v1.2.7
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/action-gh-release@v2.5.0
with:
tag_name: ${{ github.ref_name }}
draft: true
generate_release_notes: true
files: dist_flat/*.zip