added roadmap releaseit #71
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 Deploy on Commit | |
permissions: | |
contents: write | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-windows: | |
name: Build on Windows | |
runs-on: windows-latest | |
# Only run when the commit message contains "releaseIt" | |
if: contains(github.event.head_commit.message, 'releaseIt') | |
steps: | |
# ––– Checkout repositories ––– | |
- name: Checkout chemical-bootstrap repository | |
uses: actions/checkout@v3 | |
with: | |
repository: chemicallang/chemical-bootstrap | |
token: ${{ secrets.GITHUB_TOKEN }} | |
path: chemical-bootstrap | |
# Checkout chemical repository inside chemical-bootstrap | |
- name: Checkout chemical repository inside chemical-bootstrap | |
uses: actions/checkout@v3 | |
with: | |
repository: chemicallang/chemical | |
token: ${{ secrets.GITHUB_TOKEN }} | |
path: chemical-bootstrap/chemical | |
# ––– Setup build environment ––– | |
- name: Set up Visual Studio Developer Command Prompt | |
uses: ilammy/msvc-dev-cmd@v1 | |
with: | |
arch: x86_64 | |
# Get the SHA of the chemical-bootstrap repository | |
- name: Get SHA of chemical-bootstrap repository | |
id: get-sha | |
shell: pwsh | |
working-directory: chemical-bootstrap | |
run: | | |
$sha = (git rev-parse HEAD).Trim() | |
echo "sha=$sha" >> $env:GITHUB_OUTPUT | |
# Setup Cache for out-win folder | |
- uses: actions/cache@v4 | |
id: bootstrap-cache | |
with: | |
path: ./chemical-bootstrap/out-win/ | |
key: ${{ runner.os }}-${{ steps.get-sha.outputs.sha }} | |
# Build the chemical-bootstrap project (only if not cached) | |
- name: Build chemical-bootstrap (Windows) | |
working-directory: chemical-bootstrap | |
run: .\build.bat native-windows-gnu native | |
if: steps.bootstrap-cache.outputs.cache-hit != 'true' | |
# Build the chemical project executables via CMake | |
- name: Build chemical project (Windows) | |
working-directory: chemical-bootstrap/chemical | |
run: | | |
mkdir out\release | |
cmake -S . -B out\build\x64-release -G Ninja -DCMAKE_BUILD_TYPE=Release | |
cmake --build out\build\x64-release --config Release --target Compiler | |
cmake --build out\build\x64-release --config Release --target TCCCompiler | |
cmake --build out\build\x64-release --config Release --target ChemicalLsp || true | |
env: | |
BOOST_ROOT: ${{ env.BOOST_ROOT }} | |
# Run the release script to create ZIP files | |
- name: Run release packaging script (Windows) | |
working-directory: chemical-bootstrap/chemical | |
# Assuming Git Bash is available on windows-latest (if not, you might need to install/setup MSYS2) | |
run: bash release.sh | |
# ––– 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); | |
# ––– For each archive we check whether it is already attached ––– | |
- name: Check if windows-x64.zip exists in latest release | |
id: check_windows_x64 | |
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 exists = release.assets.some(asset => asset.name === 'windows-x64.zip'); | |
core.setOutput("exists", exists.toString()); | |
- name: Upload windows-x64.zip to release if not exists | |
if: steps.check_windows_x64.outputs.exists == 'false' | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.get_latest_release.outputs.tag }} | |
files: chemical-bootstrap/chemical/out/release/windows-x64.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Save windows-x64.zip as artifact if already exists | |
if: steps.check_windows_x64.outputs.exists == 'true' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-x64.zip | |
path: chemical-bootstrap/chemical/out/release/windows-x64.zip | |
# Repeat similar steps for the second Windows archive: | |
- name: Check if windows-x64-tcc.zip exists in latest release | |
id: check_windows_x64_tcc | |
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 exists = release.assets.some(asset => asset.name === 'windows-x64-tcc.zip'); | |
core.setOutput("exists", exists.toString()); | |
- name: Upload windows-x64-tcc.zip to release if not exists | |
if: steps.check_windows_x64_tcc.outputs.exists == 'false' | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.get_latest_release.outputs.tag }} | |
files: chemical-bootstrap/chemical/out/release/windows-x64-tcc.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Save windows-x64-tcc.zip as artifact if already exists | |
if: steps.check_windows_x64_tcc.outputs.exists == 'true' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: windows-x64-tcc.zip | |
path: chemical-bootstrap/chemical/out/release/windows-x64-tcc.zip | |
build-linux: | |
name: Build on Linux | |
runs-on: ubuntu-latest | |
# Only run when the commit message contains "releaseIt" | |
if: contains(github.event.head_commit.message, 'releaseIt') | |
steps: | |
# ––– Checkout repositories ––– | |
- name: Checkout chemical-bootstrap repository | |
uses: actions/checkout@v3 | |
with: | |
repository: chemicallang/chemical-bootstrap | |
token: ${{ secrets.GITHUB_TOKEN }} | |
path: chemical-bootstrap | |
# Checkout chemical repository inside chemical-bootstrap | |
- name: Checkout chemical repository inside chemical-bootstrap | |
uses: actions/checkout@v3 | |
with: | |
repository: chemicallang/chemical | |
token: ${{ secrets.GITHUB_TOKEN }} | |
path: chemical-bootstrap/chemical | |
# ––– Install dependencies ––– | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential cmake git | |
# (Do not install libboost-all-dev since we want Boost 1.74.0) | |
# Get the SHA of the chemical-bootstrap repository | |
- name: Get SHA of chemical-bootstrap repository | |
id: get-sha | |
working-directory: chemical-bootstrap | |
run: | | |
SHA=$(git rev-parse HEAD | xargs) | |
echo "sha=$SHA" >> $GITHUB_OUTPUT | |
# Setup Cache for out folder | |
- uses: actions/cache@v4 | |
id: bootstrap-cache | |
with: | |
path: ./chemical-bootstrap/out/ | |
key: ${{ runner.os }}-${{ steps.get-sha.outputs.sha }} | |
# Build the chemical-bootstrap project (Linux) (only if not cached) | |
- name: Build chemical-bootstrap (Linux) | |
working-directory: chemical-bootstrap | |
run: | | |
chmod +x build | |
./build native-linux-gnu native | |
if: steps.bootstrap-cache.outputs.cache-hit != 'true' | |
# Build the chemical project executables via CMake | |
- name: Build chemical project (Linux) | |
working-directory: chemical-bootstrap/chemical | |
run: | | |
mkdir -p out/release | |
cmake -S . -B out/build/x64-release-wsl -DCMAKE_BUILD_TYPE=Release | |
cmake --build out/build/x64-release-wsl --config Release --target Compiler | |
cmake --build out/build/x64-release-wsl --config Release --target TCCCompiler | |
cmake --build out/build/x64-release-wsl --config Release --target ChemicalLsp || true | |
env: | |
BOOST_ROOT: ${{ env.BOOST_ROOT }} | |
# Run the release packaging script to create ZIP files | |
- name: Run release packaging script (Linux) | |
working-directory: chemical-bootstrap/chemical | |
run: | | |
chmod +x release.sh | |
./release.sh | |
# ––– 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-x86-64.zip exists in latest release | |
id: check_linux_x64 | |
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 exists = release.assets.some(asset => asset.name === 'linux-x86-64.zip'); | |
core.setOutput("exists", exists.toString()); | |
- name: Upload linux-x86-64.zip to release if not exists | |
if: steps.check_linux_x64.outputs.exists == 'false' | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.get_latest_release.outputs.tag }} | |
files: chemical-bootstrap/chemical/out/release/linux-x86-64.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Save linux-x86-64.zip as artifact if already exists | |
if: steps.check_linux_x64.outputs.exists == 'true' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux-x86-64.zip | |
path: chemical-bootstrap/chemical/out/release/linux-x86-64.zip | |
- name: Check if linux-x86-64-tcc.zip exists in latest release | |
id: check_linux_x64_tcc | |
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 exists = release.assets.some(asset => asset.name === 'linux-x86-64-tcc.zip'); | |
core.setOutput("exists", exists.toString()); | |
- name: Upload linux-x86-64-tcc.zip to release if not exists | |
if: steps.check_linux_x64_tcc.outputs.exists == 'false' | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ steps.get_latest_release.outputs.tag }} | |
files: chemical-bootstrap/chemical/out/release/linux-x86-64-tcc.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Save linux-x86-64-tcc.zip as artifact if already exists | |
if: steps.check_linux_x64_tcc.outputs.exists == 'true' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: linux-x86-64-tcc.zip | |
path: chemical-bootstrap/chemical/out/release/linux-x86-64-tcc.zip |