Skip to content

Commit cd7b7cc

Browse files
committed
First commit!
0 parents  commit cd7b7cc

45 files changed

Lines changed: 5163 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/alpine_build.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Alpine Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ring-version:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
build:
12+
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'ubuntu-24.04-arm' }}
13+
strategy:
14+
matrix:
15+
include:
16+
- arch: amd64
17+
- arch: arm64
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
submodules: recursive
24+
25+
- name: Clone Ring Language
26+
uses: actions/checkout@v4
27+
with:
28+
repository: ringpackages/ringsrc
29+
path: ring
30+
ref: ${{ inputs.ring-version }}
31+
32+
- name: Cache Rust dependencies
33+
uses: actions/cache@v4
34+
with:
35+
path: |
36+
cargo-cache
37+
src/rust_src/target
38+
key: alpine-${{ matrix.arch }}-cargo-${{ hashFiles('src/rust_src/Cargo.lock') }}
39+
restore-keys: |
40+
alpine-${{ matrix.arch }}-cargo-
41+
42+
- name: Build in Alpine container
43+
run: |
44+
mkdir -p cargo-cache
45+
docker run --rm \
46+
-v ${{ github.workspace }}:/workspace \
47+
-v ${{ github.workspace }}/cargo-cache:/root/.cargo \
48+
-w /workspace \
49+
alpine:3.23 sh -c '
50+
apk add --no-cache cmake make gcc g++ musl-dev rust cargo curl python3 python3-dev clang clang-dev ninja git linux-headers
51+
cd ring/language
52+
cmake . -DCMAKE_BUILD_TYPE=Release -GNinja
53+
ninja install
54+
cd ../..
55+
export RING=/workspace/ring
56+
cd src/rust_src
57+
cargo build --release
58+
chmod -R a+r /root/.cargo /workspace/src/rust_src/target
59+
'
60+
61+
- name: Copy Rust artifacts to lib directory
62+
run: |
63+
mkdir -p lib/linux/musl/${{ matrix.arch }}
64+
cp src/rust_src/target/release/libring_python.so lib/linux/musl/${{ matrix.arch }}/
65+
66+
- name: Upload artifacts
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: ring-python-linux-musl-${{ matrix.arch }}
70+
path: lib/linux/musl/${{ matrix.arch }}/libring_python.so
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: FreeBSD Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ring-version:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
build:
12+
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'ubuntu-24.04-arm' }}
13+
strategy:
14+
matrix:
15+
include:
16+
- release: "15.0"
17+
arch: amd64
18+
vm_arch: amd64
19+
# - release: "15.0"
20+
# arch: arm64
21+
# vm_arch: aarch64
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
submodules: recursive
27+
28+
- name: Clean lib directory
29+
run: rm -rf lib
30+
31+
- name: Build in FreeBSD VM
32+
id: freebsd_build
33+
uses: vmactions/freebsd-vm@v1
34+
with:
35+
release: ${{ matrix.release }}
36+
arch: ${{ matrix.vm_arch }}
37+
usesh: true
38+
sync: rsync
39+
mem: 4096
40+
prepare: |
41+
pkg install -y cmake git ninja pkgconf curl python3
42+
run: |
43+
# Clone Ring Language
44+
git clone --branch ${{ inputs.ring-version }} --depth 1 https://github.com/ringpackages/ringsrc.git ring
45+
cd ring
46+
47+
# Set RING environment variable
48+
export RING=$(pwd)
49+
50+
# Build and Install Ring Language
51+
cd language
52+
cmake . -DCMAKE_BUILD_TYPE=Release -GNinja
53+
ninja install
54+
cd ../..
55+
56+
# Install Rust toolchain
57+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
58+
. $HOME/.cargo/env
59+
60+
# Build ring_python Rust library
61+
cd src/rust_src
62+
cargo build --release
63+
cd ../..
64+
65+
# Copy artifacts
66+
mkdir -p lib/freebsd/${{ matrix.arch }}
67+
cp src/rust_src/target/release/libring_python.so lib/freebsd/${{ matrix.arch }}/
68+
69+
- name: Upload artifacts
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: ring-python-freebsd-${{ matrix.arch }}
73+
path: lib/freebsd/${{ matrix.arch }}/libring_python.so

.github/workflows/macos_build.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: macOS Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ring-version:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
build:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
include:
16+
- os: macos-15-intel
17+
arch: amd64
18+
rust_target: x86_64-apple-darwin
19+
- os: macos-latest
20+
arch: arm64
21+
rust_target: aarch64-apple-darwin
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
28+
29+
- name: Clone Ring Language
30+
uses: actions/checkout@v4
31+
with:
32+
repository: ringpackages/ringsrc
33+
path: ring
34+
ref: ${{ inputs.ring-version }}
35+
36+
- name: Build and Install Ring Language
37+
run: |
38+
cd ring/language
39+
cmake . -DCMAKE_BUILD_TYPE=Release
40+
make install
41+
42+
- name: Set RING environment variable
43+
run: echo "RING=$(pwd)/ring" >> $GITHUB_ENV
44+
45+
- name: Install Rust toolchain
46+
uses: dtolnay/rust-toolchain@stable
47+
with:
48+
targets: ${{ matrix.rust_target }}
49+
50+
- name: Cache Rust dependencies
51+
uses: Swatinem/rust-cache@v2
52+
with:
53+
workspaces: "src/rust_src -> target"
54+
55+
- name: Build ring_python Rust library
56+
run: cargo build --release --target ${{ matrix.rust_target }}
57+
working-directory: src/rust_src
58+
59+
- name: Copy Rust artifacts to lib directory
60+
run: |
61+
mkdir -p lib/macos/${{ matrix.arch }}
62+
cp src/rust_src/target/${{ matrix.rust_target }}/release/libring_python.dylib lib/macos/${{ matrix.arch }}/
63+
64+
- name: Upload artifacts
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: ring-python-macos-${{ matrix.arch }}
68+
path: lib/macos/${{ matrix.arch }}/libring_python.dylib

