-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (154 loc) · 5.42 KB
/
build.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: Build packages
on:
release:
types: [created]
# pull_request:
# branches: [main]
# types: [opened]
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'info'
type: choice
options:
- info
- warning
- debug
jobs:
build-deb:
name: Build deb ${{ matrix.package }} ${{ matrix.arch.name }}
runs-on: ${{ matrix.arch.image }}
permissions:
contents: write
strategy:
matrix:
arch:
- image: ubuntu-24.04
name: amd64
- image: ubuntu-24.04-arm
name: arm64
- image: ubuntu-24.04-arm
name: arm
package:
- phonebook
env:
GOOS: "linux"
GOARCH: "${{ matrix.arch.name }}"
GOARM: "7"
CGO_ENABLED: "0"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout source
id: checkout_source
uses: actions/checkout@v4
with:
repository: arednch/phonebook
path: phonebook-repo
- name: Get version
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
else
VERSION='main'
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
cache: false
go-version: ">=1.24.1"
- name: Build Go binary
run: |
cd phonebook-repo
go build -v -ldflags="-s -w -X 'main.CommitSHA=${{ steps.checkout_source.outputs.commit }}' -X 'main.Version=${{ steps.get_version.outputs.version }}'" -o phonebook .
- name: Build .deb
run: |
mkdir -p phonebook-deb/usr/bin
cp -fr phonebook-repo/phonebook phonebook-deb/usr/bin/phonebook
dpkg-deb --build --root-owner-group phonebook-deb
mv phonebook-deb.deb phonebook-${{ matrix.arch.name }}.deb
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package }}-${{ matrix.arch.name }}-package
compression-level: 0 # no compression
path: |
*.deb
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: ${{ github.event.release.tag_name }}
tag_name: ${{ github.event.release.tag_name }}
body: ${{ github.event.release.body }}
prerelease: ${{ github.event.release.prerelease }}
draft: ${{ github.event.release.draft }}
files: |
*.deb
build-aredn:
name: Build ${{ matrix.package }} ${{ matrix.arch }} ${{ matrix.openwrt }}
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
openwrt:
- main # APK packages going forward
- openwrt-24.10 # IPK packages built using an older version
arch:
- x86_64
- mips_24kc
- arm_cortex-a7_neon-vfpv4
package:
- phonebook
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
uses: openwrt/gh-action-sdk@main
env:
ARCH: ${{ matrix.arch }}-${{ matrix.openwrt }}
FEEDNAME: aredn
EXTRA_FEEDS: "src-git|upx|https://github.com/kuoruan/openwrt-upx.git"
PACKAGES: ${{ matrix.package }}
V: sc
- name: Move created IPK packages to project dir with tag
if: ${{ matrix.openwrt != 'main' && github.event.release.tag_name != '' }}
run: |
cp bin/packages/${{ matrix.arch }}/aredn/${{ matrix.package }}*.ipk ./${{ matrix.package }}-${{ github.event.release.tag_name }}-${{ matrix.arch }}.ipk || true
- name: Move created IPK packages to project dir without tag
if: ${{ matrix.openwrt != 'main' && github.event.release.tag_name == '' }}
run: |
cp bin/packages/${{ matrix.arch }}/aredn/${{ matrix.package }}*.ipk ./${{ matrix.package }}-${{ matrix.arch }}.ipk || true
- name: Move created APK packages to project dir with tag
if: ${{ matrix.openwrt == 'main' && github.event.release.tag_name != '' }}
run: |
cp bin/packages/${{ matrix.arch }}/aredn/${{ matrix.package }}*.apk ./${{ matrix.package }}-${{ github.event.release.tag_name }}-${{ matrix.arch }}.apk || true
- name: Move created APK packages to project dir without tag
if: ${{ matrix.openwrt == 'main' && github.event.release.tag_name == '' }}
run: |
cp bin/packages/${{ matrix.arch }}/aredn/${{ matrix.package }}*.apk ./${{ matrix.package }}-${{ matrix.arch }}.apk || true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package }}-${{ matrix.arch }}-${{ matrix.openwrt }}-package
compression-level: 0 # no compression
path: |
*.ipk
*.apk
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
name: ${{ github.event.release.tag_name }}
tag_name: ${{ github.event.release.tag_name }}
body: ${{ github.event.release.body }}
prerelease: ${{ github.event.release.prerelease }}
draft: ${{ github.event.release.draft }}
files: |
*.ipk
*.apk