Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
brvphoenix committed Apr 29, 2023
1 parent 80581c2 commit bce3048
Showing 1 changed file with 41 additions and 10 deletions.
51 changes: 41 additions & 10 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,47 @@ jobs:
tar -cJf logs.tar.xz logs
- name: Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/release-')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
assets=()
for asset in ./bin/packages/x86_64/base/*wrtbwmon*.ipk; do
assets+=("-a" "$asset")
done
tag_name=$(basename ${{github.ref}})
hub release create -p "${assets[@]}" -m "$tag_name" "$tag_name"
uses: actions/github-script@v6
with:
script: |
const tag = context.ref.replace("refs/tags/", "");
let release;
try {
// Get release for this tag
release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tag,
});
// Delete obsolete release
release = await github.rest.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
});
}
finally {
// Create release for this tag
release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: tag,
});
}
// Upload the release asset
const fs = require('fs');
const patterns = ['/builder/bin/packages/x86_64/base/*wrtbwmon*.ipk']
const globber = await glob.create(patterns.join('\n'))
for await (const file of globber.globGenerator()) {
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: file.substr(file.lastIndexOf('/') + 1),
data: await fs.readFileSync(file)
});
}
- name: Upload app
if: ${{ ! (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/release-')) }}
uses: actions/upload-artifact@v3
Expand Down

0 comments on commit bce3048

Please sign in to comment.