Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Publish Swift Bindings #19

Publish Swift Bindings

Publish Swift Bindings #19

name: Publish Swift Bindings
on:
workflow_dispatch:
inputs:
version:
description: 'Release (MAJOR.MINOR.PATCH)'
required: true
type: string
ref:
description: 'Ref (branch, tag, commit) to checkout (from rust-nostr/nostr repo)'
required: true
type: string
default: 'master'
jobs:
build-tag-release:
name: Build, tag, and release the Nostr SDK Swift bindings
runs-on: macOS-latest
permissions:
contents: write
steps:
- name: Checkout nostr repo
uses: actions/checkout@v3
with:
repository: ${{ github.repository_owner }}/nostr
path: build
ref: ${{ inputs.ref }}
- name: Checkout nostr-swift repo
uses: actions/checkout@v3
with:
path: dist
ssh-key: ${{ secrets.NOSTR_SWIFT_DEPLOY_KEY }}
- name: Install just
run: cargo install just
- name: Build Swift bindings
working-directory: build/bindings/nostr-ffi
run: |
just init
just bindings-swift
- name: Compress XCFramework
working-directory: build/bindings/nostr-ffi/bindings-swift
run: |
zip -9 -r nostrFFI.xcframework.zip nostrFFI.xcframework
echo "XCF_CHECKSUM=`swift package compute-checksum nostrFFI.xcframework.zip`" >> $GITHUB_ENV
- name: Update Swift Package definition
working-directory: build/bindings/nostr-ffi/bindings-swift
run: |
sed 's#.binaryTarget(name: "nostrFFI", path: "./nostrFFI.xcframework"),#.binaryTarget(name: "nostrFFI", url: "https://github.com/rust-nostr/nostr-swift/releases/download/${{ inputs.version }}/nostrFFI.xcframework.zip", checksum: "${{ env.XCF_CHECKSUM }}"),#;/.testTarget(name: "NostrTests", dependencies: \["Nostr"\]),/d' Package.swift > ../../../../dist/Package.swift
cp -r Sources ../../../../dist
- name: Tag the Swift bindings
working-directory: dist
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add Package.swift
git add Sources
git commit -m "Update Nostr Swift bindings to version ${{ inputs.version }}"
git push
git tag ${{ inputs.version }} -m "${{ inputs.version }}"
git push --tags
- name: Release and attach XCFramework binary artifact
uses: ncipollo/release-action@v1
with:
artifacts: "build/bindings/nostr-ffi/bindings-swift/nostrFFI.xcframework.zip"
tag: ${{ inputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ inputs.version }}
prerelease: false