forked from hyperledger/anoncreds-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51389b8
commit 5b62462
Showing
3 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
name: "Release Libraries" | ||
|
||
env: | ||
RUST_VERSION: "1.73.0" | ||
CROSS_VERSION: "0.2.4" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'Create release with tag' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
build-swift-package: | ||
name: Build Swift Package | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Cache cargo resources | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
shared-key: deps | ||
save-if: false | ||
|
||
- name: Build library for macOS | ||
if: "runner.os == 'macOS'" | ||
run: | | ||
cd uniffi | ||
echo "TAG: ${{github.event.inputs.tag}}" | ||
./build-release-apple-universal.sh | ||
cd .. | ||
checksum=$(swift package compute-checksum 'uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip') | ||
echo "CHECKSUM: $checksum" | ||
rm -f Package.swift | ||
./.scripts/updatePackage.swift ${{github.event.inputs.tag}} $checksum './.scripts/TemplatePackage.swift' 'Package.swift' | ||
- name: Commit package | ||
uses: stefanzweifel/git-auto-commit-action@v5 | ||
with: | ||
commit_message: "chore: prepare release ${{github.event.inputs.tag}}" | ||
tagging_message: ${{github.event.inputs.tag}} | ||
|
||
- name: Upload library artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: libanoncreds.xcframework.zip | ||
path: 'uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip' | ||
|
||
- name: Create library artifacts directory | ||
run: | | ||
mkdir release-artifacts | ||
cp 'uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip' release-artifacts/ | ||
- name: Add swift package artifacts to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
tag: ${{github.event.inputs.tag}} | ||
file: uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip | ||
asset_name: "libanoncreds.xcframework.zip" | ||
|
||
build-release: | ||
needs: build-swift-package | ||
name: Build Library | ||
|
||
strategy: | ||
matrix: | ||
include: | ||
- architecture: linux-aarch64 | ||
os: ubuntu-20.04 | ||
target: aarch64-unknown-linux-gnu | ||
lib: libanoncreds_uniffi.so | ||
libPath: uniffi/target/aarch64-unknown-linux-gnu/release/libanoncreds_uniffi.so | ||
use_cross: true | ||
- architecture: linux-x86_64 | ||
os: ubuntu-20.04 | ||
target: x86_64-unknown-linux-gnu | ||
lib: libanoncreds_uniffi.so | ||
libPath: uniffi/target/x86_64-unknown-linux-gnu/release/libanoncreds_uniffi.so | ||
use_cross: true | ||
- architecture: darwin-x86_64 | ||
os: macos-latest | ||
target: x86_64-apple-darwin | ||
lib: libanoncreds_uniffi.dylib | ||
libPath: uniffi/target/x86_64-apple-darwin/release/libanoncreds_uniffi.dylib | ||
- architecture: darwin-aarch64 | ||
os: macos-latest | ||
target: aarch64-apple-darwin | ||
lib: libanoncreds_uniffi.dylib | ||
libPath: uniffi/target/aarch64-apple-darwin/release/libanoncreds_uniffi.dylib | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: ${{ env.RUST_VERSION }} | ||
targets: ${{ matrix.target }} | ||
|
||
- name: Cache cargo resources | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
shared-key: deps | ||
save-if: false | ||
|
||
- name: Build library for Linux | ||
if: "runner.os == 'Linux'" | ||
run: | | ||
cd uniffi | ||
if [ -n "${{ matrix.use_cross }}" ]; then | ||
cargo install --git https://github.com/cross-rs/cross --tag v${{ env.CROSS_VERSION }} cross | ||
cross build --release --target ${{matrix.target}} | ||
else | ||
cargo build --release --target ${{matrix.target}} | ||
fi | ||
- name: Build library for macOS | ||
if: "runner.os == 'macOS'" | ||
run: | | ||
cd uniffi | ||
cargo build --release --target ${{matrix.target}} | ||
- name: Upload library artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ matrix.lib }} | ||
path: ${{ matrix.libPath }} | ||
|
||
- name: Create library artifacts directory | ||
run: | | ||
mkdir release-artifacts | ||
cp ${{ matrix.libPath }} release-artifacts/ | ||
- name: Release artifacts | ||
uses: a7ul/[email protected] | ||
with: | ||
command: c | ||
cwd: release-artifacts | ||
files: . | ||
outPath: "library-${{ matrix.architecture }}.tar.gz" | ||
|
||
- name: Add library artifacts to release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
tag: ${{github.event.inputs.tag}} | ||
file: library-${{ matrix.architecture }}.tar.gz | ||
asset_name: "library-${{ matrix.architecture }}-${{ github.sha }}.tar.gz" | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// swift-tools-version:5.7 | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "AnoncredsSwift", | ||
platforms: [ | ||
.iOS(.v13), | ||
.macOS(.v12) | ||
], | ||
products: [ | ||
.library( | ||
name: "AnoncredsSwift", | ||
type: .dynamic, | ||
targets: ["AnoncredsSwift"] | ||
), | ||
], | ||
targets: [ | ||
.target( | ||
name: "AnoncredsSwift", | ||
dependencies: ["anoncredsFFI"], | ||
path: "uniffi/output-frameworks/anoncreds-swift/AnoncredsSwift/Sources/Swift" | ||
), | ||
.target( | ||
name: "anoncredsFFI", | ||
dependencies: ["libanoncreds"], | ||
path: "uniffi/output-frameworks/anoncreds-swift/AnoncredsSwift/Sources/C"), | ||
// LOCAL | ||
// .binaryTarget( | ||
// name: "libanoncreds", | ||
// path: "./uniffi/output-frameworks/anoncreds-swift/libanoncreds.xcframework.zip" | ||
// ) | ||
// RELEASE | ||
.binaryTarget( | ||
name: "libanoncreds", | ||
url: "https://github.com/input-output-hk/anoncreds-rs/releases/download/<ref>/libanoncreds.xcframework.zip", | ||
checksum: "<checksum>" | ||
) | ||
] | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env swift | ||
|
||
import Foundation | ||
|
||
func main() { | ||
if CommandLine.argc != 5 { | ||
let help = "Invoke the script with `swift updateFiles <ref sub> <checksum sub> <input_file_path> <output_file_path>`" | ||
print("Wrong number of arguments.\n\(help)") | ||
exit(1) | ||
} | ||
|
||
let args = CommandLine.arguments | ||
let ref = args[1] | ||
let checksum = args[2] | ||
let inputPath = args[3] | ||
let outputPath = args[4] | ||
|
||
do { | ||
// Read the content of the file | ||
let fileContent = try String(contentsOfFile: inputPath, encoding: .utf8) | ||
|
||
// Replace <ref> and <checksum> with specified values | ||
let updatedContent = fileContent.replacingOccurrences(of: "<ref>", with: ref) | ||
.replacingOccurrences(of: "<checksum>", with: checksum) | ||
|
||
// Write the updated content to the output file | ||
try updatedContent.write(toFile: outputPath, atomically: true, encoding: .utf8) | ||
print("File updated successfully.") | ||
} catch { | ||
print("An error occurred: \(error.localizedDescription)") | ||
} | ||
} | ||
|
||
main() |