Swiftpack.co - giginet/scipio-s3-storage as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by giginet.
giginet/scipio-s3-storage 0.12.0
Scipio cache storage backend for AWS S3
⭐️ 2
🕓 1 year ago
macOS
.package(url: "https://github.com/giginet/scipio-s3-storage.git", from: "0.12.0")

ScipioS3Storage

Scipio cache storage backend for AWS S3.

Usage

scipio CLI doesn't provide a way to set custom cache storage backend.

You have to prepare build script using ScipioKit.

import ScipioKit
import ScipioS3Storage

// Define S3 Storage settings
let config = S3StorageConfig(
    authenticationMode: .authorized(
        accessKeyID: "AWS_ACCESS_KEY_ID", 
        secretAccessKey: "AWS_SECRET_ACCESS_KEY"
    ),
    bucket: "my-bucket",
    region: "ap-northeast-1",
    endpoint: URL(string: "https://my-s3-bucket.com")!
)

// Instantiate S3Storage
let s3Storage = try S3Storage(config: config)

// Define Scipio Runner options
let options = Runner.Options(
    baseBuildOptions: .init(
        buildConfiguration: .release,
        isSimulatorSupported: false,
        isDebugSymbolsEmbedded: false,
        frameworkType: .static,
        extraBuildParameters: nil,
        enableLibraryEvolution: false
    ),
    buildOptionsMatrix: [:],
    cacheMode: .storage(s3Storage, [.consumer, .producer]),
    overwrite: true,
    verbose: verbose
)

// Create Scipio Runner in Prepare mode
let runner = Runner(
    mode: .prepareDependencies,
    options: options
)

// Run for your package description
try await runner.run(
    packageDirectory: packagePath,
    frameworkOutputDir: .default
)

Authorization Mode

S3Storage have two authorization modes.

.authorized requires AWS credential to upload/download build artifacts. It's good for both cache producer and consumer.

Using .usePublicURL mode, S3 client attempt to fetch build artifacts from Public URL. It doesn't need any authentication. It's good for cache consumers. In this mode, client can't upload artifacts. So it must not become producers.

If you want to use non-authenticated mode, you have to upload artifacts from producers with shoudPublishObject option. This option indicates ACL to be publicRead. It means all artifacts will become public.

let producerConfig = S3StorageConfig(
    authenticationMode: .authorized(
        accessKeyID: "AWS_ACCESS_KEY_ID", 
        secretAccessKey: "AWS_SECRET_ACCESS_KEY"
    ),
    bucket: "my-bucket",
    region: "ap-northeast-1",
    endpoint: URL(string: "https://my-s3-bucket.com")!,
    shouldPublishObject: true
)

let consumerConfig = S3StorageConfig(
    authenticationMode: .usePublicURL,
    bucket: "my-bucket",
    region: "ap-northeast-1",
    endpoint: URL(string: "https://my-s3-bucket.com")!
)

GitHub

link
Stars: 2
Last commit: 51 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

0.11.0
1 year ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics