From 91f86d63d0941ae7049e699ce4eff9539671a9d4 Mon Sep 17 00:00:00 2001 From: Stefan Date: Sat, 22 Feb 2025 16:53:11 +0100 Subject: [PATCH] add pipelines for release --- .github/workflows/uniffi-version-bump.yaml | 56 ++++++++++++++++++++++ .github/workflows/uniffi.yaml | 1 - bindings/uniffi/.bumpversion.cfg | 7 +++ bindings/uniffi/Cargo.toml | 4 +- bindings/uniffi/build.gradle.kts | 17 ++++++- 5 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/uniffi-version-bump.yaml create mode 100644 bindings/uniffi/.bumpversion.cfg diff --git a/.github/workflows/uniffi-version-bump.yaml b/.github/workflows/uniffi-version-bump.yaml new file mode 100644 index 00000000..ef62d63e --- /dev/null +++ b/.github/workflows/uniffi-version-bump.yaml @@ -0,0 +1,56 @@ +name: "Release: Uniffi" + +env: + WORKING_DIRECTORY: bindings/uniffi + +on: + workflow_dispatch: + inputs: + version: + description: 'Version' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major + +permissions: + contents: write + +jobs: + publish: + name: Version + runs-on: ubuntu-latest + defaults: + run: + working-directory: ${{ env.WORKING_DIRECTORY }} + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + + - name: Set Git author + run: | + git config user.name "Bot" + git config user.email "bot@gorules.io" + + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: 'Install dependencies' + run: pip install --upgrade bump2version + + - name: Bumpversion + run: bumpversion ${{ github.event.inputs.version }} --allow-dirty --tag-name "uniffi-v{new_version}" + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Push changes + uses: ad-m/github-push-action@v0.6.0 + with: + github_token: ${{ secrets.PAT}} diff --git a/.github/workflows/uniffi.yaml b/.github/workflows/uniffi.yaml index d833eb08..e9a8af62 100644 --- a/.github/workflows/uniffi.yaml +++ b/.github/workflows/uniffi.yaml @@ -110,7 +110,6 @@ jobs: run: | cargo run \ --bin uniffi-bindgen \ - --features "uniffi/cli" \ -- generate \ --library build/generated/main/resources/linux-x86-64/libzen_uniffi.so \ --language kotlin \ diff --git a/bindings/uniffi/.bumpversion.cfg b/bindings/uniffi/.bumpversion.cfg new file mode 100644 index 00000000..7766780d --- /dev/null +++ b/bindings/uniffi/.bumpversion.cfg @@ -0,0 +1,7 @@ +[bumpversion] +current_version = 0.1.0 +commit = True +tag = True +message = chore(release): publish uniffi + +[bumpversion:file:Cargo.toml] \ No newline at end of file diff --git a/bindings/uniffi/Cargo.toml b/bindings/uniffi/Cargo.toml index a2d64403..55cf27e8 100644 --- a/bindings/uniffi/Cargo.toml +++ b/bindings/uniffi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zen-uniffi" -version = "0.39.0" +version = "0.1.0" edition = "2021" license = "MIT" publish = false @@ -13,7 +13,7 @@ name = "uniffi-bindgen" path = "uniffi-bindgen.rs" [dependencies] -uniffi = { version = "0.29.0", features = ["tokio"] } +uniffi = { version = "0.29.0", features = ["tokio", "cli"] } serde_json = { workspace = true } zen-engine = { path = "../../core/engine" } zen-expression = { path = "../../core/expression" } diff --git a/bindings/uniffi/build.gradle.kts b/bindings/uniffi/build.gradle.kts index fc64af92..9921ef43 100644 --- a/bindings/uniffi/build.gradle.kts +++ b/bindings/uniffi/build.gradle.kts @@ -1,7 +1,15 @@ +import org.tomlj.Toml import java.util.* group = "io.gorules" -version = "0.1.0" +version = loadCargoVersion() + +buildscript { + dependencies { + classpath("org.tomlj:tomlj:1.1.1") + } +} + plugins { kotlin("jvm") version "2.1.0" @@ -95,4 +103,11 @@ nmcp { password.set(remotePassword.get()) } } +} + +fun loadCargoVersion(): String { + val cargoFile = file("${projectDir}/Cargo.toml") + val result = Toml.parse(cargoFile.toPath()) + return result.getTable("package")?.getString("version") + ?: throw GradleException("Version not found in Cargo.toml") } \ No newline at end of file