Fix percentage calculation (#70) #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- 'release-*' | |
paths: | |
- 'luci-app-wrtbwmon/**' | |
pull_request: | |
branches: | |
- master | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build the IPK | |
runs-on: ubuntu-latest | |
container: | |
image: openwrt/sdk:x86-64-22.03-SNAPSHOT | |
options: --user root | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
- name: Docker Build | |
working-directory: /builder | |
run: | | |
cp -rf ${GITHUB_WORKSPACE}/luci-app-wrtbwmon ./package | |
sed -i 's/git\.openwrt\.org\/project\/luci/github\.com\/openwrt\/luci/g' ./feeds.conf.default | |
./scripts/feeds update luci | |
./scripts/feeds install luci | |
make defconfig | |
make package/luci-app-wrtbwmon/compile V=sc -j$(nproc) BUILD_LOG=1 | |
tar -cJf logs.tar.xz logs | |
- name: Release | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/release-') | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const tag = context.ref.replace("refs/tags/", ""); | |
try { | |
// Get release for this tag | |
const release = await github.rest.repos.getReleaseByTag({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag: tag, | |
}); | |
// Delete obsolete release | |
await github.rest.repos.deleteRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: release.data.id, | |
}); | |
} | |
catch(err) { | |
console.log(err); | |
} | |
finally { | |
// Create release for this tag | |
const release = await github.rest.repos.createRelease({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
tag_name: tag, | |
draft: false, | |
prerelease: true, | |
}); | |
// 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 | |
with: | |
name: luci-app-wrtbwmon | |
path: /builder/bin/packages/x86_64/base/*wrtbwmon* | |
if-no-files-found: error | |
- name: Upload Log | |
if: ${{ always() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: buildlog | |
path: /builder/logs.tar.xz |