Skip to content

Commit

Permalink
ci: setup release gh workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Oct 31, 2023
1 parent a85db8e commit f3ebb10
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 6 deletions.
28 changes: 22 additions & 6 deletions .fluentci/src/dagger/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ export const test = async (
export const compile = async (
src = ".",
file = "main.ts",
output = "main",
output = "repl",
target = "x86_64-unknown-linux-gnu"
) => {
let result = "";
await connect(async (client) => {
const context = client.host().directory(src);
let command = [
Expand All @@ -130,7 +129,7 @@ export const compile = async (
"--output",
output,
"--target",
target,
Deno.env.get("TARGET") || target,
file,
];

Expand All @@ -139,17 +138,34 @@ export const compile = async (
}

const ctr = baseCtr(client, Job.fmt)
.withMountedCache("/assets", client.cacheVolume("gh-release-assets"))
.withDirectory("/app", context, {
exclude,
})
.withWorkdir("/app")
.withExec(command)
.withExec(["ls", "-ltr", "."]);
.withExec(["ls", "-ltr", "."])
.withExec([
"tar",
"czvf",
`/assets/${output}_${Deno.env.get("TAG") || ""}_${
Deno.env.get("TARGET") || target
}.tar.gz`,
output,
])
.withExec([
"sh",
"-c",
`shasum -a 256 /assets/${output}_${Deno.env.get("TAG") || ""}_${
Deno.env.get("TARGET") || target
}.tar.gz > /assets/${output}_${
Deno.env.get("TAG") || ""
}_${Deno.env.get("TARGET" || target)}.tar.gz.sha256`,
]);

await ctr.file(`/app/${output}`).export(`./${output}`);

result = await ctr.stdout();
console.log(result);
await ctr.stdout();
});

return "Done";
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: release
on:
release:
types: [created]

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
extensions:
- tar.gz
- tar.gz.sha256
target:
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
- aarch64-apple-darwin
steps:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: v1.37
- name: Setup Fluent CI CLI
run: deno install -A -r https://cli.fluentci.io -n fluentci
- name: Setup Dagger
run: |
curl -L https://dl.dagger.io/dagger/install.sh | DAGGER_VERSION=0.8.8 sh
sudo mv bin/dagger /usr/local/bin
dagger version
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Build
run: fluentci run . compile
env:
TAG: ${{ env.RELEASE_VERSION }}
TARGET: ${{ matrix.target }}
- name: Upload release assets
run: fluentci run github_pipeline release_upload
env:
TAG: ${{ env.RELEASE_VERSION }}
FILE: /assets/repl_${{ env.RELEASE_VERSION }}_${{ matrix.target }}.${{ matrix.extensions }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit f3ebb10

Please sign in to comment.