From 4b6bce93eb31809e003ea8c4ba815126f184015a Mon Sep 17 00:00:00 2001 From: Dom Date: Fri, 20 Sep 2024 00:13:39 +0200 Subject: [PATCH] Try using existing action for releasing update files --- .github/workflows/release.yml | 63 ++++------------------------------- 1 file changed, 6 insertions(+), 57 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 55452b7..e4fcce9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,64 +79,13 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: upload update.json - uses: actions/github-script@v7 - env: - FILES: build/update*.json - ARTEFACT_NAME_INPUT: "${{ inputs.artefactName }}" - RELEASE_TAG: 'update' + uses: meeDamian/github-release@2.0 with: - debug: true - script: | - const path = require('path'); - const fs = require('fs'); - const os = require('os'); - - const __dirname = path.resolve() - - console.log('searching for release...') - var { data: release } = await github.rest.repos.getReleaseByTag({ - owner: context.repo.owner, - repo: context.repo.repo, - tag: process.env.RELEASE_TAG, - }); - - console.log("found release " + release.name) - - console.log('doing globbing option'); - const globOptions = { - followSymbolicLinks: 'FALSE' - } - const files = process.env.FILES.split(os.EOL); - const globber = await glob.create(files.join('\n'), globOptions) - - for await (const file of globber.globGenerator()) { - console.log(file) - fs.readFile(file, 'utf8', (err, data) => { - if (err) { - console.error(err); - return; - } - - const fileName = file.split("/").pop(); - const asset = release.assets.filter(asset=>asset.name == fileName); - if(asset.length > 0){ - github.rest.repos.deleteReleaseAsset({ - owner: context.repo.owner, - repo: context.repo.repo, - asset_id: asset.id - }); - } - - console.log('write to '+ release.id) - github.rest.repos.uploadReleaseAsset({ - owner: context.repo.owner, - repo: context.repo.repo, - release_id: release.id, - name: fileName, - data: data - }); - }); - } + token: ${{ secrets.GITHUB_TOKEN }} + tag: update + files: build/update*.json + allow_override: true + - name: Notify release uses: apexskier/github-release-commenter@v1