Skip to content

Create a superposition release #189

Create a superposition release

Create a superposition release #189

Workflow file for this run

name: Create a superposition release
on: workflow_dispatch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tag-release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
if: github.ref == 'refs/heads/main'
outputs:
version: ${{ steps.git_tag.outputs.version }}
updated_ref: ${{ steps.push_main.outputs.updated_ref }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.SUPERPOSITION_TOKEN }}
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.90.0
targets: wasm32-unknown-unknown
components: rustfmt, clippy
- name: install cargo-edit to perform set-version
uses: baptiste0928/cargo-install@v2.2.0
with:
crate: cargo-edit
version: "0.13.6"
- name: install cocogitto
uses: baptiste0928/cargo-install@v2.2.0
with:
crate: cocogitto
version: "6.2.0"
- name: Semver release
shell: bash
run: |
git config user.email "super_bot@juspay.in"
git config user.name "Superposition Bot"
cog bump --auto --skip-ci-override "[skip ci]"
- name: Set latest tag
id: git_tag
shell: bash
run: |
version=`git tag -l --sort=-creatordate | grep "^v" | head -n 1 | sed 's/^v//'`
echo "version=$version" >> $GITHUB_OUTPUT
- name: Set the tag version to all crates
run: |
cargo set-version --workspace ${{ steps.git_tag.outputs.version }}
cargo upgrade --package superposition_types@${{ steps.git_tag.outputs.version }}
cargo upgrade --package superposition_derives@${{ steps.git_tag.outputs.version }}
cargo upgrade --package superposition_macros@${{ steps.git_tag.outputs.version }}
cargo upgrade --package superposition_core@${{ steps.git_tag.outputs.version }}
cargo upgrade --package superposition_provider@${{ steps.git_tag.outputs.version }}
cargo upgrade --package superposition_sdk@${{ steps.git_tag.outputs.version }}
cargo upgrade --package service_utils@${{ steps.git_tag.outputs.version }}
sed -i "s/superposition: \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/superposition: \"${{ steps.git_tag.outputs.version }}\"/" docs/src/constants/versions.js
git add .
git commit --amend --no-edit
- name: install yq
run: |
mkdir -p ${{ github.workspace }}/bin
wget -qO ${{ github.workspace }}/bin/yq https://github.com/mikefarah/yq/releases/download/v4.44.2/yq_linux_amd64
chmod +x ${{ github.workspace }}/bin/yq
echo "${{ github.workspace }}/bin" >> $GITHUB_PATH
- name: Update Helm chart appVersion
run: |
yq eval ".version = \"${{ steps.git_tag.outputs.version }}\"" -i helm/Chart.yaml
yq eval ".appVersion = \"${{ steps.git_tag.outputs.version }}\"" -i helm/Chart.yaml
git add helm/Chart.yaml
git commit --amend --no-edit
- name: Push code to main
id: push_main
shell: bash
run: |
git pull --rebase origin main
git push origin main
git push origin --tags
echo "updated_ref=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
docker-build:
needs: tag-release
permissions:
contents: read
packages: write
if: github.ref == 'refs/heads/main'
strategy:
max-parallel: 5
matrix:
include:
- platform: linux/amd64
tag: linux-amd64
os: ubuntu-latest
- platform: linux/arm64
tag: linux-arm64
os: ubuntu-24.04-arm
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.SUPERPOSITION_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push production image
uses: docker/build-push-action@v6
with:
push: true
context: .
tags: ghcr.io/${{ github.repository }}:${{ needs.tag-release.outputs.version }}-${{ matrix.tag }}
create-manifest:
needs: [tag-release, docker-build]
permissions:
contents: read
packages: write
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.SUPERPOSITION_TOKEN }}
ref: ${{ needs.tag-release.outputs.updated_ref }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest for multi-arch image
run: |
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:${{ needs.tag-release.outputs.version }} \
ghcr.io/${{ github.repository }}:${{ needs.tag-release.outputs.version }}-linux-amd64 \
ghcr.io/${{ github.repository }}:${{ needs.tag-release.outputs.version }}-linux-arm64
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:latest \
ghcr.io/${{ github.repository }}:${{ needs.tag-release.outputs.version }}-linux-amd64 \
ghcr.io/${{ github.repository }}:${{ needs.tag-release.outputs.version }}-linux-arm64
- name: Package and push Helm chart to OCI registry
run: |
helm package helm
helm push "superposition-${{ needs.tag-release.outputs.version }}.tgz" "oci://ghcr.io/${{ github.repository_owner }}/helm-charts"
docker-demo-build:
needs: [tag-release, create-manifest]
permissions:
contents: read
packages: write
if: github.ref == 'refs/heads/main'
strategy:
max-parallel: 5
matrix:
include:
- platform: linux/amd64
tag: linux-amd64
os: ubuntu-latest
- platform: linux/arm64
tag: linux-arm64
os: ubuntu-24.04-arm
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.SUPERPOSITION_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push production image
uses: docker/build-push-action@v6
with:
push: true
context: .
file: example.Dockerfile
tags: ghcr.io/${{ github.repository }}-demo:${{ needs.tag-release.outputs.version }}-${{ matrix.tag }}
create-demo-manifest:
needs: [tag-release, docker-demo-build]
permissions:
contents: read
packages: write
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.SUPERPOSITION_TOKEN }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest for multi-arch image
run: |
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}-demo:${{ needs.tag-release.outputs.version }} \
ghcr.io/${{ github.repository }}-demo:${{ needs.tag-release.outputs.version }}-linux-amd64 \
ghcr.io/${{ github.repository }}-demo:${{ needs.tag-release.outputs.version }}-linux-arm64
docker buildx imagetools create --tag ghcr.io/${{ github.repository }}-demo:latest \
ghcr.io/${{ github.repository }}-demo:${{ needs.tag-release.outputs.version }}-linux-amd64 \
ghcr.io/${{ github.repository }}-demo:${{ needs.tag-release.outputs.version }}-linux-arm64
generate-rust-binary:
needs: tag-release
if: github.ref == 'refs/heads/main'
strategy:
max-parallel: 5
matrix:
platform:
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
superposition_core_bin_name: libsuperposition_core.so
superposition_core_zip_name: superposition_core-x86_64-unknown-linux-gnu.zip
- os: macos-15-intel
target: x86_64-apple-darwin
superposition_core_bin_name: libsuperposition_core.dylib
superposition_core_zip_name: superposition_core-x86_64-apple-darwin.zip
- os: macos-latest
target: aarch64-apple-darwin
superposition_core_bin_name: libsuperposition_core.dylib
superposition_core_zip_name: superposition_core-aarch64-apple-darwin.zip
- os: windows-latest
target: x86_64-pc-windows-msvc
superposition_core_bin_name: superposition_core.dll
superposition_core_zip_name: superposition_core-x86_64-pc-windows-msvc.zip
runs-on: ${{ matrix.platform.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.90.0
targets: ${{ matrix.platform.target }}
components: rustfmt, clippy
- name: Build and package for ${{ matrix.platform.os }}
if: matrix.platform.os != 'windows-latest'
run: |
cargo build --package superposition_core --release --target ${{ matrix.platform.target }}
mv target/${{ matrix.platform.target }}/release/${{ matrix.platform.superposition_core_bin_name }} ${{ matrix.platform.superposition_core_bin_name }}
mv target/include/superposition_core.h core.h
zip -r ${{ matrix.platform.superposition_core_zip_name }} ${{ matrix.platform.superposition_core_bin_name }} core.h
- name: Build and package for ${{ matrix.platform.os }} on windows
if: matrix.platform.os == 'windows-latest'
run: |
cargo build --package superposition_core --release --target ${{ matrix.platform.target }}
Move-Item -Path "target\${{ matrix.platform.target }}\release\${{ matrix.platform.superposition_core_bin_name }}" -Destination "lib${{ matrix.platform.superposition_core_bin_name }}"
Move-Item -Path "target\include\superposition_core.h" -Destination "core.h"
Compress-Archive -Path "lib${{ matrix.platform.superposition_core_bin_name }}","core.h" -DestinationPath ${{ matrix.platform.superposition_core_zip_name }}
# Why multiple upload artifact jobs? Read: https://github.com/actions/upload-artifact/issues/331
- name: Upload superposition_core artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform.superposition_core_zip_name }}
path: ${{ matrix.platform.superposition_core_zip_name }}
generate-java-packages:
needs: [tag-release, generate-rust-binary]
permissions:
contents: read
id-token: write
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
JRELEASER_GPG_SECRET_KEY: ${{ secrets.SONATYPE_MAVEN_SIGNING_KEY }}
JRELEASER_GPG_PUBLIC_KEY: ${{ vars.SONATYPE_MAVEN_SIGNING_PUB_KEY }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.SONATYPE_MAVEN_SIGNING_KEY_PASSWORD }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.SONATYPE_MAVEN_USERNAME }}
JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.SONATYPE_MAVEN_PASSWORD }}
VERSION: ${{ needs.tag-release.outputs.version }}
defaults:
run:
working-directory: clients/java
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "temurin"
- name: Download all rust binary artifacts
uses: actions/download-artifact@v4
with:
path: clients/java/rust-binaries
pattern: superposition_core-*
merge-multiple: true
- name: List downloaded artifacts
run: |
echo "Downloaded artifacts:"
ls -lar rust-binaries
- name: Extract and organize native libraries
run: |
mkdir -p bindings/src/main/resources
mkdir temp_extract
# Extract all native libraries
for zip_file in rust-binaries/*.zip; do
echo "Extracting $zip_file"
unzip -o "$zip_file" -d temp_extract/
# Find and copy the native library
find temp_extract -name "libsuperposition_core.*" -o -name "superposition_core.*" | while read lib; do
filename=$(basename "$lib")
extension="${filename##*.}"
# Determine platform from the zip file name or path
zip_basename=$(basename "$zip_file" .zip)
target_triple="${zip_basename#superposition_core-}"
# Map target triple to JNA platform name
case "$target_triple" in
"x86_64-apple-darwin")
platform="darwin-x86-64"
;;
"aarch64-apple-darwin")
platform="darwin-aarch64"
;;
"x86_64-unknown-linux-gnu")
platform="linux-x86-64"
;;
"x86_64-pc-windows-msvc")
platform="win32-x86-64"
;;
*)
echo "Unknown target triple: $target_triple"
continue
;;
esac
# Create the platform-specific directory
target_dir="bindings/src/main/resources/$platform"
mkdir -p "$target_dir"
# Copy the file
cp "$lib" "$target_dir/libsuperposition_core.$extension"
echo "Copied $filename (.$extension) to $target_dir/"
done
# Clean up temp directory
rm -rf temp_extract
done
# List what we have
echo "Native libraries in bindings package:"
ls -lar bindings/src/main/resources/
- name: Make gradlew executable
run: chmod +x gradlew
- name: Publish
run: ./gradlew clean publish
- name: Deploy to Sonatype
run: ./gradlew jreleaserDeploy --info --stacktrace
generate-python-packages:
needs: [tag-release, generate-rust-binary]
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
env:
VERSION: ${{ needs.tag-release.outputs.version }}
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
- name: install twine
run: |
python -m pip install --upgrade pip
pip install twine
- name: Download all rust binary artifacts
uses: actions/download-artifact@v4
with:
path: rust-binaries
pattern: superposition_core-*
merge-multiple: true
- name: List downloaded artifacts
run: |
echo "Downloaded artifacts:"
find rust-binaries -type f -name "*.zip" | sort
- name: Extract and organize native libraries
run: |
# Extract all native libraries
for zip_file in rust-binaries/*.zip; do
echo "Extracting $zip_file"
zip_basename=$(basename "$zip_file" .zip)
target_triple="${zip_basename#superposition_core-}"
mkdir -p temp_extract/$target_triple
unzip -o "$zip_file" -d temp_extract/$target_triple/
# Find and copy the native library
find temp_extract/$target_triple -name "libsuperposition_core.*" -o -name "superposition_core.*" | while read lib; do
filename=$(basename "$lib")
extension="${filename##*.}"
file="libsuperposition_core-$target_triple.$extension"
cp "$lib" clients/python/bindings/superposition_bindings/$file
echo "Copied $file"
done
# Clean up temp directory
rm -rf temp_extract
done
# List what we have
echo "Native libraries in bindings package:"
ls -la clients/python/bindings/superposition_bindings/
- name: Build bindings package
run: |
cd clients/python/bindings
uv build --wheel
echo "Built bindings wheel:"
ls -la dist/
- name: Build SDK package
run: |
cd clients/python/sdk
uv build --wheel
echo "Built SDK wheel:"
ls -la dist/
env:
VERSION: ${{ needs.tag-release.outputs.version }}
- name: Build provider package
run: |
cd clients/python/provider
# Install dependencies first since provider depends on sdk and bindings
# uv pip install --system ../bindings/dist/*.whl ../sdk/dist/*.whl
uv build --wheel
echo "Built provider wheel:"
ls -la dist/
env:
VERSION: ${{ needs.tag-release.outputs.version }}
- name: Collect all wheels
run: |
mkdir -p python-wheels
cp clients/python/bindings/dist/*.whl python-wheels/
cp clients/python/sdk/dist/*.whl python-wheels/
cp clients/python/provider/dist/*.whl python-wheels/
echo "All Python wheels:"
ls -la python-wheels/
- name: Publish Python packages to PyPI
run: |
twine upload python-wheels/*.whl
generate-js-packages:
needs: [tag-release, generate-rust-binary]
if: github.ref == 'refs/heads/main'
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.tag-release.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: "24.12.0"
registry-url: "https://registry.npmjs.org"
- name: Download all rust binary artifacts
uses: actions/download-artifact@v4
with:
path: rust-binaries
pattern: superposition_core-*
merge-multiple: true
- name: List downloaded artifacts
run: |
echo "Downloaded artifacts:"
find rust-binaries -type f -name "*.zip" | sort
- name: Extract and organize native libraries
run: |
# Extract all native libraries
mkdir -p clients/javascript/bindings/native-lib
for zip_file in rust-binaries/*.zip; do
echo "Extracting $zip_file"
zip_basename=$(basename "$zip_file" .zip)
target_triple="${zip_basename#superposition_core-}"
mkdir -p temp_extract/$target_triple
unzip -o "$zip_file" -d temp_extract/$target_triple/
# Find and copy the native library
find temp_extract/$target_triple -name "libsuperposition_core.*" -o -name "superposition_core.*" | while read lib; do
filename=$(basename "$lib")
extension="${filename##*.}"
file="libsuperposition_core-$target_triple.$extension"
cp "$lib" clients/javascript/bindings/native-lib/$file
echo "Copied $file"
done
# Clean up temp directory
rm -rf temp_extract
done
# List what we have
echo "Native libraries in bindings package:"
ls -la clients/javascript/bindings/native-lib
- run: |
cd clients/javascript
npm ci
npm publish --access public --workspace bindings --workspace sdk --workspace open-feature-provider
generate-rust-packages:
needs: tag-release
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
env:
VERSION: ${{ needs.tag-release.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.tag-release.outputs.updated_ref }}
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.90.0
targets: wasm32-unknown-unknown
components: rustfmt, clippy, cargo
- name: install cargo-edit to perform set-version
uses: baptiste0928/cargo-install@v2.2.0
with:
crate: cargo-edit
version: "0.13.6"
- name: Build and package superposition
run: |
cargo login ${{ secrets.CRATES_IO_TOKEN }}
cargo publish --package superposition_derives
cargo publish --package superposition_sdk
cargo publish --package superposition_types
cargo publish --package superposition_core
cargo publish --package superposition_provider
release:
needs: [tag-release, generate-rust-binary]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name:
Download all artifacts
# This step downloads all artifacts uploaded by the 'generate-builds' job.
# They will be placed into the 'artifacts_dir' directory.
uses: actions/download-artifact@v4
with:
path: artifacts_dir
- name: List downloaded files
run: ls -R artifacts_dir
- uses: softprops/action-gh-release@v2
name: Create GitHub Release
# if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: |
artifacts_dir/superposition_core-x86_64-unknown-linux-gnu.zip/superposition_core-x86_64-unknown-linux-gnu.zip
artifacts_dir/superposition_core-x86_64-apple-darwin.zip/superposition_core-x86_64-apple-darwin.zip
artifacts_dir/superposition_core-aarch64-apple-darwin.zip/superposition_core-aarch64-apple-darwin.zip
artifacts_dir/superposition_core-x86_64-pc-windows-msvc.zip/superposition_core-x86_64-pc-windows-msvc.zip