.github/workflows/main.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Build and Update
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths:
7+
- '**.rs'
8+
- '**/Cargo.toml'
9+
- '**/Cargo.lock'
10+
- '.github/workflows/**'
11+
pull_request:
12+
paths:
13+
- '**.rs'
14+
- '**/Cargo.toml'
15+
- '**/Cargo.lock'
16+
- '.github/workflows/**'
17+
jobs:
18+
alpine:
19+
uses: ./.github/workflows/alpine_build.yml
20+
with:
21+
ring-version: master
22+
23+
freebsd:
24+
uses: ./.github/workflows/freebsd_build.yml
25+
with:
26+
ring-version: master
27+
28+
macos:
29+
uses: ./.github/workflows/macos_build.yml
30+
with:
31+
ring-version: master
32+
33+
ubuntu:
34+
uses: ./.github/workflows/ubuntu_build.yml
35+
with:
36+
ring-version: master
37+
38+
windows:
39+
uses: ./.github/workflows/windows_build.yml
40+
with:
41+
ring-version: master
42+
43+
update-libs:
44+
runs-on: ubuntu-latest
45+
needs: [ alpine, freebsd, macos, ubuntu, windows ]
46+
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
47+
48+
permissions:
49+
contents: write
50+
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
55+
- name: Download all artifacts from this workflow run
56+
uses: actions/download-artifact@v4
57+
with:
58+
path: artifacts
59+
60+
- name: Copy artifacts to lib directory
61+
run: |
62+
mkdir -p lib
63+
echo "=== Artifacts structure ==="
64+
find artifacts -type f
65+
echo "=== Copying artifacts ==="
66+
# Each artifact is named ring-python-{os}-{arch} and contains a single binary
67+
for artifact_dir in artifacts/ring-python-*/; do
68+
dirname=$(basename "$artifact_dir")
69+
# Extract os and arch from ring-python-{os}-{arch}
70+
os_arch="${dirname#ring-python-}"
71+
os="${os_arch%-*}"
72+
os="${os//-//}"
73+
arch="${os_arch##*-}"
74+
mkdir -p "lib/${os}/${arch}"
75+
echo "Copying ${os}/${arch} from: $artifact_dir"
76+
cp -a "${artifact_dir}"* "lib/${os}/${arch}/"
77+
done
78+
echo "=== Final lib structure ==="
79+
find lib -type f
80+
81+
- name: Commit and push changes
82+
run: |
83+
git config --global user.name 'github-actions[bot]'
84+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
85+
git add lib
86+
if ! git diff --staged --quiet; then
87+
git commit -m "* Update libs"
88+
git push
89+
else
90+
echo "No library changes to commit."
91+
fi
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ubuntu_build.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Ubuntu Build
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ring-version:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
build:
12+
runs-on: ${{ matrix.arch == 'amd64' && 'ubuntu-latest' || 'ubuntu-24.04-arm' }}
13+
strategy:
14+
matrix:
15+
include:
16+
- arch: amd64
17+
- arch: arm64
18+
19+
steps:
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y cmake build-essential python3-dev
24+
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
with:
28+
submodules: recursive
29+
30+
- name: Clone Ring Language
31+
uses: actions/checkout@v4
32+
with:
33+
repository: ringpackages/ringsrc
34+
path: ring
35+
ref: ${{ inputs.ring-version }}
36+
37+
- name: Build and Install Ring Language
38+
run: |
39+
cd ring/language
40+
cmake . -DCMAKE_BUILD_TYPE=Release
41+
make install
42+
43+
- name: Set RING environment variable
44+
run: echo "RING=$(pwd)/ring" >> $GITHUB_ENV
45+
46+
- name: Install Rust toolchain
47+
uses: dtolnay/rust-toolchain@stable
48+
49+
- name: Cache Rust dependencies
50+
uses: Swatinem/rust-cache@v2
51+
with:
52+
workspaces: "src/rust_src -> target"
53+
54+
- name: Build ring_python Rust library
55+
run: cargo build --release
56+
working-directory: src/rust_src
57+
58+
- name: Copy Rust artifacts to lib directory
59+
run: |
60+
mkdir -p lib/linux/${{ matrix.arch }}
61+
cp src/rust_src/target/release/libring_python.so lib/linux/${{ matrix.arch }}/
62+
63+
- name: Upload artifacts
64+
uses: actions/upload-artifact@v4
65+
with:
66+
name: ring-python-linux-${{ matrix.arch }}
67+
path: lib/linux/${{ matrix.arch }}/libring_python.so

0 commit comments

Comments
 (0)