From 16aa84737eb7c05894098b89295ff9795e2265da Mon Sep 17 00:00:00 2001 From: "AsynchronousMatrix (Jack)" Date: Sun, 30 Jun 2024 01:44:06 +0100 Subject: [PATCH 1/2] ENG-172: add support for publishing SDK to metrik S3 server upon new commit --- .github/workflows/on-commit.yml | 16 ++++++++++++++ .lune/deploy.luau | 37 +++++++++++++++++++++++++++++++++ .vscode/settings.json | 6 +++++- aftman.toml | 1 + 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/on-commit.yml create mode 100644 .lune/deploy.luau diff --git a/.github/workflows/on-commit.yml b/.github/workflows/on-commit.yml new file mode 100644 index 0000000..a9c56c6 --- /dev/null +++ b/.github/workflows/on-commit.yml @@ -0,0 +1,16 @@ +on: + push: + branches: [ "*" ] + +jobs: + upload-artifact: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: ok-nick/setup-aftman@v0.4.2 + - name: Build artifact dependencies + run: wally install + - name: Build artifact + run: rojo build default.project.json -o Artifact.rbxm + - name: Deploy artifact + run: lune run deploy Artifact.rbxm \ No newline at end of file diff --git a/.lune/deploy.luau b/.lune/deploy.luau new file mode 100644 index 0000000..f567a7f --- /dev/null +++ b/.lune/deploy.luau @@ -0,0 +1,37 @@ +local process = require("@lune/process") +local net = require("@lune/net") +local fs = require("@lune/fs") + +local artifact = process.args[1] +local commitHash = process.env.GITHUB_SHA +local authorization = process.env.SDK_ARTIFACT_UPLOAD_SECRET + +local multiformUuid = `SDK_WORKFLOW.{math.random()}` +local multiformContentBoundary = `{multiformUuid}` +local multiformContent = "" + +multiformContent ..= `--{multiformContentBoundary}\r\n` +multiformContent ..= `Content-Disposition: form-data; name="commitHash"\r\n` +multiformContent ..= `Content-Type: application/json\r\n` + +multiformContent ..= `\r\n` +multiformContent ..= `{commitHash}\r\n` + +multiformContent ..= `--{multiformContentBoundary}\r\n` +multiformContent ..= `Content-Disposition: form-data; name="file"\r\n` +multiformContent ..= `Content-Type: application/octet-stream\r\n` + +multiformContent ..= `\r\n` +multiformContent ..= `{fs.readFile(artifact)}\r\n` + +multiformContent ..= `--{multiformContentBoundary}--\r\n` + +print(net.request({ + url = "https://preview.metrik.app/api/sdk/upload-artifact", + method = "POST", + headers = { + ["Authorization"] = `Bearer {authorization}`, + ["content-type"] = `multipart/form-data; boundary={multiformContentBoundary}` + }, + body = multiformContent +})) \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index ce29214..a22b561 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,7 @@ { - "luau-lsp.sourcemap.rojoProjectFile": "development.project.json" + "luau-lsp.sourcemap.rojoProjectFile": "development.project.json", + "luau-lsp.require.mode": "relativeToFile", + "luau-lsp.require.directoryAliases": { + "@lune/": "~/.lune/.typedefs/0.8.6/" + } } \ No newline at end of file diff --git a/aftman.toml b/aftman.toml index 7459399..3f8bad6 100644 --- a/aftman.toml +++ b/aftman.toml @@ -10,3 +10,4 @@ wally = "UpliftGames/wally@0.3.2" wally-package-types = "JohnnyMorganz/wally-package-types@1.2.1" luaulsp = "JohnnyMorganz/luau-lsp@1.24.1" zap = "red-blox/zap@0.6.3" +lune = "lune-org/lune@0.8.6" From d808d29e931f30a07a207380c1a3efd8b4282974 Mon Sep 17 00:00:00 2001 From: "AsynchronousMatrix (Jack)" Date: Sun, 30 Jun 2024 02:32:29 +0100 Subject: [PATCH 2/2] ENG-172: add 'filename' content header --- .lune/deploy.luau | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.lune/deploy.luau b/.lune/deploy.luau index f567a7f..c333c74 100644 --- a/.lune/deploy.luau +++ b/.lune/deploy.luau @@ -18,7 +18,7 @@ multiformContent ..= `\r\n` multiformContent ..= `{commitHash}\r\n` multiformContent ..= `--{multiformContentBoundary}\r\n` -multiformContent ..= `Content-Disposition: form-data; name="file"\r\n` +multiformContent ..= `Content-Disposition: form-data; name="file"; filename="file.rbxm"\r\n` multiformContent ..= `Content-Type: application/octet-stream\r\n` multiformContent ..= `\r\n`