Skip to content
Open
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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,34 @@ jobs:
# Must run from the repo root: with python/ as cwd, the source anydoc/
# package dir shadows the installed compiled module.
- run: python -m unittest discover -s python/tests

go:
name: Go bindings
runs-on: blacksmith-8vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: actions/setup-go@v6
with:
go-version: '1.22'
- name: Build the static library
run: cargo build -p anydoc-go --release
- name: Place the archive where cgo expects it
run: |
mkdir -p go/lib/linux_amd64_gnu
cp target/release/libanydoc_go.a go/lib/linux_amd64_gnu/
- name: Committed header is up to date
# `cargo build` regenerates include/anydoc.h via cbindgen; any diff
# means the committed header is stale and must be rebuilt and committed.
run: |
if ! git diff --exit-code -- go/include/anydoc.h; then
echo "::error::go/include/anydoc.h is out of date. Run 'cargo build -p anydoc-go --release' and commit the result."
exit 1
fi
- name: go vet
run: go vet ./...
working-directory: go
- name: go test
run: go test ./...
working-directory: go
86 changes: 86 additions & 0 deletions .github/workflows/prepare-go-archives.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Prepare Go Archives

on:
workflow_dispatch:

permissions:
contents: read

jobs:
build:
name: Build Go archive (${{ matrix.target }})
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
host: blacksmith-6vcpu-macos-latest
lib_dir: darwin_amd64
lib_name: libanydoc_go.a
- target: aarch64-apple-darwin
host: blacksmith-6vcpu-macos-latest
lib_dir: darwin_arm64
lib_name: libanydoc_go.a
- target: x86_64-pc-windows-msvc
host: blacksmith-8vcpu-windows-2025
lib_dir: windows_amd64
lib_name: anydoc_go.lib
- target: x86_64-unknown-linux-gnu
host: blacksmith-8vcpu-ubuntu-2404
lib_dir: linux_amd64_gnu
lib_name: libanydoc_go.a
- target: aarch64-unknown-linux-gnu
host: blacksmith-4vcpu-ubuntu-2404-arm
lib_dir: linux_arm64_gnu
lib_name: libanydoc_go.a
- target: x86_64-unknown-linux-musl
host: blacksmith-8vcpu-ubuntu-2404
lib_dir: linux_amd64_musl
lib_name: libanydoc_go.a
zig: true
- target: aarch64-unknown-linux-musl
host: blacksmith-4vcpu-ubuntu-2404-arm
lib_dir: linux_arm64_musl
lib_name: libanydoc_go.a
zig: true
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: go-${{ matrix.target }}
- uses: mlugg/setup-zig@v2
if: matrix.zig == true
with:
version: 0.14.1
- run: cargo build -p anydoc-go --release --target ${{ matrix.target }}
- name: Stage archive
shell: bash
run: |
mkdir -p staging/go/lib/${{ matrix.lib_dir }}
cp target/${{ matrix.target }}/release/${{ matrix.lib_name }} \
staging/go/lib/${{ matrix.lib_dir }}/${{ matrix.lib_name }}
- uses: actions/upload-artifact@v7
with:
name: go-lib-${{ matrix.target }}
path: staging
if-no-files-found: error

bundle:
name: Bundle Go archives
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
pattern: go-lib-*
path: staging
merge-multiple: true
- uses: actions/upload-artifact@v7
with:
name: go-libraries
path: staging
if-no-files-found: error
82 changes: 82 additions & 0 deletions .github/workflows/release-go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Release Go Module

on:
push:
tags: ['go/v*']
workflow_dispatch:

permissions:
contents: read

jobs:
gate:
name: Version gate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Check versions
run: |
if [ "$GITHUB_REF_TYPE" = "tag" ]; then
sh scripts/check-versions.sh "v${GITHUB_REF_NAME#go/v}"
else
sh scripts/check-versions.sh
fi

verify:
name: Verify Go archive (${{ matrix.target }})
needs: gate
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
host: blacksmith-6vcpu-macos-latest
lib_dir: darwin_amd64
lib_name: libanydoc_go.a
- target: aarch64-apple-darwin
host: blacksmith-6vcpu-macos-latest
lib_dir: darwin_arm64
lib_name: libanydoc_go.a
- target: x86_64-pc-windows-msvc
host: blacksmith-8vcpu-windows-2025
lib_dir: windows_amd64
lib_name: anydoc_go.lib
- target: x86_64-unknown-linux-gnu
host: blacksmith-8vcpu-ubuntu-2404
lib_dir: linux_amd64_gnu
lib_name: libanydoc_go.a
- target: aarch64-unknown-linux-gnu
host: blacksmith-4vcpu-ubuntu-2404-arm
lib_dir: linux_arm64_gnu
lib_name: libanydoc_go.a
- target: x86_64-unknown-linux-musl
host: blacksmith-8vcpu-ubuntu-2404
lib_dir: linux_amd64_musl
lib_name: libanydoc_go.a
zig: true
- target: aarch64-unknown-linux-musl
host: blacksmith-4vcpu-ubuntu-2404-arm
lib_dir: linux_arm64_musl
lib_name: libanydoc_go.a
zig: true
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: go-${{ matrix.target }}
- uses: mlugg/setup-zig@v2
if: matrix.zig == true
with:
version: 0.14.1
- run: cargo build -p anydoc-go --release --target ${{ matrix.target }}
- name: Compare bundled archive
shell: bash
run: |
built=target/${{ matrix.target }}/release/${{ matrix.lib_name }}
bundled=go/lib/${{ matrix.lib_dir }}/${{ matrix.lib_name }}
test -f "$bundled"
cmp "$built" "$bundled"
121 changes: 118 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
version: ${{ steps.check.outputs.version }}
steps:
- uses: actions/checkout@v7
- name: All five version locations agree (and match the tag)
- name: All seven version locations agree (and match the tag)
id: check
run: |
if [ "$GITHUB_REF_TYPE" = "tag" ]; then
Expand Down Expand Up @@ -442,11 +442,126 @@ jobs:
# Tolerate re-running a release where PyPI already got some files.
skip-existing: true

