-
Notifications
You must be signed in to change notification settings - Fork 56
105 lines (99 loc) · 3.32 KB
/
CI.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: CI
on:
push:
branches:
- master
tags:
- 'release-*'
paths:
- 'luci-app-wrtbwmon/**'
pull_request:
branches:
- master
workflow_dispatch:
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: ghcr.io/openwrt/sdk:x86-64-23.05-SNAPSHOT
options: --user root
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Build
working-directory: /builder
run: |
sed \
-e 's,git\.openwrt\.org/feed/,github.com/openwrt/,' \
-e 's,git\.openwrt\.org/openwrt/,github.com/openwrt/,' \
-e 's,git\.openwrt\.org/project/,github.com/openwrt/,' \
feeds.conf.default | grep -Ev "^src-git(-full)? (routing|telephony) .*" > feeds.conf
echo "src-cpy local ${GITHUB_WORKSPACE}" >> feeds.conf
./scripts/feeds update -f luci local
./scripts/feeds install -p local luci-app-wrtbwmon
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/*/*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/*/*wrtbwmon*
if-no-files-found: error
- name: Upload Log
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: buildlog
path: /builder/logs.tar.xz