Skip to content

support for alias and importing symbols in remote imports #2110

support for alias and importing symbols in remote imports

support for alias and importing symbols in remote imports #2110

name: Build and Deploy on Commit
permissions:
contents: write
on:
push:
branches:
- main
workflow_dispatch:
env:
LLVM_RELEASE_TAG: "v2"
jobs:
build-windows:
name: Build on Windows (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
# Only run when the commit message contains "releaseIt"
if: |
github.event_name == 'workflow_dispatch' ||
contains(github.event.head_commit.message, 'releaseIt')
strategy:
fail-fast: false
matrix:
include:
- arch: x64
runner: windows-2025
llvm_asset: windows-x64.zip
- arch: arm64
runner: windows-11-arm
llvm_asset: windows-arm64.zip
steps:
# Checkout chemical repository
- name: Checkout chemical repository
uses: actions/checkout@v4
with:
repository: chemicallang/chemical
token: ${{ secrets.GITHUB_TOKEN }}
path: chemical
submodules: recursive
# ––– Setup build environment –––
- name: Set up Visual Studio Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
# Download prebuilt LLVM and unzip it
- name: Download prebuilt LLVM
shell: pwsh
run: |
$url = "https://github.com/chemicallang/llvm-prebuilt/releases/download/${{ env.LLVM_RELEASE_TAG }}/${{ matrix.llvm_asset }}"
Write-Host "Downloading LLVM from $url"
curl.exe -L -o llvm.zip -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" $url
7z x llvm.zip -y
# Configure the project
- name: Map workspace to X and configure
shell: pwsh
run: |
subst X: $PWD
cd X:\chemical
mkdir out\build
cmake -S . -B out\build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_NINJA_FORCE_RESPONSE_FILE=ON
# Run the configure script to configure the project
- name: Run configure script (Windows)
working-directory: chemical
run: bash ./scripts/configure.sh --arch ${{ matrix.arch }}
# Building the llvm based, tiny cc based compilers and lsp
- name: Build Compiler Targets
working-directory: chemical
run: |
cmake --build out\build --config Release --target Compiler
cmake --build out\build --config Release --target TCCCompiler
cmake --build out\build --config Release --target ChemicalLsp
# Run the release script to create ZIP files
- name: Run release packaging script (Windows)
working-directory: chemical
run: bash ./scripts/release.sh --windows
# rename windows release files to include the aarch
- name: Rename Windows release files
shell: bash
run: |
mv chemical/out/release/windows.zip chemical/out/release/windows-${{ matrix.arch }}.zip
mv chemical/out/release/windows-tcc.zip chemical/out/release/windows-${{ matrix.arch }}-tcc.zip
mv chemical/out/release/windows-lsp.zip chemical/out/release/windows-${{ matrix.arch }}-lsp.zip
# ––– Get information about the latest release –––
- name: Get latest release info
id: get_latest_release
uses: actions/github-script@v6
with:
script: |
const releasesResponse = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const validReleases = releasesResponse.data.filter(release => !release.draft);
if (validReleases.length === 0) {
throw new Error("No published or pre-releases found.");
}
const latestRelease = validReleases[0];
core.setOutput("tag", latestRelease.tag_name);
core.setOutput("id", latestRelease.id);
# ––– we check whether it is already attached –––
- name: Check if windows-${{ matrix.arch }}.zip exists in latest release
id: check_windows
uses: actions/github-script@v6
with:
script: |
const tag = '${{ steps.get_latest_release.outputs.tag }}';
const { data: release } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag
});
const filenames = [
`windows-${{ matrix.arch }}.zip`,
`windows-${{ matrix.arch }}-tcc.zip`,
`windows-${{ matrix.arch }}-lsp.zip`
];
// Check if any of these files exist in the release assets
const exists = release.assets.some(asset => filenames.includes(asset.name));
core.setOutput("exists", exists.toString());
# Upload artifacts
- name: Upload release artifacts
if: steps.check_windows.outputs.exists == 'false'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_latest_release.outputs.tag }}
files: |
chemical/out/release/windows-${{ matrix.arch }}.zip
chemical/out/release/windows-${{ matrix.arch }}-tcc.zip
chemical/out/release/windows-${{ matrix.arch }}-lsp.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save windows-${{ matrix.arch }}.zip as artifact if already exists
if: steps.check_windows.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.arch }}.zip
path: chemical/out/release/windows-${{ matrix.arch }}.zip
- name: Save windows-${{ matrix.arch }}-tcc.zip as artifact if already exists
if: steps.check_windows.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.arch }}-tcc.zip
path: chemical/out/release/windows-${{ matrix.arch }}-tcc.zip
- name: Save windows-${{ matrix.arch }}-lsp.zip as artifact if already exists
if: steps.check_windows.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: windows-${{ matrix.arch }}-lsp.zip
path: chemical/out/release/windows-${{ matrix.arch }}-lsp.zip
build-linux:
name: Build on Linux (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
if: |
github.event_name == 'workflow_dispatch' ||
contains(github.event.head_commit.message, 'releaseIt')
strategy:
matrix:
include:
- arch: x64
runner: ubuntu-24.04
llvm_asset: linux-x64.tar.gz
- arch: arm64
runner: ubuntu-24.04-arm
llvm_asset: linux-arm64.tar.gz
steps:
# Checkout chemical repository
- name: Checkout chemical repository
uses: actions/checkout@v4
with:
repository: chemicallang/chemical
token: ${{ secrets.GITHUB_TOKEN }}
path: chemical
submodules: recursive
# ––– Install dependencies –––
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake git
- name: Download prebuilt LLVM
run: |
curl -L -o llvm.tar.gz \
-H "Authorization: token $GITHUB_TOKEN" \
"https://github.com/chemicallang/llvm-prebuilt/releases/download/${{ env.LLVM_RELEASE_TAG }}/${{ matrix.llvm_asset }}"
tar -xzf llvm.tar.gz
# Configure chemical project
- name: Configure Chemical Project
working-directory: chemical
run: |
mkdir -p out/build
cmake -S . -B out/build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON
# Configure project dependencies using configuration script
- name: Run configure script
working-directory: chemical
run: |
chmod +x ./scripts/configure.sh
./scripts/configure.sh --arch ${{ matrix.arch }}
- name: Build Compiler Targets
working-directory: chemical
run: |
cmake --build out/build --config Release --target Compiler
cmake --build out/build --config Release --target TCCCompiler
cmake --build out/build --config Release --target ChemicalLsp
- name: Run release packaging
working-directory: chemical
run: |
chmod +x ./scripts/release.sh
./scripts/release.sh --linux
# rename linux release files to include the aarch
- name: Rename Linux release files
shell: bash
run: |
mv chemical/out/release/linux.zip chemical/out/release/linux-${{ matrix.arch }}.zip
mv chemical/out/release/linux-tcc.zip chemical/out/release/linux-${{ matrix.arch }}-tcc.zip
mv chemical/out/release/linux-lsp.zip chemical/out/release/linux-${{ matrix.arch }}-lsp.zip
# ––– Get information about the latest release –––
- name: Get latest release info
id: get_latest_release
uses: actions/github-script@v6
with:
script: |
const releasesResponse = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const validReleases = releasesResponse.data.filter(release => !release.draft);
if (validReleases.length === 0) {
throw new Error("No published or pre-releases found.");
}
const latestRelease = validReleases[0];
core.setOutput("tag", latestRelease.tag_name);
core.setOutput("id", latestRelease.id);
# ––– Check and (conditionally) upload Linux archives –––
- name: Check if linux-${{ matrix.arch }}.zip exists in latest release
id: check_linux
uses: actions/github-script@v6
with:
script: |
const tag = '${{ steps.get_latest_release.outputs.tag }}';
const { data: release } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag
});
const filenames = [
`linux-${{ matrix.arch }}.zip`,
`linux-${{ matrix.arch }}-tcc.zip`,
`linux-${{ matrix.arch }}-lsp.zip`
];
// Check if any of these files exist in the release assets
const exists = release.assets.some(asset => filenames.includes(asset.name));
core.setOutput("exists", exists.toString());
- name: Upload release artifacts
if: steps.check_linux.outputs.exists == 'false'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_latest_release.outputs.tag }}
files: |
chemical/out/release/linux-${{ matrix.arch }}.zip
chemical/out/release/linux-${{ matrix.arch }}-tcc.zip
chemical/out/release/linux-${{ matrix.arch }}-lsp.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save linux-${{ matrix.arch }}.zip as artifact if already exists
if: steps.check_linux.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: linux-${{ matrix.arch }}.zip
path: chemical/out/release/linux-${{ matrix.arch }}.zip
- name: Save linux-${{ matrix.arch }}-tcc.zip as artifact if already exists
if: steps.check_linux.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: linux-${{ matrix.arch }}-tcc.zip
path: chemical/out/release/linux-${{ matrix.arch }}-tcc.zip
- name: Save linux-${{ matrix.arch }}-lsp.zip as artifact if already exists
if: steps.check_linux.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: linux-${{ matrix.arch }}-lsp.zip
path: chemical/out/release/linux-${{ matrix.arch }}-lsp.zip
build-alpine:
name: Build on Alpine Linux (${{ matrix.arch }})
container:
image: alpine:3.20
runs-on: ${{ matrix.runner }}
if: |
github.event_name == 'workflow_dispatch' ||
contains(github.event.head_commit.message, 'releaseIt')
strategy:
fail-fast: false
matrix:
include:
- arch: x64
runner: ubuntu-24.04
llvm_asset: linux-alpine-x64.tar.gz
- arch: arm64
runner: ubuntu-24.04-arm
llvm_asset: linux-alpine-arm64.tar.gz
steps:
# ––– Install dependencies –––
- name: Install dependencies
run: |
apk add --no-cache build-base cmake ninja git bash python3 curl musl-dev linux-headers zip unzip
# Checkout chemical repository
- name: Checkout chemical repository
uses: actions/checkout@v4
with:
repository: chemicallang/chemical
token: ${{ secrets.GITHUB_TOKEN }}
path: chemical
submodules: recursive
- name: Download prebuilt LLVM
run: |
curl -L -o llvm.tar.gz \
-H "Authorization: token $GITHUB_TOKEN" \
"https://github.com/chemicallang/llvm-prebuilt/releases/download/${{ env.LLVM_RELEASE_TAG }}/${{ matrix.llvm_asset }}"
tar -xzf llvm.tar.gz
# Linux steps unchanged
- name: Configure Chemical Project
working-directory: chemical
run: |
mkdir -p out/build
cmake -S . -B out/build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON
# Configure project dependencies using configuration script
- name: Run configure script
working-directory: chemical
run: |
chmod +x ./scripts/configure.sh
./scripts/configure.sh --arch ${{ matrix.arch }}
- name: Build Compiler Targets
working-directory: chemical
run: |
cmake --build out/build --config Release --target Compiler
cmake --build out/build --config Release --target TCCCompiler
- name: Run release packaging
working-directory: chemical
run: |
chmod +x ./scripts/release.sh
./scripts/release.sh --alpine
# rename linux release files to include the aarch
- name: Rename Linux Alpine release files
shell: bash
run: |
mv chemical/out/release/linux-alpine.zip chemical/out/release/linux-alpine-${{ matrix.arch }}.zip
mv chemical/out/release/linux-alpine-tcc.zip chemical/out/release/linux-alpine-${{ matrix.arch }}-tcc.zip
- name: Get latest release info
id: get_latest_release
uses: actions/github-script@v6
with:
script: |
const releasesResponse = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const validReleases = releasesResponse.data.filter(release => !release.draft);
if (validReleases.length === 0) {
throw new Error("No published or pre-releases found.");
}
const latestRelease = validReleases[0];
core.setOutput("tag", latestRelease.tag_name);
core.setOutput("id", latestRelease.id);
# ––– Check and (conditionally) upload Linux archives –––
- name: Check if linux-alpine-${{ matrix.arch }}.zip exists in latest release
id: check_linux
uses: actions/github-script@v6
with:
script: |
const tag = '${{ steps.get_latest_release.outputs.tag }}';
const { data: release } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag
});
const filenames = [
`linux-alpine-${{ matrix.arch }}.zip`,
`linux-alpine-${{ matrix.arch }}-tcc.zip`
];
// Check if any of these files exist in the release assets
const exists = release.assets.some(asset => filenames.includes(asset.name));
core.setOutput("exists", exists.toString());
- name: Upload release artifacts
if: steps.check_linux.outputs.exists == 'false'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_latest_release.outputs.tag }}
files: |
chemical/out/release/linux-alpine-${{ matrix.arch }}.zip
chemical/out/release/linux-alpine-${{ matrix.arch }}-tcc.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save linux-alpine-${{ matrix.arch }}.zip as artifact if already exists
if: steps.check_linux.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: linux-alpine-${{ matrix.arch }}.zip
path: chemical/out/release/linux-alpine-${{ matrix.arch }}.zip
- name: Save linux-alpine-${{ matrix.arch }}-tcc.zip as artifact if already exists
if: steps.check_linux.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: linux-alpine-${{ matrix.arch }}-tcc.zip
path: chemical/out/release/linux-alpine-${{ matrix.arch }}-tcc.zip
build-macos:
name: Build on macOS (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
if: |
github.event_name == 'workflow_dispatch' ||
contains(github.event.head_commit.message, 'releaseIt')
strategy:
matrix:
include:
- arch: x64
runner: macos-15-intel
llvm_asset: macos-x64.tar.gz
- arch: arm64
runner: macos-26
llvm_asset: macos-arm64.tar.gz
steps:
# ––– Install dependencies –––
- name: Install Dependencies
run: |
brew update
brew install cmake ninja git
- name: Checkout chemical repository
uses: actions/checkout@v4
with:
repository: chemicallang/chemical
token: ${{ secrets.GITHUB_TOKEN }}
path: chemical
submodules: recursive
- name: Download prebuilt LLVM
run: |
curl -L -o llvm.tar.gz \
-H "Authorization: token $GITHUB_TOKEN" \
"https://github.com/chemicallang/llvm-prebuilt/releases/download/${{ env.LLVM_RELEASE_TAG }}/${{ matrix.llvm_asset }}"
tar -xzf llvm.tar.gz
# Configure chemical project
- name: Configure Chemical Project
working-directory: chemical
run: |
mkdir -p out/build
cmake -S . -B out/build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 -DCMAKE_CXX_STANDARD_REQUIRED=ON
# Run configure script
- name: Run configure script
working-directory: chemical
run: |
chmod +x ./scripts/configure.sh
./scripts/configure.sh --arch ${{ matrix.arch }}
# Build Compiler Targets
- name: Build Compiler Targets
working-directory: chemical
run: |
cmake --build out/build --config Release --target Compiler
cmake --build out/build --config Release --target TCCCompiler
cmake --build out/build --config Release --target ChemicalLsp
# Run release packaging
- name: Run release packaging
working-directory: chemical
run: |
chmod +x ./scripts/release.sh
./scripts/release.sh --macos
# Rename macOS release files to include the arch
- name: Rename macOS release files
shell: bash
run: |
mv chemical/out/release/macos.zip chemical/out/release/macos-${{ matrix.arch }}.zip
mv chemical/out/release/macos-tcc.zip chemical/out/release/macos-${{ matrix.arch }}-tcc.zip
mv chemical/out/release/macos-lsp.zip chemical/out/release/macos-${{ matrix.arch }}-lsp.zip
# Get latest release info
- name: Get latest release info
id: get_latest_release
uses: actions/github-script@v6
with:
script: |
const releasesResponse = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
});
const validReleases = releasesResponse.data.filter(release => !release.draft);
if (validReleases.length === 0) {
throw new Error("No published or pre-releases found.");
}
const latestRelease = validReleases[0];
core.setOutput("tag", latestRelease.tag_name);
core.setOutput("id", latestRelease.id);
# Check and (conditionally) upload macOS archives
- name: Check if macos-${{ matrix.arch }}.zip exists in latest release
id: check_macos
uses: actions/github-script@v6
with:
script: |
const tag = '${{ steps.get_latest_release.outputs.tag }}';
const { data: release } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag
});
const filenames = [
`macos-${{ matrix.arch }}.zip`,
`macos-${{ matrix.arch }}-tcc.zip`,
`macos-${{ matrix.arch }}-lsp.zip`
];
const exists = release.assets.some(asset => filenames.includes(asset.name));
core.setOutput("exists", exists.toString());
# Upload artifacts
- name: Upload release artifacts
if: steps.check_macos.outputs.exists == 'false'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_latest_release.outputs.tag }}
files: |
chemical/out/release/macos-${{ matrix.arch }}.zip
chemical/out/release/macos-${{ matrix.arch }}-tcc.zip
chemical/out/release/macos-${{ matrix.arch }}-lsp.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Save as artifact if already exists
- name: Save macos-${{ matrix.arch }}.zip as artifact if already exists
if: steps.check_macos.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: macos-${{ matrix.arch }}.zip
path: chemical/out/release/macos-${{ matrix.arch }}.zip
- name: Save macos-${{ matrix.arch }}-tcc.zip as artifact if already exists
if: steps.check_macos.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: macos-${{ matrix.arch }}-tcc.zip
path: chemical/out/release/macos-${{ matrix.arch }}-tcc.zip
- name: Save macos-${{ matrix.arch }}-lsp.zip as artifact if already exists
if: steps.check_macos.outputs.exists == 'true'
uses: actions/upload-artifact@v4
with:
name: macos-${{ matrix.arch }}-lsp.zip
path: chemical/out/release/macos-${{ matrix.arch }}-lsp.zip