From 12c6c8bd752070f876743185f9d63bd26df18d75 Mon Sep 17 00:00:00 2001 From: CRGBS <32331418+CRGBS@users.noreply.github.com> Date: Sun, 14 Jul 2024 10:18:27 +0800 Subject: [PATCH] Update NEW_RELEASE.yml --- .github/workflows/NEW_RELEASE.yml | 41 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/NEW_RELEASE.yml b/.github/workflows/NEW_RELEASE.yml index ff246ca6..192623df 100644 --- a/.github/workflows/NEW_RELEASE.yml +++ b/.github/workflows/NEW_RELEASE.yml @@ -61,28 +61,35 @@ jobs: uses: actions/upload-artifact@v3 with: path: /home/runner/work/AccA-release/AccA-release/app/build/outputs/apk/debug/ - name: ${{ env.BRANCH_NAME }}-${{ steps.commit.outputs.short }} + name: apk - - name: Upload release - id: upload_release + + - name: Create Release uses: actions/github-script@v3 with: github-token: ${{secrets.FORBD}} script: | - const path = require('path'); - const fs = require('fs'); - const release_id = '${{ steps.create_release.outputs.id }}'; - for (let file of await fs.readdirSync('./artifact')) { - if (path.extname(file) === '.zip') { - console.log('uploadReleaseAsset', file); - await github.repos.uploadReleaseAsset({ - owner: context.repo.owner, - repo: context.repo.repo, - release_id: release_id, - name: file, - data: await fs.readFileSync(`./artifact/${file}`) - }); - } + console.log('environment', process.versions); + const fs = require('fs').promises; + const { repo: { owner, repo }, sha } = context; + console.log({ owner, repo, sha }); + const release = await github.repos.createRelease({ + owner, repo, + tag_name: process.env.GITHUB_REF, + draft: true, + target_commitish: sha + }); + console.log('created release', { release }); + for (let file of await fs.readdir('.')) { + // do whatever filtering you want here, I'm just uploading all the files + console.log('uploading', file); + await github.repos.uploadReleaseAsset({ + owner, repo, + release_id: release.data.id, + name: file, + data: await fs.readFile(`./${file}`) + }); + } #- name: Releases # uses: softprops/action-gh-release@v1