Skip to content

WIP

WIP #2845

Workflow file for this run

name: CI
on:
push:
branches: [ master ]
tags: "*.*.*"
pull_request:
branches: [ master ]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
# Build statically linked Linux binaries in an Alpine-based Docker container
# See https://ocamlpro.com/blog/2021_09_02_generating_static_and_portable_executables_with_ocaml
# for more info.
# The container already comes with all required tools pre-installed
# (see https://github.com/rescript-lang/docker-rescript-ci-build/blob/main/Dockerfile).
build-linux:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, buildjet-2vcpu-ubuntu-2204-arm]
# syntax explanation:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations
include:
- os: ubuntu-latest
artifact-folder: linux
- os: buildjet-2vcpu-ubuntu-2204-arm
artifact-folder: linuxarm64
runs-on: ${{matrix.os}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
uses: docker://ghcr.io/rescript-lang/rescript-ci-build:alpine-3.20-ocaml-5.2.0-01
with:
args: opam exec -- dune build --profile static
- name: Copy and strip binaries
run: |
cp -f _build/install/default/bin/rescript-editor-analysis rescript-editor-analysis.exe
cp -f _build/install/default/bin/rescript-tools rescript-tools.exe
strip rescript-editor-analysis.exe rescript-tools.exe
# Also avoids artifacts upload permission loss:
# https://github.com/actions/upload-artifact/tree/ee69f02b3dfdecd58bb31b4d133da38ba6fe3700#permission-loss
- name: Compress files
run: |
mkdir ${{matrix.artifact-folder}}
mv rescript-editor-analysis.exe ${{matrix.artifact-folder}}
mv rescript-tools.exe ${{matrix.artifact-folder}}
tar -cvf binary.tar ${{matrix.artifact-folder}}
- name: "Upload artifacts"
uses: actions/upload-artifact@v4
with:
name: ${{matrix.artifact-folder}}
path: binary.tar
build:
strategy:
fail-fast: false
matrix:
os: [
macos-13, # x64
macos-14, # ARM
windows-latest,
]
# syntax explanation:
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations
include:
- os: macos-13
artifact-folder: darwin
- os: macos-14
artifact-folder: darwinarm64
- os: windows-latest
artifact-folder: win32
runs-on: ${{matrix.os}}
steps:
# needed for Windows testing
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v4
- name: Cache OCaml's opam
uses: actions/cache@v4
with:
path: ~/.opam
key: ${{matrix.os}}-rescript-vscode-v5
- name: Use OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: 5.2.0
opam-pin: false
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: opam install dune cppo
- run: npm run compile
- run: npm run bundle
# These 2 runs (or just the second?) are for when you have opam dependencies. We don't.
# Don't add deps. But if you ever do, un-comment these and add an .opam file.
# - run: opam pin add rescript-editor-analysis.dev . --no-action
# - run: opam install . --deps-only --with-doc --with-test
- name: Build
run: opam exec -- make
- name: Test
run: opam exec -- make test
- name: Strip binaries
if: matrix.os != 'windows-latest'
run: strip rescript-editor-analysis.exe rescript-tools.exe
# Also avoids artifacts upload permission loss:
# https://github.com/actions/upload-artifact/tree/ee69f02b3dfdecd58bb31b4d133da38ba6fe3700#permission-loss
- name: Compress files
run: |
mkdir ${{matrix.artifact-folder}}
mv rescript-editor-analysis.exe ${{matrix.artifact-folder}}
mv rescript-tools.exe ${{matrix.artifact-folder}}
tar -cvf binary.tar ${{matrix.artifact-folder}}
- uses: actions/upload-artifact@v4
with:
name: ${{matrix.artifact-folder}}
path: binary.tar
package:
needs:
- build
- build-linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm run compile
- name: Download MacOS binaries
uses: actions/download-artifact@v4
with:
name: darwin
path: binaries
- run: tar -xvf binary.tar
working-directory: binaries
- name: Download MacOS ARM binaries
uses: actions/download-artifact@v4
with:
name: darwinarm64
path: binaries
- run: tar -xvf binary.tar
working-directory: binaries
- name: Download Linux binaries
uses: actions/download-artifact@v4
with:
name: linux
path: binaries
- run: tar -xvf binary.tar
working-directory: binaries
- name: Download Linux ARM binaries
uses: actions/download-artifact@v4
with:
name: linuxarm64
path: binaries
- run: tar -xvf binary.tar
working-directory: binaries
- name: Download Windows binaries
uses: actions/download-artifact@v4
with:
name: win32
path: binaries
- run: tar -xvf binary.tar
working-directory: binaries
- name: Cleanup tar file
run: rm binary.tar
working-directory: binaries
- name: Move binaries to folders
run: |
declare -a platforms=("darwin" "darwinarm64" "linux" "linuxarm64" "win32")
for platform in "${platforms[@]}"; do
mkdir server/analysis_binaries/"$platform"
mv binaries/"$platform"/rescript-editor-analysis.exe server/analysis_binaries/"$platform"
done
for platform in "${platforms[@]}"; do
mkdir tools/binaries/"$platform"
mv binaries/"$platform"/rescript-tools.exe tools/binaries/"$platform"
done
- name: Store short commit SHA for filename
id: vars
env:
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: echo "sha_short=${COMMIT_SHA:0:7}" >> $GITHUB_OUTPUT
- name: Store tag name
id: tag_name
if: startsWith(github.ref, 'refs/tags/')
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Increment pre-release version
if: github.ref == 'refs/heads/master'
id: increment_pre_release
run: |
JSON=$(npx vsce show chenglou92.rescript-vscode --json)
NEW_VERSION=$(echo $JSON | jq -r '.versions | .[0] | .["version"]')
node .github/workflows/bump-version.js ${NEW_VERSION}
- name: Package Extension
if: github.ref != 'refs/heads/master'
run: npx vsce package -o rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
- name: Package Extension pre-release version
if: github.ref == 'refs/heads/master'
run: npx vsce package -o rescript-vscode-latest-master.vsix ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version
- name: Package Extension release version
if: startsWith(github.ref, 'refs/tags/')
run: npx vsce package -o rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix ${{ steps.tag_name.outputs.tag }} --no-git-tag-version
- uses: actions/upload-artifact@v4
if: github.ref != 'refs/heads/master'
with:
name: rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
path: rescript-vscode-${{ steps.vars.outputs.sha_short }}.vsix
- uses: actions/upload-artifact@v4
if: github.ref == 'refs/heads/master'
with:
name: rescript-vscode-latest-master.vsix
path: rescript-vscode-latest-master.vsix
- uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/')
with:
name: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
path: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
- name: Move latest-master tag to current commit
if: github.ref == 'refs/heads/master'
uses: jimeh/update-tags-action@v1
with:
tags: "latest-master"
- name: Publish latest master to GitHub
if: github.ref == 'refs/heads/master'
uses: softprops/action-gh-release@v2
with:
token: "${{ secrets.GITHUB_TOKEN }}"
tag_name: "latest-master"
prerelease: true
generate_release_notes: true
name: "Latest master"
files: rescript-vscode-latest-master.vsix
- name: Generate release notes from changelog
if: startsWith(github.ref, 'refs/tags/')
run: |
sed -e "/^## ${{ steps.tag_name.outputs.tag }}/,/^## / ! d" CHANGELOG.md | head -n -2 > RELEASE.md
- name: Publish release version to GitHub
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
body_path: RELEASE.md
name: ${{ steps.tag_name.outputs.tag }}
files: rescript-vscode-${{ steps.tag_name.outputs.tag }}.vsix
- name: Publish extension as pre-release
if: github.ref == 'refs/heads/master' && !startsWith(github.event.head_commit.message, 'publish tools')
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} --pre-release ${{ steps.increment_pre_release.outputs.new_version }} --no-git-tag-version
- name: Publish extension as release
if: startsWith(github.ref, 'refs/tags/')
run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version
- name: Publish LSP as pre-release to NPM
if: github.ref == 'refs/heads/master'
working-directory: server
run: |
npm version preminor --preid next-$(git rev-parse --short HEAD)
npm publish --access public --tag next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish LSP to NPM
if: startsWith(github.ref, 'refs/tags/')
working-directory: server
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build @rescript/tools package
working-directory: tools
run: |
npm ci
npm run build
- name: Publish @rescript/tools package
if: ${{ startsWith(github.event.head_commit.message, 'publish tools') && (github.ref == 'refs/heads/master') }}
working-directory: tools
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}