This file contains 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 and Upload JARs | |
on: | |
push: | |
tags: | |
- '*' | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-20.04 | |
release_name: snapshot-linux | |
os_name: linux-x86_64 | |
- os: windows-2022 | |
release_name: snapshot-windows | |
os_name: windows-x86_64 | |
- os: macos-15 | |
release_name: snapshot-macos | |
os_name: macos-aarch64 | |
- os: macos-12 | |
release_name: snapshot-macos-intel | |
os_name: macos-x86_64 | |
env: | |
SCALA_VERSION: '3.5.2' | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
defaults: | |
run: | |
working-directory: ./ | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
if: runner.os != 'Windows' | |
with: | |
version: 9 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 23 | |
cache: '' | |
- name: Choco install pnpm on windows | |
if: runner.os == 'Windows' | |
uses: crazy-max/ghaction-chocolatey@v3 | |
with: | |
args: install pnpm | |
- name: Setup GraalVM | |
uses: graalvm/setup-graalvm@v1 | |
if: runner.os != 'Linux' || true | |
with: | |
java-version: '23' | |
distribution: 'graalvm' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
native-image-job-reports: 'true' | |
- name: GraalVM Env - G1GC - Linux | |
if: runner.os == 'Linux' | |
shell: bash | |
run: | | |
echo "NATIVE_IMAGE_OPTIONS=--gc=G1" >> $GITHUB_ENV | |
- name: GraalVM Env - -march=native - mac | |
if: runner.os == 'macOS' | |
shell: bash | |
run: | | |
echo "NATIVE_IMAGE_OPTIONS=-march=native" >> $GITHUB_ENV | |
- name: GraalVM - Linux - musl - disabled | |
uses: graalvm/setup-graalvm@v1 | |
if: runner.os == 'Linux' && false | |
with: | |
native-image-musl: 'true' | |
java-version: '23' | |
distribution: 'graalvm' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
native-image-job-reports: 'true' | |
- name: GraalVM Env - Linux - musl - disabled | |
if: runner.os == 'Linux' && false | |
shell: bash | |
run: | | |
echo "NATIVE_IMAGE_OPTIONS=--static --libc=musl" >> $GITHUB_ENV | |
- name: GraalVM Env | |
shell: bash | |
run: | | |
echo "NATIVE_IMAGE_INSTALLED=true" >> $GITHUB_ENV | |
echo "GRAALVM_INSTALLED=true" >> $GITHUB_ENV | |
- uses: sbt/setup-sbt@v1 | |
- name: Cache SBT (Unix) | |
if: runner.os != 'Windows' | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.ivy2/cache | |
~/.sbt | |
~/.coursier | |
~/.cache/coursier | |
key: ${{ matrix.os }}-sbt-${{ hashFiles('**/*.sbt') }} | |
restore-keys: | | |
${{ matrix.os }}-sbt- | |
- name: Cache SBT for Windows | |
if: runner.os == 'Windows' | |
uses: actions/cache@v4 | |
with: | |
path: | | |
C:\Users\runneradmin\.ivy2\cache | |
C:\Users\runneradmin\.sbt | |
C:\Users\runneradmin\.coursier | |
C:\Users\runneradmin\AppData\Local\Coursier\cache | |
key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }} | |
restore-keys: | | |
${{ runner.os }}-sbt- | |
- name: Build CLI JAR with SBT | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 25 | |
max_attempts: 2 | |
command: sbt cli/assembly | |
- name: Build LSP JAR with SBT | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 25 | |
max_attempts: 2 | |
command: sbt lsp/assembly | |
- name: Build CLI Native Executable | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 25 | |
max_attempts: 2 | |
command: sbt cliNative/nativeLink | |
- name: Rename CLI Native Executable | |
shell: bash | |
run: | | |
if [[ "$RUNNER_OS" == "Windows" ]]; then | |
mv cli/native/target/scala-${{ env.SCALA_VERSION }}/cli-out.exe cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out.exe || mv cli/native/target/scala-${{ env.SCALA_VERSION }}/native/chester.cli.Main.exe cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out.exe | |
else | |
mv cli/native/target/scala-${{ env.SCALA_VERSION }}/cli-out cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out || mv cli/native/target/scala-${{ env.SCALA_VERSION }}/native/chester.cli.Main cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out | |
fi | |
- name: Generate JS Artifacts for CLI | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 25 | |
max_attempts: 2 | |
shell: bash | |
command: | | |
sbt cliJS/fullLinkJS | |
mv cli/js/target/scala-${{ env.SCALA_VERSION }}/cli-opt/main.js cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js | |
- name: Build Native Image for LSP | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 50 | |
max_attempts: 2 | |
command: sbt lsp/nativeImage | |
- name: Build Native Image for CLI | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 50 | |
max_attempts: 2 | |
command: sbt cli/nativeImage | |
- name: Test Native Image for CLI integrity | |
shell: bash | |
run: ./target/chester integrity | |
- name: List files for debugging | |
shell: bash | |
run: find . -type f -name "*.jar" -or -name "chester" -or -name "chester-lsp" -or -name "chester-out" -or -name "*.exe" | |
continue-on-error: true | |
- name: Install Node.js dependencies | |
working-directory: vscode | |
run: pnpm install --frozen-lockfile | |
- name: Build VSCode Extension | |
working-directory: vscode | |
run: pnpm run package | |
- name: Upload Unix Artifacts | |
if: runner.os != 'Windows' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.release_name }} | |
path: | | |
./target/chester.jar | |
./target/chester-lsp.jar | |
./cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js | |
./target/chester | |
./target/chester-lsp | |
./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out | |
./vscode/chester-language-support-*.vsix | |
- name: Upload Windows Artifacts | |
if: runner.os == 'Windows' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.release_name }} | |
path: | | |
./target/chester.jar | |
./target/chester-lsp.jar | |
./cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js | |
./target/chester.exe | |
./target/chester-lsp.exe | |
./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out.exe | |
./vscode/chester-language-support-*.vsix | |
- name: Create or Update GitHub Release for Unix | |
if: runner.os != 'Windows' | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ matrix.release_name }} | |
name: ${{ matrix.release_name }} | |
allowUpdates: true | |
prerelease: true | |
artifacts: | | |
./target/chester.jar, | |
./target/chester-lsp.jar, | |
./cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js, | |
./target/chester, | |
./target/chester-lsp, | |
./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out, | |
./vscode/chester-language-support-*.vsix | |
- name: Create or Update GitHub Release for Windows | |
if: runner.os == 'Windows' | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ matrix.release_name }} | |
name: ${{ matrix.release_name }} | |
allowUpdates: true | |
prerelease: true | |
artifacts: | | |
./target/chester.jar, | |
./target/chester-lsp.jar, | |
./cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js, | |
./target/chester.exe, | |
./target/chester-lsp.exe, | |
./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out.exe, | |
./vscode/chester-language-support-*.vsix | |
# Add OS name to artifacts and create archives (Unix) | |
- name: Add OS name to artifacts and create tar.gz (Unix) | |
shell: bash | |
if: runner.os != 'Windows' && startsWith(github.ref, 'refs/tags/') | |
run: | | |
# Rename artifacts with OS name | |
cp ./target/chester ./target/chester-${{ matrix.os_name }} | |
cp ./target/chester-lsp ./target/chester-lsp-${{ matrix.os_name }} | |
cp ./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out ./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out-${{ matrix.os_name }} | |
# Create tar.gz archive | |
tar -czvf chester-${{ matrix.os_name }}.tar.gz \ | |
-C ./target chester chester-lsp | |
# Generate checksum for the tar.gz file | |
shasum -a 256 chester-${{ matrix.os_name }}.tar.gz > chester-${{ matrix.os_name }}.tar.gz.sha256 | |
# Add OS name to artifacts and create archives (Windows) | |
- name: Add OS name to artifacts and create zip (Windows) | |
shell: pwsh | |
if: runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/') | |
run: | | |
# Rename artifacts with OS name | |
cp .\target\chester.exe .\target\chester-${{ matrix.os_name }}.exe | |
cp .\target\chester-lsp.exe .\target\chester-lsp-${{ matrix.os_name }}.exe | |
cp .\cli\native\target\scala-${{ env.SCALA_VERSION }}\chester-out.exe .\cli\native\target\scala-${{ env.SCALA_VERSION }}\chester-out-${{ matrix.os_name }}.exe | |
# Create zip archive | |
Compress-Archive -Path ` | |
.\target\chester.exe,` | |
.\target\chester-lsp.exe ` | |
-DestinationPath chester-${{ matrix.os_name }}.zip | |
# generating checksum using Git Bash | |
- name: Generate checksum for Windows zip | |
shell: bash | |
if: runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/') | |
run: | | |
sha256sum chester-${{ matrix.os_name }}.zip > chester-${{ matrix.os_name }}.zip.sha256 | |
# Create or Update Releases when a tag is pushed | |
- name: Create or Update GitHub Release Tag for Unix | |
if: runner.os != 'Windows' && startsWith(github.ref, 'refs/tags/') | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ github.ref_name }} | |
name: ${{ github.ref_name }} | |
allowUpdates: true | |
prerelease: false | |
artifacts: | | |
./target/chester.jar, | |
./target/chester-lsp.jar, | |
./cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js, | |
./target/chester-${{ matrix.os_name }}, | |
./target/chester-lsp-${{ matrix.os_name }}, | |
./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out-${{ matrix.os_name }}, | |
./vscode/chester-language-support-*.vsix, | |
./chester-${{ matrix.os_name }}.tar.gz, | |
./chester-${{ matrix.os_name }}.tar.gz.sha256 | |
- name: Create or Update GitHub Release Tag for Windows | |
if: runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/') | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ github.ref_name }} | |
name: ${{ github.ref_name }} | |
allowUpdates: true | |
prerelease: false | |
artifacts: | | |
./target/chester.jar, | |
./target/chester-lsp.jar, | |
./cli/js/target/scala-${{ env.SCALA_VERSION }}/chester.js, | |
./target/chester-${{ matrix.os_name }}.exe, | |
./target/chester-lsp-${{ matrix.os_name }}.exe, | |
./cli/native/target/scala-${{ env.SCALA_VERSION }}/chester-out-${{ matrix.os_name }}.exe, | |
./vscode/chester-language-support-*.vsix, | |
./chester-${{ matrix.os_name }}.zip, | |
./chester-${{ matrix.os_name }}.zip.sha256 | |
- name: Run Tests | |
uses: nick-fields/retry@v3 | |
with: | |
timeout_minutes: 25 | |
max_attempts: 3 | |
command: sbt testAll |