diff --git a/.editorconfig b/.editorconfig index ba599b24..99156ecd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -57,6 +57,9 @@ csharp_new_line_before_members_in_anonymous_types = true [*.csproj] indent_size = 2 +[*.js] +indent_size = 2 + [*.json] indent_size = 2 diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 129ff424..6ff18e5d 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -16,7 +16,7 @@ jobs: - uses: actions/setup-dotnet@v4 with: dotnet-version: 8.x - - run: build\build.ps1 + - run: scripts\build.ps1 - uses: actions/upload-artifact@v4 with: name: nuget @@ -28,6 +28,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/v') runs-on: windows-latest steps: + - uses: actions/checkout@v4 - uses: actions/setup-dotnet@v4 - uses: actions/download-artifact@v4 with: @@ -37,16 +38,5 @@ jobs: - uses: actions/github-script@v7 with: script: | - const owner = context.repo.owner; - const repo = context.repo.repo; - const tag_name = context.ref.replace(/refs\/tags\//, ''); - - github.rest.repos.createRelease({ - owner, - repo, - tag_name, - name: "Release " + tag_name, - body: "TODO", - draft: true, - }); - + const script = require('./scripts/create-release.js') + script({github, context}) diff --git a/build/build.ps1 b/scripts/build.ps1 similarity index 100% rename from build/build.ps1 rename to scripts/build.ps1 diff --git a/scripts/create-release.js b/scripts/create-release.js new file mode 100644 index 00000000..31514991 --- /dev/null +++ b/scripts/create-release.js @@ -0,0 +1,36 @@ +const fs = require("fs").promises; +const path = require("path"); + +const ARTIFACTS_PATH = "./artifacts"; + +const createRelease = async ({github, context}) => { + const owner = context.repo.owner; + const repo = context.repo.repo; + const tag_name = context.ref.replace(/refs\/tags\//, ''); + + const res = github.rest.repos.createRelease({ + owner, + repo, + tag_name, + name: "Release " + tag_name, + body: "TODO", + draft: true, + }); + + const artifacts = await fs.readdir(ARTIFACTS_PATH); + + for (let artifact of artifacts) { + const artifactPath = path.join(ARTIFACTS_PATH, artifact); + const data = await fs.readFile(artifactPath); + + await github.rest.repos.uploadReleaseAsset({ + owner, + repo, + release_id: res.data.id, + name: artifact, + data + }); + } +} + +module.exports = createRelease;