Skip to content

Merge branch 'development' into main: STruC++ v0.4.13 #39

Merge branch 'development' into main: STruC++ v0.4.13

Merge branch 'development' into main: STruC++ v0.4.13 #39

Workflow file for this run

name: Build & Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to inject (e.g. 1.0.0). Leave empty for 0.1-dev.'
required: false
type: string
permissions:
contents: write
jobs:
# ---------------------------------------------------------------------------
# Compute the version string once, share it across jobs
# ---------------------------------------------------------------------------
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Determine version
id: version
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
elif [[ -n "${{ inputs.version }}" ]]; then
VERSION="${{ inputs.version }}"
else
VERSION="0.1-dev"
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "### Version: \`${VERSION}\`" >> "$GITHUB_STEP_SUMMARY"
# ---------------------------------------------------------------------------
# Linux x64
# ---------------------------------------------------------------------------
build-linux-x64:
needs: prepare
runs-on: ubuntu-22.04
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Bundle
run: npm run build:bundle
- name: Build standalone binary
run: npx pkg dist/strucpp-bundle.cjs --target node18-linux-x64 --output dist/bin/strucpp --compress GZip
- name: Verify binary
run: |
file dist/bin/strucpp
dist/bin/strucpp --help || true
- name: Package
run: |
mkdir -p staging/strucpp/runtime/include staging/strucpp/runtime/repl staging/strucpp/runtime/test staging/strucpp/libs
cp dist/bin/strucpp staging/strucpp/
cp src/runtime/include/*.hpp staging/strucpp/runtime/include/
cp src/runtime/repl/* staging/strucpp/runtime/repl/
cp src/runtime/test/* staging/strucpp/runtime/test/
cp libs/*.stlib staging/strucpp/libs/
cp LICENSE COPYING COPYING.RUNTIME staging/strucpp/ 2>/dev/null || true
tar -czf strucpp-linux-x64.tar.gz -C staging strucpp
- uses: actions/upload-artifact@v4
with:
name: strucpp-linux-x64
path: strucpp-linux-x64.tar.gz
# ---------------------------------------------------------------------------
# Linux ARM64
# ---------------------------------------------------------------------------
build-linux-arm64:
needs: prepare
runs-on: ubuntu-24.04-arm
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Bundle
run: npm run build:bundle
- name: Build standalone binary
run: npx pkg dist/strucpp-bundle.cjs --target node18-linux-arm64 --output dist/bin/strucpp --compress GZip
- name: Verify binary
run: |
file dist/bin/strucpp
dist/bin/strucpp --help || true
- name: Package
run: |
mkdir -p staging/strucpp/runtime/include staging/strucpp/runtime/repl staging/strucpp/runtime/test staging/strucpp/libs
cp dist/bin/strucpp staging/strucpp/
cp src/runtime/include/*.hpp staging/strucpp/runtime/include/
cp src/runtime/repl/* staging/strucpp/runtime/repl/
cp src/runtime/test/* staging/strucpp/runtime/test/
cp libs/*.stlib staging/strucpp/libs/
cp LICENSE COPYING COPYING.RUNTIME staging/strucpp/ 2>/dev/null || true
tar -czf strucpp-linux-arm64.tar.gz -C staging strucpp
- uses: actions/upload-artifact@v4
with:
name: strucpp-linux-arm64
path: strucpp-linux-arm64.tar.gz
# ---------------------------------------------------------------------------
# macOS x64 (Intel) — cross-compiled via pkg on ARM runner
# ---------------------------------------------------------------------------
build-darwin-x64:
needs: prepare
runs-on: macos-15
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Bundle
run: npm run build:bundle
- name: Build standalone binary
run: npx pkg dist/strucpp-bundle.cjs --target node18-macos-x64 --output dist/bin/strucpp --compress GZip
- name: Verify binary
run: |
file dist/bin/strucpp
arch -x86_64 dist/bin/strucpp --help || true
- name: Package
run: |
mkdir -p staging/strucpp/runtime/include staging/strucpp/runtime/repl staging/strucpp/runtime/test staging/strucpp/libs
cp dist/bin/strucpp staging/strucpp/
cp src/runtime/include/*.hpp staging/strucpp/runtime/include/
cp src/runtime/repl/* staging/strucpp/runtime/repl/
cp src/runtime/test/* staging/strucpp/runtime/test/
cp libs/*.stlib staging/strucpp/libs/
cp LICENSE COPYING COPYING.RUNTIME staging/strucpp/ 2>/dev/null || true
cd staging && zip -r ../strucpp-darwin-x64.zip strucpp
- uses: actions/upload-artifact@v4
with:
name: strucpp-darwin-x64
path: strucpp-darwin-x64.zip
# ---------------------------------------------------------------------------
# macOS ARM64 (Apple Silicon)
# ---------------------------------------------------------------------------
build-darwin-arm64:
needs: prepare
runs-on: macos-15
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Bundle
run: npm run build:bundle
- name: Build standalone binary
run: npx pkg dist/strucpp-bundle.cjs --target node18-macos-arm64 --output dist/bin/strucpp --compress GZip
- name: Verify binary
run: |
file dist/bin/strucpp
dist/bin/strucpp --help || true
- name: Package
run: |
mkdir -p staging/strucpp/runtime/include staging/strucpp/runtime/repl staging/strucpp/runtime/test staging/strucpp/libs
cp dist/bin/strucpp staging/strucpp/
cp src/runtime/include/*.hpp staging/strucpp/runtime/include/
cp src/runtime/repl/* staging/strucpp/runtime/repl/
cp src/runtime/test/* staging/strucpp/runtime/test/
cp libs/*.stlib staging/strucpp/libs/
cp LICENSE COPYING COPYING.RUNTIME staging/strucpp/ 2>/dev/null || true
cd staging && zip -r ../strucpp-darwin-arm64.zip strucpp
- uses: actions/upload-artifact@v4
with:
name: strucpp-darwin-arm64
path: strucpp-darwin-arm64.zip
# ---------------------------------------------------------------------------
# Windows x64 (cross-compiled via pkg on Linux)
# ---------------------------------------------------------------------------
build-windows-x64:
needs: prepare
runs-on: ubuntu-22.04
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Bundle
run: npm run build:bundle
- name: Build standalone binary
run: npx pkg dist/strucpp-bundle.cjs --target node18-win-x64 --output dist/bin/strucpp.exe --compress GZip
- name: Verify binary
run: file dist/bin/strucpp.exe
- name: Package
run: |
mkdir -p staging/strucpp/runtime/include staging/strucpp/runtime/repl staging/strucpp/runtime/test staging/strucpp/libs
cp dist/bin/strucpp.exe staging/strucpp/
cp src/runtime/include/*.hpp staging/strucpp/runtime/include/
cp src/runtime/repl/* staging/strucpp/runtime/repl/
cp src/runtime/test/* staging/strucpp/runtime/test/
cp libs/*.stlib staging/strucpp/libs/
cp LICENSE COPYING COPYING.RUNTIME staging/strucpp/ 2>/dev/null || true
cd staging && zip -r ../strucpp-win32-x64.zip strucpp
- uses: actions/upload-artifact@v4
with:
name: strucpp-win32-x64
path: strucpp-win32-x64.zip
# ---------------------------------------------------------------------------
# npm tarball (platform-independent — used by OpenPLC Editor)
# ---------------------------------------------------------------------------
build-npm:
needs: prepare
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install vscode-extension dependencies
# Required so the browser-server bundle can build during prepack.
run: npm ci
working-directory: vscode-extension
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Build
run: npm run build
- name: Create npm tarball
# `npm pack` triggers `prepack`, which builds the browser-server
# bundle into `dist/browser-server.js` so it ships in the tarball
# alongside the Node compiler output.
run: npm pack
- uses: actions/upload-artifact@v4
with:
name: strucpp-npm
path: strucpp-*.tgz
# ---------------------------------------------------------------------------
# VSCode Extension (.vsix)
# ---------------------------------------------------------------------------
build-vsix:
needs: prepare
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install compiler dependencies and build
run: npm ci && npm run build
- name: Install extension dependencies
run: cd vscode-extension && npm ci
- name: Inject version
run: cd vscode-extension && npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Package extension
run: cd vscode-extension && npx @vscode/vsce package --no-dependencies
- uses: actions/upload-artifact@v4
with:
name: strucpp-vsix
path: vscode-extension/*.vsix
# ---------------------------------------------------------------------------
# Create GitHub Release (only on tag push)
# ---------------------------------------------------------------------------
create-release:
if: startsWith(github.ref, 'refs/tags/')
needs:
- prepare
- build-linux-x64
- build-linux-arm64
- build-darwin-x64
- build-darwin-arm64
- build-windows-x64
- build-npm
- build-vsix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
cp artifacts/strucpp-linux-x64/strucpp-linux-x64.tar.gz release/
cp artifacts/strucpp-linux-arm64/strucpp-linux-arm64.tar.gz release/
cp artifacts/strucpp-darwin-x64/strucpp-darwin-x64.zip release/
cp artifacts/strucpp-darwin-arm64/strucpp-darwin-arm64.zip release/
cp artifacts/strucpp-win32-x64/strucpp-win32-x64.zip release/
# Windows ARM64 runs x64 binaries via emulation
cp release/strucpp-win32-x64.zip release/strucpp-win32-arm64.zip
# npm tarball (platform-independent, used by OpenPLC Editor)
cp artifacts/strucpp-npm/strucpp-*.tgz release/
cp artifacts/strucpp-vsix/*.vsix release/
ls -lh release/
- name: Detect prerelease
id: prerelease
run: |
TAG="${{ github.ref_name }}"
if [[ "$TAG" =~ (alpha|beta|rc) ]]; then
echo "flag=--prerelease" >> "$GITHUB_OUTPUT"
else
echo "flag=" >> "$GITHUB_OUTPUT"
fi
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" \
--title "${{ github.ref_name }}" \
--generate-notes \
${{ steps.prerelease.outputs.flag }} \
release/*
- name: Publish extension to VSCode Marketplace
if: env.VSCE_PAT != ''
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: npx @vscode/vsce publish --packagePath release/*.vsix --pat "$VSCE_PAT"