Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Build and Test

on:
push:
branches: [ main, 'release/**' ]
pull_request:
branches: [ main ]

jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y gcc make zlib1g-dev

- name: Build nauty
run: |
curl -L -o nauty2_9_3.tar.gz https://users.cecs.anu.edu.au/~bdm/nauty/nauty2_9_3.tar.gz
tar xzf nauty2_9_3.tar.gz
cd nauty2_9_3
./configure && make

- name: Build surge
working-directory: src
run: |
make surge \
NAUTY=${{ github.workspace }}/nauty2_9_3 \
NAUTYLIB=${{ github.workspace }}/nauty2_9_3 \
CCOPT="-O3"

- name: Test surge
working-directory: src
run: |
./surge -help 2>&1 | head -3
./surge -u C6H6
./surge -u C4H10

- name: Build canonsdf
working-directory: src
run: |
make canonsdf \
NAUTY=${{ github.workspace }}/nauty2_9_3 \
NAUTYLIB=${{ github.workspace }}/nauty2_9_3 \
CCOPT="-O3"

- name: Upload Linux binary
uses: actions/upload-artifact@v4
with:
name: surge-linux-x86_64
path: src/surge

build-macos:
strategy:
matrix:
include:
- os: macos-14
arch: arm64
- os: macos-15
arch: arm64-m15
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Install nauty
run: brew install nauty

- name: Create nauty library symlink
run: |
NAUTY_LIB=$(brew --prefix nauty)/lib
ln -sf "$NAUTY_LIB/libnautyL1.a" "$NAUTY_LIB/nautyL1.a"

- name: Build surge
working-directory: src
run: |
make surge \
NAUTY=$(brew --prefix nauty)/include/nauty \
NAUTYLIB=$(brew --prefix nauty)/lib \
CCOPT="-O3"

- name: Test surge
working-directory: src
run: |
./surge -help 2>&1 | head -3
./surge -u C6H6
./surge -u C4H10

- name: Upload macOS binary
uses: actions/upload-artifact@v4
with:
name: surge-macos-${{ matrix.arch }}
path: src/surge

build-windows:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4

- uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
install: >-
mingw-w64-ucrt-x86_64-gcc
make
mingw-w64-ucrt-x86_64-zlib
curl
tar

- name: Build nauty
run: |
curl -L -o nauty2_9_3.tar.gz https://users.cecs.anu.edu.au/~bdm/nauty/nauty2_9_3.tar.gz
tar xzf nauty2_9_3.tar.gz
cd nauty2_9_3
./configure && make

- name: Build surge
working-directory: src
run: |
make surge \
NAUTY=$(cygpath -u "$GITHUB_WORKSPACE")/nauty2_9_3 \
NAUTYLIB=$(cygpath -u "$GITHUB_WORKSPACE")/nauty2_9_3 \
CCOPT="-O3"

- name: Test surge
working-directory: src
run: |
./surge.exe -help 2>&1 | head -3
./surge.exe -u C6H6
./surge.exe -u C4H10

- name: Upload Windows binary
uses: actions/upload-artifact@v4
with:
name: surge-windows-x86_64
path: src/surge.exe
137 changes: 137 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
build-release:
strategy:
matrix:
include:
- os: ubuntu-latest
artifact: surge-linux-x86_64
binary: surge
- os: macos-14
artifact: surge-macos-arm64
binary: surge
- os: windows-latest
artifact: surge-windows-x86_64
binary: surge.exe
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
steps:
- uses: actions/checkout@v4

- name: Setup MSYS2 (Windows only)
if: matrix.os == 'windows-latest'
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
install: >-
mingw-w64-ucrt-x86_64-gcc
make
mingw-w64-ucrt-x86_64-zlib
curl
tar

- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y gcc make zlib1g-dev

- name: Install nauty (macOS)
if: startsWith(matrix.os, 'macos')
run: |
brew install nauty
NAUTY_LIB=$(brew --prefix nauty)/lib
ln -sf "$NAUTY_LIB/libnautyL1.a" "$NAUTY_LIB/nautyL1.a"

- name: Build nauty from source (Linux/Windows)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'windows-latest'
run: |
curl -L -o nauty2_9_3.tar.gz https://users.cecs.anu.edu.au/~bdm/nauty/nauty2_9_3.tar.gz
tar xzf nauty2_9_3.tar.gz
cd nauty2_9_3
./configure && make

