diff --git a/.github/workflows/update_version.yml b/.github/workflows/update_version.yml new file mode 100644 index 0000000..75fb01f --- /dev/null +++ b/.github/workflows/update_version.yml @@ -0,0 +1,33 @@ +on: + workflow_dispatch: + push: + branches: + - main + paths: + - gradle/libs.versions.toml + +jobs: + update-version: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: "Checkout repo" + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: "Set version as envionment variable" + run: echo "LATEST_VERSION=$(awk -F\" '/sh.christian.ozone:bluesky/ { print $4 }' < gradle/libs.versions.toml)" >> $GITHUB_ENV + + - name: "Update Package.swift" + run: ./update_version.sh ${{ env.LATEST_VERSION }} + + - name: "Commit changes back to repo" + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "Releasing v${{ env.LATEST_VERSION }}." + tagging_message: "${{ env.LATEST_VERSION }}" + file_pattern: "Package.swift" diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec3ee5b --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +![Maven Central](https://img.shields.io/maven-central/v/sh.christian.ozone/bluesky?versionPrefix=0.0.9) ![CI](https://github.com/christiandeange/ozone/actions/workflows/ci.yml/badge.svg) + +BlueskyAPI +========== + +### Overview + +Swift bindings for Bluesky Social, powered by [Ozone](https://github.com/christiandeange/ozone). No relation to the moderation tools also named [Ozone](https://github.com/bluesky-social/ozone). + +> **Warning** +> +> 🚧 🚧 🚧 Everything in here is very much a work-in-progress! +> The [upstream schemas](https://github.com/christiandeange/ozone/commits/main/bluesky/lexicons) are still subject to breaking +> changes and may break at any moment if used in production code. Use at your own risk! + +### Installation + +In Xcode, select **File > Add Packages...** and enter https://github.com/christiandeange/BlueskyAPI. + +### Sample Usage + +```swift +let api = XrpcBlueskyApi() +let call = try await api.describeServer() +switch onEnum(of: call) { +case .success(let success): + print(success.response) +case .failure(let failure): + print(failure.response ?? failure.error ?? failure) +} +``` + +Docs are available at [ozone.christian.sh](https://ozone.christian.sh). diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..fe9f107 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,2 @@ +[libraries] +bluesky = { module = "sh.christian.ozone:bluesky", version = "0.0.9" } diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..5db72dd --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ] +} diff --git a/templates/Package.swift b/templates/Package.swift new file mode 100644 index 0000000..8b62c9d --- /dev/null +++ b/templates/Package.swift @@ -0,0 +1,27 @@ +// swift-tools-version:5.3 +import PackageDescription + +let remoteKotlinUrl = "{url}" +let remoteKotlinChecksum = "{checksum}" +let packageName = "BlueskyAPI" + +let package = Package( + name: packageName, + platforms: [ + .iOS(.v13) + ], + products: [ + .library( + name: packageName, + targets: [packageName] + ), + ], + targets: [ + .binaryTarget( + name: packageName, + url: remoteKotlinUrl, + checksum: remoteKotlinChecksum + ) + , + ] +) diff --git a/update_version.sh b/update_version.sh new file mode 100755 index 0000000..c6dc569 --- /dev/null +++ b/update_version.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +set -euo pipefail +set -x + +ZIP_URL_TEMPLATE="https://repo1.maven.org/maven2/sh/christian/ozone/bluesky-kmmbridge/{version}/bluesky-kmmbridge-{version}.zip" + +if [[ -z "${1}" ]]; then + echo "Usage: $0 " >&2 + exit 1 +elif ! [[ "${1}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + echo "Error: '${1}' is not a valid semantic version." >&2 + echo "Usage: $0 " >&2 + exit 1 +fi + +NEXT_VERSION="${1-}" + +ZIP_URL="$(sed "s/{version}/$NEXT_VERSION/g" <<< "$ZIP_URL_TEMPLATE")" +SHA_URL="${ZIP_URL}.sha256" + +CHECKSUM="$(curl -s $SHA_URL)" +echo $CHECKSUM + +cp templates/Package.swift . + +if [ $(uname) == "Darwin" ]; then + SP=" " # Needed for portability with sed +fi +sed -i${SP}'' "s|{url}|$ZIP_URL|g" Package.swift +sed -i${SP}'' "s|{checksum}|$CHECKSUM|g" Package.swift