Release #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Release version (e.g., 0.17.12)' | |
| required: true | |
| type: string | |
| dry_run: | |
| description: 'Dry run (skip release creation and publishing)' | |
| required: false | |
| default: false | |
| type: boolean | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # Prepare release - set version outputs | |
| prepare-release: | |
| name: Prepare Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| outputs: | |
| version: ${{ steps.set-version.outputs.version }} | |
| version_tag: ${{ steps.set-version.outputs.version_tag }} | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set version outputs | |
| id: set-version | |
| run: | | |
| VERSION="${{ github.event.inputs.version }}" | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "version_tag=v${VERSION}" >> $GITHUB_OUTPUT | |
| # Build iOS artifacts on macOS | |
| build-ios: | |
| name: Build iOS | |
| needs: prepare-release | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-apple-ios,aarch64-apple-ios-sim | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}-ios-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: ${{ runner.os }}-ios-cargo- | |
| - name: Build iOS targets | |
| run: | | |
| targets=("aarch64-apple-ios" "aarch64-apple-ios-sim") | |
| for target in "${targets[@]}"; do | |
| echo "Building for $target..." | |
| cargo build --release --target $target -p cooklang-bindings | |
| done | |
| - name: Generate Swift bindings | |
| working-directory: bindings | |
| run: | | |
| mkdir -p out | |
| cargo run --features="uniffi/cli" --bin uniffi-bindgen generate \ | |
| --config uniffi.toml \ | |
| --library ../target/aarch64-apple-ios/release/libcooklang_bindings.a \ | |
| --language swift \ | |
| --out-dir out | |
| - name: Create XCFramework | |
| working-directory: bindings | |
| run: | | |
| NAME="CooklangParser" | |
| LIBRARY_NAME="libcooklang_bindings.a" | |
| FRAMEWORK_LIBRARY_NAME="${NAME}FFI" | |
| FRAMEWORK_NAME="$FRAMEWORK_LIBRARY_NAME.framework" | |
| XC_FRAMEWORK_NAME="$FRAMEWORK_LIBRARY_NAME.xcframework" | |
| HEADER_NAME="${NAME}FFI.h" | |
| OUT_PATH="out" | |
| MIN_IOS_VERSION="16.0" | |
| BUNDLE_IDENTIFIER="org.cooklang.$NAME" | |
| # Target paths | |
| AARCH64_APPLE_IOS_PATH="../target/aarch64-apple-ios/release" | |
| AARCH64_APPLE_IOS_SIM_PATH="../target/aarch64-apple-ios-sim/release" | |
| # Create framework template | |
| rm -rf $OUT_PATH/$FRAMEWORK_NAME | |
| mkdir -p $OUT_PATH/$FRAMEWORK_NAME/Headers | |
| mkdir -p $OUT_PATH/$FRAMEWORK_NAME/Modules | |
| cp $OUT_PATH/$HEADER_NAME $OUT_PATH/$FRAMEWORK_NAME/Headers | |
| cat > $OUT_PATH/$FRAMEWORK_NAME/Modules/module.modulemap << EOF | |
| framework module $FRAMEWORK_LIBRARY_NAME { | |
| umbrella header "$HEADER_NAME" | |
| export * | |
| module * { export * } | |
| } | |
| EOF | |
| cat > $OUT_PATH/$FRAMEWORK_NAME/Info.plist << EOF | |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>CFBundleDevelopmentRegion</key> | |
| <string>en</string> | |
| <key>CFBundleExecutable</key> | |
| <string>$FRAMEWORK_LIBRARY_NAME</string> | |
| <key>CFBundleIdentifier</key> | |
| <string>$BUNDLE_IDENTIFIER</string> | |
| <key>CFBundleInfoDictionaryVersion</key> | |
| <string>6.0</string> | |
| <key>CFBundleName</key> | |
| <string>$FRAMEWORK_LIBRARY_NAME</string> | |
| <key>CFBundlePackageType</key> | |
| <string>FMWK</string> | |
| <key>CFBundleShortVersionString</key> | |
| <string>1.0</string> | |
| <key>CFBundleVersion</key> | |
| <string>1.0</string> | |
| <key>NSPrincipalClass</key> | |
| <string></string> | |
| <key>MinimumOSVersion</key> | |
| <string>$MIN_IOS_VERSION</string> | |
| </dict> | |
| </plist> | |
| EOF | |
| # Prepare frameworks for each platform | |
| rm -rf $OUT_PATH/frameworks | |
| mkdir -p $OUT_PATH/frameworks/sim | |
| mkdir -p $OUT_PATH/frameworks/ios | |
| cp -r $OUT_PATH/$FRAMEWORK_NAME $OUT_PATH/frameworks/sim/ | |
| cp -r $OUT_PATH/$FRAMEWORK_NAME $OUT_PATH/frameworks/ios/ | |
| cp $AARCH64_APPLE_IOS_SIM_PATH/$LIBRARY_NAME $OUT_PATH/frameworks/sim/$FRAMEWORK_NAME/$FRAMEWORK_LIBRARY_NAME | |
| cp $AARCH64_APPLE_IOS_PATH/$LIBRARY_NAME $OUT_PATH/frameworks/ios/$FRAMEWORK_NAME/$FRAMEWORK_LIBRARY_NAME | |
| # Create xcframework | |
| echo "Creating xcframework..." | |
| rm -rf $OUT_PATH/$XC_FRAMEWORK_NAME | |
| xcodebuild -create-xcframework \ | |
| -framework $OUT_PATH/frameworks/sim/$FRAMEWORK_NAME \ | |
| -framework $OUT_PATH/frameworks/ios/$FRAMEWORK_NAME \ | |
| -output $OUT_PATH/$XC_FRAMEWORK_NAME | |
| - name: Package iOS artifacts | |
| run: | | |
| cd bindings/out | |
| zip -r ../../CooklangParserFFI.xcframework.zip CooklangParserFFI.xcframework | |
| - name: Upload iOS artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ios-artifacts | |
| path: CooklangParserFFI.xcframework.zip | |
| # Build Android artifacts on Linux | |
| build-android: | |
| name: Build Android | |
| needs: prepare-release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}-android-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: ${{ runner.os }}-android-cargo- | |
| - name: Setup Android NDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Install NDK | |
| run: | | |
| sdkmanager --install "ndk;26.1.10909125" | |
| echo "ANDROID_NDK_HOME=$ANDROID_HOME/ndk/26.1.10909125" >> $GITHUB_ENV | |
| - name: Install cargo-ndk | |
| run: command -v cargo-ndk || cargo install cargo-ndk --locked | |
| - name: Build uniffi-bindgen for host | |
| working-directory: bindings | |
| run: cargo build --features="uniffi/cli" --bin uniffi-bindgen --release | |
| - name: Build Android targets | |
| working-directory: bindings | |
| run: | | |
| cargo ndk --target aarch64-linux-android --platform 21 build --release | |
| cargo ndk --target armv7-linux-androideabi --platform 21 build --release | |
| cargo ndk --target x86_64-linux-android --platform 21 build --release | |
| - name: Generate Kotlin bindings | |
| working-directory: bindings | |
| run: | | |
| rm -rf out/kotlin | |
| mkdir -p out/kotlin | |
| ../target/release/uniffi-bindgen generate \ | |
| --config uniffi.toml \ | |
| --library ../target/aarch64-linux-android/release/libcooklang_bindings.so \ | |
| --language kotlin \ | |
| --out-dir out/kotlin | |
| - name: Organize JNI libraries | |
| run: | | |
| mkdir -p target/android/jniLibs/{arm64-v8a,armeabi-v7a,x86_64} | |
| cp target/aarch64-linux-android/release/libcooklang_bindings.so target/android/jniLibs/arm64-v8a/ | |
| cp target/armv7-linux-androideabi/release/libcooklang_bindings.so target/android/jniLibs/armeabi-v7a/ | |
| cp target/x86_64-linux-android/release/libcooklang_bindings.so target/android/jniLibs/x86_64/ | |
| - name: Create Android library module | |
| run: | | |
| mkdir -p target/android/parser/src/main/kotlin | |
| mkdir -p target/android/parser/src/main/jniLibs | |
| # Copy JNI libs | |
| cp -R target/android/jniLibs/* target/android/parser/src/main/jniLibs/ | |
| # Copy Kotlin bindings | |
| find bindings/out/kotlin -name "*.kt" -exec cp {} target/android/parser/src/main/kotlin/ \; | |
| # Create build.gradle.kts | |
| cat > target/android/parser/build.gradle.kts << 'EOF' | |
| plugins { | |
| id("com.android.library") | |
| id("org.jetbrains.kotlin.android") | |
| } | |
| android { | |
| namespace = "org.cooklang.parser" | |
| compileSdk = 34 | |
| defaultConfig { | |
| minSdk = 26 | |
| testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | |
| consumerProguardFiles("consumer-rules.pro") | |
| } | |
| buildTypes { | |
| release { | |
| isMinifyEnabled = false | |
| proguardFiles( | |
| getDefaultProguardFile("proguard-android-optimize.txt"), | |
| "proguard-rules.pro" | |
| ) | |
| } | |
| } | |
| compileOptions { | |
| sourceCompatibility = JavaVersion.VERSION_17 | |
| targetCompatibility = JavaVersion.VERSION_17 | |
| } | |
| kotlinOptions { | |
| jvmTarget = "17" | |
| } | |
| sourceSets { | |
| getByName("main") { | |
| jniLibs.srcDirs("src/main/jniLibs") | |
| } | |
| } | |
| } | |
| dependencies { | |
| implementation("net.java.dev.jna:jna:5.14.0@aar") | |
| implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") | |
| } | |
| EOF | |
| # Create AndroidManifest.xml | |
| cat > target/android/parser/src/main/AndroidManifest.xml << 'EOF' | |
| <?xml version="1.0" encoding="utf-8"?> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | |
| </manifest> | |
| EOF | |
| # Create proguard rules | |
| cat > target/android/parser/proguard-rules.pro << 'EOF' | |
| -keep class uniffi.** { *; } | |
| -keep class org.cooklang.** { *; } | |
| -keep class com.sun.jna.** { *; } | |
| -keepclassmembers class * extends com.sun.jna.** { public *; } | |
| EOF | |
| cat > target/android/parser/consumer-rules.pro << 'EOF' | |
| -keep class uniffi.** { *; } | |
| -keep class org.cooklang.** { *; } | |
| EOF | |
| - name: Package Android artifacts | |
| run: | | |
| cd target/android | |
| zip -r ../../cooklang-parser-android.zip parser jniLibs | |
| - name: Upload Android artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-artifacts | |
| path: cooklang-parser-android.zip | |
| # Update Package.swift with correct checksum | |
| update-package-swift: | |
| name: Update Package.swift | |
| needs: [prepare-release, build-ios] | |
| runs-on: macos-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download iOS artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ios-artifacts | |
| - name: Compute checksum | |
| id: checksum | |
| run: | | |
| CHECKSUM=$(swift package compute-checksum CooklangParserFFI.xcframework.zip) | |
| echo "checksum=${CHECKSUM}" >> $GITHUB_OUTPUT | |
| echo "Computed checksum: ${CHECKSUM}" | |
| - name: Update Package.swift | |
| run: | | |
| VERSION="${{ needs.prepare-release.outputs.version_tag }}" | |
| CHECKSUM="${{ steps.checksum.outputs.checksum }}" | |
| sed -i '' "s|url: \"https://github.com/cooklang/cooklang-rs/releases/download/[^\"]*\"|url: \"https://github.com/cooklang/cooklang-rs/releases/download/${VERSION}/CooklangParserFFI.xcframework.zip\"|" Package.swift | |
| sed -i '' "s|checksum: \"[^\"]*\"|checksum: \"${CHECKSUM}\"|" Package.swift | |
| echo "Updated Package.swift:" | |
| grep -A2 "binaryTarget" Package.swift | head -5 | |
| - name: Commit Package.swift | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Package.swift | |
| git commit -m "Update Package.swift for ${{ needs.prepare-release.outputs.version_tag }}" || echo "No changes to commit" | |
| git push origin HEAD:main | |
| # Create GitHub Release | |
| create-release: | |
| name: Create Release | |
| needs: [prepare-release, build-ios, build-android, update-package-swift] | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download iOS artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ios-artifacts | |
| - name: Download Android artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: android-artifacts | |
| - name: Create and push tag | |
| run: | | |
| VERSION_TAG="${{ needs.prepare-release.outputs.version_tag }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Create tag at current commit (which includes updated Package.swift) | |
| git tag "${VERSION_TAG}" | |
| git push origin "${VERSION_TAG}" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ needs.prepare-release.outputs.version_tag }} | |
| name: Release ${{ needs.prepare-release.outputs.version_tag }} | |
| draft: false | |
| prerelease: ${{ contains(github.event.inputs.version, 'alpha') || contains(github.event.inputs.version, 'beta') || contains(github.event.inputs.version, 'rc') }} | |
| generate_release_notes: true | |
| files: | | |
| CooklangParserFFI.xcframework.zip | |
| cooklang-parser-android.zip | |
| body: | | |
| ## Cooklang Parser Release ${{ needs.prepare-release.outputs.version_tag }} | |
| ### iOS (Swift Package Manager) | |
| Add to your `Package.swift` or Xcode project: | |
| ```swift | |
| .package(url: "https://github.com/cooklang/cooklang-rs.git", from: "${{ needs.prepare-release.outputs.version_tag }}") | |
| ``` | |
| Or download `CooklangParserFFI.xcframework.zip` for manual integration. | |
| **Supported architectures:** | |
| - iOS arm64 (devices) | |
| - iOS arm64 (simulator, Apple Silicon) | |
| ### Android (GitHub Packages Maven) | |
| Add to your `settings.gradle.kts`: | |
| ```kotlin | |
| dependencyResolutionManagement { | |
| repositories { | |
| maven { | |
| url = uri("https://maven.pkg.github.com/cooklang/cooklang-rs") | |
| credentials { | |
| username = System.getenv("GITHUB_ACTOR") ?: project.findProperty("gpr.user") as String? | |
| password = System.getenv("GITHUB_TOKEN") ?: project.findProperty("gpr.key") as String? | |
| } | |
| } | |
| } | |
| } | |
| ``` | |
| Add to your `build.gradle.kts`: | |
| ```kotlin | |
| implementation("org.cooklang:parser:${{ needs.prepare-release.outputs.version_tag }}") | |
| ``` | |
| Or download `cooklang-parser-android.zip` for manual integration. | |
| **Supported architectures:** | |
| - arm64-v8a | |
| - armeabi-v7a | |
| - x86_64 | |
| > **Note:** This replaces the deprecated `cooklang-kotlin` repository. | |
| ### Rust (crates.io) | |
| ```toml | |
| [dependencies] | |
| cooklang = "${{ needs.prepare-release.outputs.version }}" | |
| ``` | |
| ### TypeScript/JavaScript (npm) | |
| ```bash | |
| npm install @cooklang/cooklang | |
| ``` | |
| See the README for detailed integration instructions. | |
| # Publish Android package to GitHub Packages | |
| publish-android: | |
| name: Publish Android to GitHub Packages | |
| needs: [prepare-release, build-android, create-release] | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Download Android artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: android-artifacts | |
| - name: Extract Android artifacts | |
| run: | | |
| mkdir -p target/android | |
| unzip cooklang-parser-android.zip -d target/android/ | |
| - name: Setup JDK | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| - name: Configure Android library for publishing | |
| run: | | |
| VERSION="${{ needs.prepare-release.outputs.version }}" | |
| ANDROID_DIR="target/android/parser" | |
| # Create settings.gradle.kts with plugin management | |
| cat > "${ANDROID_DIR}/settings.gradle.kts" << 'EOF' | |
| pluginManagement { | |
| repositories { | |
| google() | |
| mavenCentral() | |
| gradlePluginPortal() | |
| } | |
| } | |
| dependencyResolutionManagement { | |
| repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) | |
| repositories { | |
| google() | |
| mavenCentral() | |
| } | |
| } | |
| rootProject.name = "parser" | |
| EOF | |
| # Create build.gradle.kts with publishing | |
| cat > "${ANDROID_DIR}/build.gradle.kts" << EOF | |
| plugins { | |
| id("com.android.library") version "8.2.0" | |
| id("org.jetbrains.kotlin.android") version "1.9.22" | |
| id("maven-publish") | |
| } | |
| group = "org.cooklang" | |
| version = "${VERSION}" | |
| android { | |
| namespace = "org.cooklang.parser" | |
| compileSdk = 34 | |
| defaultConfig { | |
| minSdk = 26 | |
| testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | |
| consumerProguardFiles("consumer-rules.pro") | |
| aarMetadata { | |
| minCompileSdk = 26 | |
| } | |
| } | |
| buildTypes { | |
| release { | |
| isMinifyEnabled = false | |
| proguardFiles( | |
| getDefaultProguardFile("proguard-android-optimize.txt"), | |
| "proguard-rules.pro" | |
| ) | |
| } | |
| } | |
| compileOptions { | |
| sourceCompatibility = JavaVersion.VERSION_17 | |
| targetCompatibility = JavaVersion.VERSION_17 | |
| } | |
| kotlinOptions { | |
| jvmTarget = "17" | |
| } | |
| sourceSets { | |
| getByName("main") { | |
| jniLibs.srcDirs("src/main/jniLibs") | |
| } | |
| } | |
| publishing { | |
| singleVariant("release") { | |
| withSourcesJar() | |
| } | |
| } | |
| } | |
| dependencies { | |
| implementation("net.java.dev.jna:jna:5.14.0@aar") | |
| implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") | |
| } | |
| publishing { | |
| publications { | |
| register<MavenPublication>("release") { | |
| groupId = "org.cooklang" | |
| artifactId = "parser" | |
| version = "${VERSION}" | |
| afterEvaluate { | |
| from(components["release"]) | |
| } | |
| pom { | |
| name.set("cooklang-parser") | |
| description.set("Cooklang Parser Library for Android") | |
| url.set("https://github.com/cooklang/cooklang-rs") | |
| licenses { | |
| license { | |
| name.set("The MIT License (MIT)") | |
| url.set("http://opensource.org/licenses/MIT") | |
| } | |
| } | |
| developers { | |
| developer { | |
| id.set("dubadub") | |
| name.set("Alexey Dubovskoy") | |
| } | |
| } | |
| scm { | |
| connection.set("scm:git:git://github.com/cooklang/cooklang-rs.git") | |
| developerConnection.set("scm:git:ssh://github.com:cooklang/cooklang-rs.git") | |
| url.set("https://github.com/cooklang/cooklang-rs") | |
| } | |
| } | |
| } | |
| } | |
| repositories { | |
| maven { | |
| name = "GitHubPackages" | |
| url = uri("https://maven.pkg.github.com/cooklang/cooklang-rs") | |
| credentials { | |
| username = System.getenv("GITHUB_ACTOR") | |
| password = System.getenv("GITHUB_TOKEN") | |
| } | |
| } | |
| } | |
| } | |
| EOF | |
| # Create gradle.properties | |
| cat > "${ANDROID_DIR}/gradle.properties" << 'GRADLE_EOF' | |
| android.useAndroidX=true | |
| kotlin.code.style=official | |
| org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 | |
| android.nonTransitiveRClass=true | |
| GRADLE_EOF | |
| - name: Publish to GitHub Packages | |
| working-directory: target/android/parser | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| run: | | |
| gradle wrapper --gradle-version 8.5 | |
| ./gradlew publish --no-daemon | |
| # Publish Rust crate to crates.io | |
| publish-rust: | |
| name: Publish to crates.io | |
| needs: [prepare-release, build-ios, build-android] | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Authenticate to crates.io | |
| uses: rust-lang/crates-io-auth-action@v1 | |
| id: auth | |
| - name: Publish to crates.io | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} | |
| run: cargo publish --no-verify | |
| # Publish TypeScript package to npm | |
| publish-typescript: | |
| name: Publish to npm | |
| needs: [prepare-release, build-ios, build-android] | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.inputs.dry_run != 'true' }} | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install wasm-pack | |
| run: cargo install wasm-pack --locked || true | |
| - name: Build TypeScript package | |
| working-directory: typescript | |
| run: | | |
| npm ci | |
| npm run build | |
| - name: Publish to npm | |
| working-directory: typescript | |
| run: npm publish --access public |