Scipio 的 AWS S3 缓存存储后端。
scipio
CLI 没有提供设置自定义缓存存储后端的方法。
您必须使用 ScipioKit
准备构建脚本。
import ScipioKit
import ScipioS3Storage
// Define S3 Storage settings
let config = AuthorizedConfiguration(
bucket: "my-bucket",
region: "ap-northeast-1",
accessKeyID: "AWS_ACCESS_KEY_ID",
secretAccessKey: "AWS_SECRET_ACCESS_KEY"
)
// Instantiate S3Storage
let s3Storage = try S3Storage(config: .authorized(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
)
S3Storage
有两种授权模式。
.authorized
需要 AWS 凭证来上传/下载构建工件。 这对缓存生产者和消费者都有好处。
使用 .usePublicURL
模式时,S3 客户端会尝试从公共 URL 获取构建工件。它不需要任何身份验证。 这对缓存消费者有好处。 在此模式下,客户端无法上传工件。 所以它一定不能成为生产者。
如果您想使用未经身份验证的模式,则必须从生产者上传带有 shoudPublishObject
选项的工件。 此选项表示 ACL 设置为 publicRead
。 这意味着所有工件都将变为公开。
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")!
)