Skip to content

Commit

Permalink
Try using existing action for releasing update files
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic-DallOsto committed Sep 19, 2024
1 parent 8603b03 commit 4b6bce9
Showing 1 changed file with 6 additions and 57 deletions.
63 changes: 6 additions & 57 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4b6bce9

Please sign in to comment.