Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
90 changes: 90 additions & 0 deletions .github/workflows/release.yml_
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest

name: Release to Maven Central

permissions:
contents: write
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'gradle'

- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Releasing version: $VERSION"

- name: Update version in build.gradle.kts
run: |
sed -i "s/version = \".*\"/version = \"${{ steps.version.outputs.version }}\"/" build.gradle.kts
cat build.gradle.kts | grep "version ="

- name: Make Gradle wrapper executable
run: chmod +x gradlew

- name: Build
run: ./gradlew clean build

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Publish to Maven Central
run: ./gradlew publish
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
GPG_SIGNING_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_SIGNING_PASSWORD: ${{ secrets.GPG_PASSPHRASE }}

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
name: Release ${{ steps.version.outputs.version }}
draft: false
prerelease: false
files: |
build/libs/smithy-unison-*.jar
body: |
## smithy-unison v${{ steps.version.outputs.version }}

### Installation

Add to your `smithy-build.json`:
```json
{
"maven": {
"dependencies": [
"io.smithy.unison:smithy-unison:${{ steps.version.outputs.version }}"
]
}
}
```

Or add to your build.gradle.kts:
```kotlin
dependencies {
implementation("io.smithy.unison:smithy-unison:${{ steps.version.outputs.version }}")
}
```
53 changes: 0 additions & 53 deletions examples/aws-demo/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,59 +108,6 @@ scratch/main> load generated/aws_s3_client.u
scratch/main> add
\`\`\`

Create namespace aliases so main.u can use lib.f34nk_aws_0_1_2 imports:

\`\`\`ucm
scratch/main> alias.type Config lib.f34nk_aws_0_1_2.Config
scratch/main> alias.type Credentials lib.f34nk_aws_0_1_2.Credentials
scratch/main> alias.type ListBucketsRequest lib.f34nk_aws_0_1_2.ListBucketsRequest
scratch/main> alias.type ListBucketsOutput lib.f34nk_aws_0_1_2.ListBucketsOutput
scratch/main> alias.type Bucket lib.f34nk_aws_0_1_2.Bucket
scratch/main> alias.type PutObjectRequest lib.f34nk_aws_0_1_2.PutObjectRequest
scratch/main> alias.type PutObjectOutput lib.f34nk_aws_0_1_2.PutObjectOutput
scratch/main> alias.type ListObjectsV2Request lib.f34nk_aws_0_1_2.ListObjectsV2Request
scratch/main> alias.type ListObjectsV2Output lib.f34nk_aws_0_1_2.ListObjectsV2Output
scratch/main> alias.type Object lib.f34nk_aws_0_1_2.Object
scratch/main> alias.type GetObjectRequest lib.f34nk_aws_0_1_2.GetObjectRequest
scratch/main> alias.type GetObjectOutput lib.f34nk_aws_0_1_2.GetObjectOutput
scratch/main> alias.type DeleteObjectRequest lib.f34nk_aws_0_1_2.DeleteObjectRequest
scratch/main> alias.type DeleteObjectOutput lib.f34nk_aws_0_1_2.DeleteObjectOutput
\`\`\`

\`\`\`ucm
scratch/main> alias.term objectCannedACLFromText lib.f34nk_aws_0_1_2.objectCannedACLFromText
scratch/main> alias.term listBuckets lib.f34nk_aws_0_1_2.listBuckets
scratch/main> alias.term putObject lib.f34nk_aws_0_1_2.putObject
scratch/main> alias.term listObjectsV2 lib.f34nk_aws_0_1_2.listObjectsV2
scratch/main> alias.term getObject lib.f34nk_aws_0_1_2.getObject
scratch/main> alias.term deleteObject lib.f34nk_aws_0_1_2.deleteObject
\`\`\`

Alias constructors:

\`\`\`ucm
scratch/main> alias.term Credentials.Credentials lib.f34nk_aws_0_1_2.Credentials.Credentials
scratch/main> alias.term Config.Config lib.f34nk_aws_0_1_2.Config.Config
scratch/main> alias.term ListBucketsRequest.ListBucketsRequest lib.f34nk_aws_0_1_2.ListBucketsRequest.ListBucketsRequest
scratch/main> alias.term PutObjectRequest.PutObjectRequest lib.f34nk_aws_0_1_2.PutObjectRequest.PutObjectRequest
scratch/main> alias.term ListObjectsV2Request.ListObjectsV2Request lib.f34nk_aws_0_1_2.ListObjectsV2Request.ListObjectsV2Request
scratch/main> alias.term GetObjectRequest.GetObjectRequest lib.f34nk_aws_0_1_2.GetObjectRequest.GetObjectRequest
scratch/main> alias.term DeleteObjectRequest.DeleteObjectRequest lib.f34nk_aws_0_1_2.DeleteObjectRequest.DeleteObjectRequest
\`\`\`

Alias record accessors:

\`\`\`ucm
scratch/main> alias.term Bucket.name lib.f34nk_aws_0_1_2.Bucket.name
scratch/main> alias.term Config.endpoint lib.f34nk_aws_0_1_2.Config.endpoint
scratch/main> alias.term Config.region lib.f34nk_aws_0_1_2.Config.region
scratch/main> alias.term Object.key lib.f34nk_aws_0_1_2.Object.key
scratch/main> alias.term Object.size lib.f34nk_aws_0_1_2.Object.size
scratch/main> alias.term ListBucketsOutput.buckets lib.f34nk_aws_0_1_2.ListBucketsOutput.buckets
scratch/main> alias.term ListObjectsV2Output.contents lib.f34nk_aws_0_1_2.ListObjectsV2Output.contents
scratch/main> alias.term GetObjectOutput.body lib.f34nk_aws_0_1_2.GetObjectOutput.body
\`\`\`

Load the main application:

\`\`\`ucm
Expand Down
9 changes: 7 additions & 2 deletions examples/aws-demo/smithy-build.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"version": "1.0",
"sources": ["model"],
"sources": [
"model"
],
"maven": {
"dependencies": [
"software.amazon.smithy:smithy-model:1.64.0",
"software.amazon.smithy:smithy-aws-traits:1.64.0",
"software.amazon.smithy:smithy-aws-endpoints:1.64.0",
"software.amazon.smithy:smithy-aws-smoke-test-model:1.64.0",
"software.amazon.smithy:smithy-aws-iam-traits:1.64.0",
"io.smithy.unison:smithy-unison:0.1.0"
],
"repositories": [
Expand All @@ -19,6 +23,7 @@
"plugins": {
"unison-codegen": {
"service": "com.amazonaws.s3#AmazonS3",
"name": "s3",
"namespace": "aws.s3",
"outputDir": "generated"
}
Expand Down
61 changes: 26 additions & 35 deletions examples/aws-demo/src/main.u
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@
-- load aws_http_bridge.u
-- add

-- Import types from @f34nk/aws library (use statements are file-scoped in Unison)
use lib.f34nk_aws_0_1_2 Config Credentials
use lib.f34nk_aws_0_1_2 ListBucketsRequest ListBucketsOutput Bucket
use lib.f34nk_aws_0_1_2 PutObjectRequest PutObjectOutput objectCannedACLFromText
use lib.f34nk_aws_0_1_2 ListObjectsV2Request ListObjectsV2Output Object
use lib.f34nk_aws_0_1_2 GetObjectRequest GetObjectOutput
use lib.f34nk_aws_0_1_2 DeleteObjectRequest DeleteObjectOutput
use lib.f34nk_aws_0_1_2 listBuckets putObject listObjectsV2 getObject deleteObject

-- =============================================================================
-- Helpers
-- =============================================================================
Expand All @@ -32,14 +23,14 @@ envOrDefault name default = do
-- =============================================================================

-- Create S3 client configuration for LocalStack
defaultConfig : '{IO, Exception} Config
defaultConfig : '{IO, Exception} Aws.S3.Config
defaultConfig = do
key = !(envOrDefault "AWS_ACCESS_KEY_ID" "dummy")
secret = !(envOrDefault "AWS_SECRET_ACCESS_KEY" "dummy")
creds = Credentials.Credentials key secret None
endpoint = !(envOrDefault "AWS_ENDPOINT" "http://localhost:4566")
region = !(envOrDefault "AWS_DEFAULT_REGION" "us-east-1")
Config.Config endpoint region creds true
Aws.S3.Config.Config endpoint region creds true

-- Test bucket name - created by terraform provisioner in docker-compose
testBucket : Text
Expand Down Expand Up @@ -134,20 +125,20 @@ runDemo = do
List all buckets in the account.
The terraform provisioner creates 'us-east-1-nonprod-configs' bucket.
}}
listBucketsDemo : Config -> '{IO, Exception, Threads} ()
listBucketsDemo : Aws.S3.Config -> '{IO, Exception, Threads} ()
listBucketsDemo config = do
printLine " → Creating ListBucketsRequest..."

-- Create request with all optional fields as None
request = ListBucketsRequest.ListBucketsRequest None None None None
request = Aws.S3.ListBucketsRequest.ListBucketsRequest None None None None

-- Call the S3 client
printLine " → Calling listBuckets..."
result = !(listBuckets config request)
result = !(Aws.S3.listBuckets config request)

-- Extract and print buckets
printLine " ✓ SUCCESS: ListBuckets returned"
match ListBucketsOutput.buckets result with
match Aws.S3.ListBucketsOutput.buckets result with
Some buckets ->
count = List.size buckets
printLine (" → Found " ++ Nat.toText count ++ " bucket(s):")
Expand All @@ -158,7 +149,7 @@ listBucketsDemo config = do
{{
Upload a test object to the configs bucket.
}}
putObjectDemo : Config -> '{IO, Exception, Threads} ()
putObjectDemo : Aws.S3.Config -> '{IO, Exception, Threads} ()
putObjectDemo config = do
printLine (" → Creating PutObjectRequest...")
printLine (" Bucket: " ++ testBucket)
Expand All @@ -170,37 +161,37 @@ putObjectDemo config = do
-- PutObjectRequest with minimal required fields (41 fields)
-- Field order: aCL body bucket bucketKeyEnabled cacheControl checksumAlgorithm ...
-- Set ACL to public-read so we can read the object back
acl = objectCannedACLFromText "public-read"
acl = Aws.S3.objectCannedACLFromText "public-read"
request = PutObjectRequest.PutObjectRequest acl body testBucket None None None None None None None None None None None None None (Some "text/plain") None None None None None None None None testObjectKey None None None None None None None None None None None None None None None

-- Call the S3 client
printLine " → Calling putObject..."
result = !(putObject config request)
result = !(Aws.S3.putObject config request)

printLine " ✓ SUCCESS: PutObject completed"
-- Print ETag if available
match PutObjectOutput.eTag result with
match Aws.S3.PutObjectOutput.eTag result with
Some etag -> printLine (" ETag: " ++ etag)
None -> ()

{{
List objects in the configs prefix.
}}
listObjectsV2Demo : Config -> '{IO, Exception, Threads} ()
listObjectsV2Demo : Aws.S3.Config -> '{IO, Exception, Threads} ()
listObjectsV2Demo config = do
printLine " → Creating ListObjectsV2Request..."
printLine (" Bucket: " ++ testBucket)
printLine (" Prefix: configs/")

-- ListObjectsV2Request (11 fields)
request = ListObjectsV2Request.ListObjectsV2Request testBucket None None None None None (Some +100) None (Some "configs/") None None
request = Aws.S3.ListObjectsV2Request.ListObjectsV2Request testBucket None None None None None (Some +100) None (Some "configs/") None None

-- Call the S3 client
printLine " → Calling listObjectsV2..."
result = !(listObjectsV2 config request)
result = !(Aws.S3.listObjectsV2 config request)

printLine " ✓ SUCCESS: ListObjectsV2 returned"
match ListObjectsV2Output.contents result with
match Aws.S3.ListObjectsV2Output.contents result with
Some objects ->
count = List.size objects
printLine (" → Found " ++ Nat.toText count ++ " object(s):")
Expand All @@ -211,21 +202,21 @@ listObjectsV2Demo config = do
{{
Get the test object we uploaded.
}}
getObjectDemo : Config -> '{IO, Exception, Threads} ()
getObjectDemo : Aws.S3.Config -> '{IO, Exception, Threads} ()
getObjectDemo config = do
printLine " → Creating GetObjectRequest..."
printLine (" Bucket: " ++ testBucket)
printLine (" Key: " ++ testObjectKey)

-- GetObjectRequest (21 fields)
request = GetObjectRequest.GetObjectRequest testBucket None None None None None None testObjectKey None None None None None None None None None None None None None
request = Aws.S3.GetObjectRequest.GetObjectRequest testBucket None None None None None None testObjectKey None None None None None None None None None None None None None

-- Call the S3 client
printLine " → Calling getObject..."
result = !(getObject config request)
result = !(Aws.S3.getObject config request)

-- Extract and print body
body = GetObjectOutput.body result
body = Aws.S3.GetObjectOutput.body result
bodyText = fromUtf8 body

printLine " ✓ SUCCESS: GetObject returned"
Expand All @@ -240,42 +231,42 @@ getObjectDemo config = do
{{
Delete the test object (cleanup).
}}
deleteObjectDemo : Config -> '{IO, Exception, Threads} ()
deleteObjectDemo : Aws.S3.Config -> '{IO, Exception, Threads} ()
deleteObjectDemo config = do
printLine " → Creating DeleteObjectRequest..."
printLine (" Bucket: " ++ testBucket)
printLine (" Key: " ++ testObjectKey)

-- DeleteObjectRequest (10 fields)
request = DeleteObjectRequest.DeleteObjectRequest testBucket None None None None None testObjectKey None None None
request = Aws.S3.DeleteObjectRequest.DeleteObjectRequest testBucket None None None None None testObjectKey None None None

-- Call the S3 client
printLine " → Calling deleteObject..."
result = !(deleteObject config request)
result = !(Aws.S3.deleteObject config request)

printLine " ✓ SUCCESS: DeleteObject completed"
-- Print delete marker if versioned
match DeleteObjectOutput.deleteMarker result with
match Aws.S3.DeleteObjectOutput.deleteMarker result with
Some true -> printLine " Delete marker created (versioned bucket)"
_ -> ()

{{
Verify the test object was deleted by listing objects.
}}
verifyDeletionDemo : Config -> '{IO, Exception, Threads} ()
verifyDeletionDemo : Aws.S3.Config -> '{IO, Exception, Threads} ()
verifyDeletionDemo config = do
printLine " → Listing objects after deletion..."
printLine (" Bucket: " ++ testBucket)
printLine (" Prefix: configs/")

-- ListObjectsV2Request (11 fields)
request = ListObjectsV2Request.ListObjectsV2Request testBucket None None None None None (Some +100) None (Some "configs/") None None
request = Aws.S3.ListObjectsV2Request.ListObjectsV2Request testBucket None None None None None (Some +100) None (Some "configs/") None None

-- Call the S3 client
result = !(listObjectsV2 config request)
result = !(Aws.S3.listObjectsV2 config request)

printLine " ✓ SUCCESS: ListObjectsV2 returned"
match ListObjectsV2Output.contents result with
match Aws.S3.ListObjectsV2Output.contents result with
Some objects ->
count = List.size objects
printLine (" → Found " ++ Nat.toText count ++ " object(s):")
Expand Down
2 changes: 1 addition & 1 deletion generate-aws-sdk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ build: init
# Build AWS SDK models
#
./generate.py
tree -h output/*/src
tree -h output/*/generated

.PHONY: clean
clean:
Expand Down
Loading