Skip to content

Commit bd8a5c6

Browse files
committed
Merge branch 'main' into madhava/wasm-fixes
2 parents e66040a + 2509e30 commit bd8a5c6

14 files changed

Lines changed: 341 additions & 14 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Build Docker Image
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: 'Image version tag, without v prefix. Defaults to VERSION.'
8+
required: false
9+
type: string
10+
push:
11+
branches: [main]
12+
tags:
13+
- 'v*'
14+
paths:
15+
- 'rust/**'
16+
- 'docker/**'
17+
- 'VERSION'
18+
- '.github/workflows/docker-build.yml'
19+
release:
20+
types: [published]
21+
workflow_dispatch:
22+
inputs:
23+
version:
24+
description: 'Image version tag, without v prefix. Defaults to VERSION.'
25+
required: false
26+
type: string
27+
28+
env:
29+
REGISTRY: ghcr.io
30+
IMAGE_NAME: openmined/bioscript
31+
32+
jobs:
33+
build-and-push:
34+
runs-on: ubuntu-latest
35+
permissions:
36+
contents: read
37+
packages: write
38+
attestations: write
39+
id-token: write
40+
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
with:
45+
submodules: recursive
46+
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
- name: Log in to GitHub Container Registry
51+
uses: docker/login-action@v3
52+
with:
53+
registry: ${{ env.REGISTRY }}
54+
username: ${{ github.actor }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Resolve version
58+
id: version
59+
shell: bash
60+
env:
61+
VERSION_INPUT: ${{ inputs.version || '' }}
62+
run: |
63+
if [[ -n "${VERSION_INPUT}" ]]; then
64+
VERSION="${VERSION_INPUT#v}"
65+
elif [[ "${GITHUB_REF_TYPE}" == "tag" && "${GITHUB_REF_NAME}" == v* ]]; then
66+
VERSION="${GITHUB_REF_NAME#v}"
67+
else
68+
VERSION="$(tr -d '[:space:]' < VERSION)"
69+
fi
70+
71+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
72+
echo "Invalid version: $VERSION" >&2
73+
exit 1
74+
fi
75+
76+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
77+
echo "Resolved version: ${VERSION}"
78+
79+
- name: Extract metadata for Docker
80+
id: meta
81+
uses: docker/metadata-action@v5
82+
with:
83+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
84+
tags: |
85+
type=semver,pattern={{version}},value=v${{ steps.version.outputs.version }}
86+
type=semver,pattern={{major}}.{{minor}},value=v${{ steps.version.outputs.version }}
87+
type=semver,pattern={{major}},value=v${{ steps.version.outputs.version }}
88+
type=raw,value=${{ steps.version.outputs.version }}
89+
type=raw,value=latest,enable={{is_default_branch}}
90+
type=sha,prefix={{branch}}-
91+
92+
- name: Build and push Docker image
93+
id: build
94+
uses: docker/build-push-action@v6
95+
with:
96+
context: .
97+
file: ./docker/Dockerfile
98+
platforms: linux/amd64,linux/arm64
99+
push: true
100+
tags: ${{ steps.meta.outputs.tags }}
101+
labels: ${{ steps.meta.outputs.labels }}
102+
cache-from: type=gha
103+
cache-to: type=gha,mode=max
104+
105+
- name: Generate artifact attestation
106+
uses: actions/attest-build-provenance@v2
107+
continue-on-error: true
108+
with:
109+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
110+
subject-digest: ${{ steps.build.outputs.digest }}
111+
push-to-registry: true

.github/workflows/release.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Release Docker Image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: 'Version bump type'
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
- custom
15+
default: 'minor'
16+
custom_version:
17+
description: 'Custom version, without v prefix. Required when bump=custom.'
18+
required: false
19+
type: string
20+
21+
permissions:
22+
contents: write
23+
packages: write
24+
attestations: write
25+
id-token: write
26+
27+
jobs:
28+
version:
29+
runs-on: ubuntu-latest
30+
outputs:
31+
version: ${{ steps.new.outputs.version }}
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v4
36+
with:
37+
fetch-depth: 0
38+
submodules: recursive
39+
40+
- name: Resolve new version
41+
id: new
42+
shell: bash
43+
run: |
44+
CURRENT="$(tr -d '[:space:]' < VERSION)"
45+
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
46+
47+
case "${{ inputs.bump }}" in
48+
major)
49+
NEW_VERSION="$((MAJOR + 1)).0.0"
50+
;;
51+
minor)
52+
NEW_VERSION="${MAJOR}.$((MINOR + 1)).0"
53+
;;
54+
patch)
55+
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
56+
;;
57+
custom)
58+
NEW_VERSION="${{ inputs.custom_version }}"
59+
;;
60+
esac
61+
62+
if [[ ! "$NEW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
63+
echo "Invalid version: $NEW_VERSION" >&2
64+
exit 1
65+
fi
66+
67+
echo "version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
68+
echo "New version: ${NEW_VERSION}"
69+
70+
- name: Bump version
71+
run: ./bump_version.sh "${{ steps.new.outputs.version }}"
72+
73+
- name: Run tests
74+
run: ./test.sh
75+
76+
- name: Commit version bump and tag
77+
shell: bash
78+
run: |
79+
VERSION="${{ steps.new.outputs.version }}"
80+
git config user.name "github-actions[bot]"
81+
git config user.email "github-actions[bot]@users.noreply.github.com"
82+
git add VERSION rust/bioscript-*/Cargo.toml rust/Cargo.lock
83+
if git diff --cached --quiet; then
84+
echo "Version files already at ${VERSION}"
85+
else
86+
git commit -m "Bump version to ${VERSION}"
87+
fi
88+
git tag "v${VERSION}"
89+
git push origin main --tags
90+
91+
docker:
92+
needs: version
93+
uses: ./.github/workflows/docker-build.yml
94+
secrets: inherit
95+
with:
96+
version: ${{ needs.version.outputs.version }}

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.2.0

bump_version.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [[ $# -ne 1 ]]; then
5+
echo "Usage: $0 <version>" >&2
6+
echo "Example: $0 0.2.0" >&2
7+
exit 1
8+
fi
9+
10+
VERSION="$1"
11+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
12+
echo "Invalid semver version: $VERSION" >&2
13+
exit 1
14+
fi
15+
16+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17+
cd "$ROOT_DIR"
18+
19+
printf "%s\n" "$VERSION" > VERSION
20+
21+
for manifest in \
22+
rust/bioscript-cli/Cargo.toml \
23+
rust/bioscript-core/Cargo.toml \
24+
rust/bioscript-ffi/Cargo.toml \
25+
rust/bioscript-formats/Cargo.toml \
26+
rust/bioscript-runtime/Cargo.toml \
27+
rust/bioscript-schema/Cargo.toml \
28+
rust/bioscript-wasm/Cargo.toml
29+
do
30+
perl -0pi -e 's/^version = ".*?"$/version = "'"$VERSION"'"/m' "$manifest"
31+
done
32+
33+
cargo metadata --manifest-path rust/Cargo.toml --format-version 1 >/dev/null
34+
35+
echo "Bumped BioScript to $VERSION"

docker/Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM rust:1-bookworm AS builder
2+
3+
RUN apt-get update \
4+
&& apt-get install -y --no-install-recommends \
5+
bash \
6+
ca-certificates \
7+
clang \
8+
cmake \
9+
git \
10+
libbz2-dev \
11+
libclang-dev \
12+
libcurl4-openssl-dev \
13+
liblzma-dev \
14+
libssl-dev \
15+
pkg-config \
16+
zlib1g-dev \
17+
&& rm -rf /var/lib/apt/lists/*
18+
19+
WORKDIR /src
20+
COPY . .
21+
22+
RUN cargo build --release \
23+
--manifest-path rust/Cargo.toml \
24+
-p bioscript-cli
25+
26+
RUN install -m 0755 rust/target/release/bioscript /usr/local/bin/bioscript
27+
28+
FROM debian:bookworm-slim AS runtime
29+
30+
RUN apt-get update \
31+
&& apt-get install -y --no-install-recommends \
32+
bash \
33+
ca-certificates \
34+
libbz2-1.0 \
35+
libcurl4 \
36+
liblzma5 \
37+
libssl3 \
38+
zlib1g \
39+
&& rm -rf /var/lib/apt/lists/*
40+
41+
COPY --from=builder /usr/local/bin/bioscript /usr/local/bin/bioscript
42+
RUN ln -s /usr/local/bin/bioscript /usr/local/bin/bs
43+
44+
LABEL org.opencontainers.image.source="https://github.com/OpenMined/bioscript"
45+
LABEL org.opencontainers.image.description="BioScript runtime"
46+
LABEL org.opencontainers.image.licenses="Apache-2.0"
47+
48+
WORKDIR /workspace
49+
50+
CMD ["bioscript"]

docker/build.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
cd "$ROOT_DIR"
6+
7+
VERSION="${1:-$(tr -d '[:space:]' < VERSION)}"
8+
IMAGE="${BIOSCRIPT_IMAGE:-ghcr.io/openmined/bioscript}"
9+
PLATFORMS="${PLATFORMS:-linux/amd64,linux/arm64}"
10+
PUSH="${PUSH:-0}"
11+
LOAD="${LOAD:-0}"
12+
13+
BUILD_ARGS=(
14+
docker buildx build
15+
--platform "$PLATFORMS"
16+
-f docker/Dockerfile
17+
-t "${IMAGE}:${VERSION}"
18+
-t "${IMAGE}:latest"
19+
.
20+
)
21+
22+
if [[ "$PUSH" == "1" ]]; then
23+
BUILD_ARGS+=(--push)
24+
elif [[ "$LOAD" == "1" ]]; then
25+
if [[ "$PLATFORMS" == *,* ]]; then
26+
echo "LOAD=1 requires a single platform, got: $PLATFORMS" >&2
27+
exit 1
28+
fi
29+
BUILD_ARGS+=(--load)
30+
else
31+
BUILD_ARGS+=(--output "type=oci,dest=docker/bioscript-${VERSION}.oci.tar")
32+
fi
33+
34+
"${BUILD_ARGS[@]}"

rust/Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/bioscript-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bioscript-cli"
3-
version = "0.1.0"
3+
version = "0.2.0"
44
edition = "2024"
55

66
[[bin]]

0 commit comments

Comments
 (0)