- name: Build surge (Linux/Windows)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'windows-latest'
working-directory: src
run: |
make surge \
NAUTY=$(cygpath -u "$GITHUB_WORKSPACE" 2>/dev/null || echo "$GITHUB_WORKSPACE")/nauty2_9_3 \
NAUTYLIB=$(cygpath -u "$GITHUB_WORKSPACE" 2>/dev/null || echo "$GITHUB_WORKSPACE")/nauty2_9_3 \
CCOPT="-O3"

- name: Build surge (macOS)
if: startsWith(matrix.os, 'macos')
working-directory: src
run: |
make surge \
NAUTY=$(brew --prefix nauty)/include/nauty \
NAUTYLIB=$(brew --prefix nauty)/lib \
CCOPT="-O3"

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: src/${{ matrix.binary }}

create-release:
needs: build-release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Package binaries
run: |
cd artifacts
for dir in */; do
name="${dir%/}"
cd "$name"
chmod +x * 2>/dev/null || true
tar czf "../${name}.tar.gz" *
cd ..
done

- name: Create Release
uses: softprops/action-gh-release@v2
with:
name: "Surge ${{ github.ref_name }}"
draft: true
generate_release_notes: false
body: |
## Surge 2.0

A fast open-source chemical graph generator.

### What's New in 2.0
- **64-bit word size**: Supports larger molecular structures
- **Aromaticity detection** (`-R`): Filter duplicate Kekule structures under carbon-ring aromaticity
- **Hexagon restrictions** (`-h#`, `-h#:#`): Control 6-membered cycle counts
- **Carbon 6-ring restrictions** (`-C#`, `-C#:#`): Limit carbon-only 6-membered rings
- **Improved summary reporting**

### Installation
Download the binary for your platform below, or build from source (see README).

### Binaries
- `surge-linux-x86_64.tar.gz` - Linux (x86_64)
- `surge-macos-arm64.tar.gz` - macOS (Apple Silicon)
- `surge-windows-x86_64.tar.gz` - Windows (x86_64, built with MSYS2)
files: |
artifacts/*.tar.gz
doc/surge2_0.pdf
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ dkms.conf

# Editor backup files
*~

# Surge binaries
surge
surge_[0-9]
canonsdf
57 changes: 22 additions & 35 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
FROM ubuntu:21.04
FROM alpine:3.21 AS builder

RUN apt-get update && \
apt-get -y install curl gcc make zlib1g-dev && \
apt-get -y clean && \
rm -rf \
/var/lib/apt/lists/* \
/usr/share/doc \
/usr/share/doc-base \
/usr/share/man \
/usr/share/locale \
/usr/share/zoneinfo
WORKDIR /root
RUN curl -o nauty27r3.tar.gz http://users.cecs.anu.edu.au/~bdm/nauty/nauty27r3.tar.gz \
&& tar xzvf nauty27r3.tar.gz \
&& cd nauty27r3 \
&& ./configure && make
ENV NAUTY_HOME=/root/nauty27r3
COPY src/surge.c $NAUTY_HOME
COPY src/Makefile /root
WORKDIR $NAUTY_HOME
RUN ln -s /root/nauty27r3 /root/nauty
RUN make -f ../Makefile clean ; make -f ../Makefile surge
RUN apk add --no-cache build-base curl zlib-dev

FROM ubuntu:21.04
WORKDIR /build

RUN apt-get update && \
apt-get -y install curl time gnupg zlib1g && \
apt-get -y clean && \
rm -rf \
/var/lib/apt/lists/* \
/usr/share/doc \
/usr/share/doc-base \
/usr/share/man \
/usr/share/locale \
/usr/share/zoneinfo
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && apt-get update -y && apt-get install google-cloud-sdk -y
# Download and build nauty
RUN curl -L -o nauty2_9_3.tar.gz https://users.cecs.anu.edu.au/~bdm/nauty/nauty2_9_3.tar.gz \
&& tar xzf nauty2_9_3.tar.gz \
&& cd nauty2_9_3 \
&& ./configure && make -j4

COPY --from=0 /root/nauty27r3/surge /usr/bin
# Copy source and build surge (static linking for minimal runtime image)
COPY src/ /build/src/
WORKDIR /build/src
RUN make surge \
NAUTY=/build/nauty2_9_3 \
NAUTYLIB=/build/nauty2_9_3 \
CCOPT="-O3 -static"

# Minimal runtime image (~9MB)
FROM alpine:3.21

COPY --from=builder /build/src/surge /usr/local/bin/surge

ENTRYPOINT ["surge"]
Loading