build-go:
name: Build Go static lib (${{ matrix.target }})
needs: gate
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
host: blacksmith-6vcpu-macos-latest
lib_dir: darwin_amd64
lib_name: libanydoc_go.a
- target: aarch64-apple-darwin
host: blacksmith-6vcpu-macos-latest
lib_dir: darwin_arm64
lib_name: libanydoc_go.a
- target: x86_64-pc-windows-msvc
host: blacksmith-8vcpu-windows-2025
lib_dir: windows_amd64
lib_name: anydoc_go.lib
# napi-cross is Node-specific; the Rust staticlib links glibc on the
# build host. manylinux2014 compatibility comes from building on
# ubuntu-2404 with the toolchain's default glibc target.
- target: x86_64-unknown-linux-gnu
host: blacksmith-8vcpu-ubuntu-2404
lib_dir: linux_amd64_gnu
lib_name: libanydoc_go.a
- target: aarch64-unknown-linux-gnu
host: blacksmith-4vcpu-ubuntu-2404-arm
lib_dir: linux_arm64_gnu
lib_name: libanydoc_go.a
# musl targets cross-compile with the Zig toolchain, mirroring the
# Node build. The asset name carries the full triple so gnu and musl
# never collide on the release page.
- target: x86_64-unknown-linux-musl
host: blacksmith-8vcpu-ubuntu-2404
zig: true
lib_dir: linux_amd64_musl
lib_name: libanydoc_go.a
- target: aarch64-unknown-linux-musl
host: blacksmith-4vcpu-ubuntu-2404-arm
zig: true
lib_dir: linux_arm64_musl
lib_name: libanydoc_go.a
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: go-${{ matrix.target }}
- uses: mlugg/setup-zig@v2
if: matrix.zig == true
with:
version: 0.14.1
- name: Build staticlib
run: cargo build -p anydoc-go --release --target ${{ matrix.target }}
- name: Verify packaged archive
shell: bash
run: |
built=target/${{ matrix.target }}/release/${{ matrix.lib_name }}
packaged=go/lib/${{ matrix.lib_dir }}/${{ matrix.lib_name }}
test -f "$packaged"
cmp "$built" "$packaged"

test-go:
name: Test Go bindings (${{ matrix.target }})
needs: build-go
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
host: blacksmith-6vcpu-macos-latest
# Apple Silicon runs x64 Go through Rosetta, which loads the x64 lib.
- target: x86_64-apple-darwin
host: blacksmith-6vcpu-macos-latest
go_arch: amd64
- target: x86_64-pc-windows-msvc
host: blacksmith-4vcpu-windows-2025
# The Linux flavors test through `docker run` rather than container:
# jobs — JavaScript actions cannot run inside Alpine containers on
# arm64 runners.
- target: x86_64-unknown-linux-gnu
host: blacksmith-4vcpu-ubuntu-2404
image: golang:1.22-slim
- target: aarch64-unknown-linux-gnu
host: blacksmith-4vcpu-ubuntu-2404-arm
image: golang:1.22-slim
- target: x86_64-unknown-linux-musl
host: blacksmith-4vcpu-ubuntu-2404
image: golang:1.22-alpine
- target: aarch64-unknown-linux-musl
host: blacksmith-4vcpu-ubuntu-2404-arm
image: golang:1.22-alpine
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v6
if: ${{ !matrix.image }}
with:
go-version: '1.22'
architecture: ${{ matrix.go_arch || '' }}
- name: go test
if: ${{ !matrix.image }}
run: go test ./...
working-directory: go
- name: go test in container
if: ${{ matrix.image }}
run: >
docker run --rm -v ${{ github.workspace }}:/build -w /build/go
${{ matrix.image }} sh -c
'go test ${{ contains(matrix.target, 'musl') && '-tags musl' || '' }} ./...'

# The release page appears last: only once every registry publish has
# succeeded, carrying the Node addons, the wheels, and the sdist.
# succeeded, carrying the Node addons, wheels, and sdist.
github-release:
name: GitHub release
needs: [publish-npm, publish-npm-wasm, publish-crates, publish-pypi]
needs: [publish-npm, publish-npm-wasm, publish-crates, publish-pypi, test-go]
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ __pycache__/
.venv/
# maturin build output from the CI python job
/python/wheels/
# Go archives are generated by the maintainer-only release-preparation step.
# The archive payload lands in a follow-up release-prep PR.
/go/lib/
# wasm-pack build output: pkg/ is the npm package, www/pkg/ the demo site copy
/wasm/pkg/
/wasm/www/pkg/
Loading