add github workflow

This commit is contained in:
Tyr Chen 2023-11-26 21:25:11 -08:00
parent 53d2956001
commit 0aa2231398
No known key found for this signature in database
GPG Key ID: FA69377479FE142A
4 changed files with 176 additions and 10 deletions

41
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,41 @@
name: build
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Smithy
run: |
mkdir -p /tmp/smithy
curl -L https://github.com/smithy-lang/smithy/releases/download/1.41.1/smithy-cli-linux-x86_64.tar.gz -o /tmp/smithy-cli-linux.tar.gz
tar xvzf /tmp/smithy-cli-linux.tar.gz -C /tmp/smithy
/tmp/smithy/install
- name: build smithy plugins
run: |
cd $GITHUB_WORKSPACE/rust && ./gradlew publishToMavenLocal
cd $GITHUB_WORKSPACE/python/codegen && ./gradlew publishToMavenLocal
cd $GITHUB_WORKSPACE/swift && ./gradlew publishToMavenLocal
cd $GITHUB_WORKSPACE/typescript && ./gradlew publishToMavenLocal
- name: make sure smithy build works
run: |
cd $GITHUB_WORKSPACE && smithy build
- name: compress .m2 directory
run: |
cd ${{ runner.home }} && tar -czf assets.tar.gz .m2
- name: Release with assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
${{ runner.home }}/assets.tar.gz

View File

@ -1,16 +1,37 @@
FROM 8.4.0-jdk17-alpine # stage 1
FROM openjdk:17-jdk-slim AS build
ARG arch=x86_64
RUN apt-get -y update; apt-get -y install curl
RUN mkdir -p /tmp/smithy && \ RUN mkdir -p /tmp/smithy && \
curl -L https://github.com/smithy-lang/smithy/releases/download/1.41.1/smithy-cli-linux-x86_64.tar.gz -o /tmp/smithy-cli-linux-x86_64.tar.gz && \ curl -L https://github.com/smithy-lang/smithy/releases/download/1.41.1/smithy-cli-linux-$arch.tar.gz -o /tmp/smithy-cli-linux-$arch.tar.gz && \
tar xvzf /tmp/smithy-cli-linux-x86_64.tar.gz -C /tmp/smithy tar xvzf /tmp/smithy-cli-linux-$arch.tar.gz -C /tmp/smithy
RUN sudo /tmp/smithy/install && rm -rf /tmp/smithy
ADD . /tmp ADD . /tmp
RUN /tmp/rust/gradlew publishToMavenLocal RUN /tmp/smithy/install
RUN /tmp/python/gradlew publishToMavenLocal
RUN /tmp/swift/gradlew publishToMavenLocal
RUN /tmp/typescript/gradlew publishToMavenLocal
RUN rm -rf /tmp/* RUN cd /tmp/rust && ./gradlew publishToMavenLocal
RUN cd /tmp/python/codegen && ./gradlew publishToMavenLocal
RUN cd /tmp/swift && ./gradlew publishToMavenLocal
RUN cd /tmp/typescript && ./gradlew publishToMavenLocal
RUN cd /tmp && smithy build
# stage 2
FROM openjdk:17-jdk-slim
COPY --from=build /root/.m2 /root/.m2
COPY --from=build /tmp/smithy /tmp/smithy
RUN /tmp/smithy/install
COPY --from=build /tmp/smithy-build.json /root/smithy-build.json
COPY --from=build /tmp/model /root/model

27
model/main.smithy Normal file
View File

@ -0,0 +1,27 @@
$version: "2.0"
namespace com.example
use aws.protocols#restJson1
use smithy.framework#ValidationException
/// Echoes input
@restJson1
service EchoService {
version: "2006-03-01"
operations: [EchoMessage]
}
@http(uri: "/echo", method: "POST")
operation EchoMessage {
input := {
@required
@httpHeader("x-echo-message")
message: String
}
output := {
@required
message: String
}
errors: [ValidationException]
}

77
smithy-build.json Normal file
View File

@ -0,0 +1,77 @@
{
"version": "1.0",
"sources": [
"model"
],
"maven": {
"dependencies": [
"software.amazon.smithy:smithy-model:[1.41.0,2.0)",
"software.amazon.smithy:smithy-validation-model:[1.41.0,2.0)",
"software.amazon.smithy:smithy-aws-traits:[1.41.0,2.0)",
"software.amazon.smithy:smithy-openapi:1.41.1",
"software.amazon.smithy.python:smithy-python-codegen:0.1.0",
"software.amazon.smithy.typescript:smithy-typescript-codegen:0.19.0",
"software.amazon.smithy:smithy-swift-codegen:0.1.0",
"software.amazon.smithy.kotlin:smithy-kotlin-codegen:0.30.2-SNAPSHOT",
"software.amazon.smithy.rust.codegen:codegen-client:0.1.0",
"software.amazon.smithy.rust.codegen.server.smithy:codegen-server:0.1.0"
]
},
"plugins": {
"openapi": {
"service": "com.example#EchoService",
"version": "3.1.0"
},
"rust-server-codegen": {
"service": "com.example#EchoService",
"module": "echo-server-sdk",
"moduleDescription": "Rust server SDK for echo server",
"moduleVersion": "0.1.0",
"moduleAuthors": [
"Tyr Chen <tchen@abc.xyz>"
],
"runtimeConfig": {
"versions": {
"DEFAULT": "1.0.1",
"aws-smithy-http": "0.60.0",
"aws-smithy-json": "0.60.0",
"aws-smithy-http-server": "0.60.0"
}
}
},
"python-client-codegen": {
"service": "com.example#EchoService",
"module": "echo",
"moduleVersion": "0.0.1"
},
"typescript-client-codegen": {
"package": "echo",
"packageVersion": "0.0.1"
},
"swift-codegen": {
"service": "com.example#EchoService",
"module": "echo",
"moduleVersion": "0.0.1",
"homepage": "https://github.com/tyrchen",
"gitRepo": "https://github.com/tyrchen",
"author": "Tyr Chen <tchen@abc.xyz>",
"swiftVersion": "5.0"
},
"rust-client-codegen": {
"service": "com.example#EchoService",
"module": "echo-client-sdk",
"moduleDescription": "Rust client SDK for echo service",
"moduleVersion": "0.1.0",
"moduleAuthors": [
"Tyr Chen <tchen@abc.xyz>"
],
"runtimeConfig": {
"versions": {
"DEFAULT": "1.0.1",
"aws-smithy-http": "0.60.0",
"aws-smithy-json": "0.60.0"
}
}
}
}
}