Skip to content

Commit

Permalink
Set up repository for BlueskyAPI releases.
Browse files Browse the repository at this point in the history
  • Loading branch information
christiandeange committed Apr 15, 2024
0 parents commit e7052c7
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/update_version.yml
Original file line number Diff line number Diff line change
@@ -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"
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libraries]
bluesky = { module = "sh.christian.ozone:bluesky", version = "0.0.9" }
6 changes: 6 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
]
}
27 changes: 27 additions & 0 deletions templates/Package.swift
Original file line number Diff line number Diff line change
@@ -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
)
,
]
)
31 changes: 31 additions & 0 deletions update_version.sh
Original file line number Diff line number Diff line change
@@ -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 <new-version>" >&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 <new-version>" >&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

0 comments on commit e7052c7

Please sign in to comment.