This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
138 lines (120 loc) · 3.65 KB
/
build.yml
File metadata and controls
138 lines (120 loc) · 3.65 KB
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
name: Build
on:
workflow_dispatch:
push:
tags:
- "*"
jobs:
generate_matrix:
name: Set matrix
runs-on: ubuntu-latest
outputs:
sdks: ${{ steps.out.outputs.sdks }}
strategy:
matrix:
ref:
- main # apk
- openwrt-23.05 # ipk
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: openwrt/openwrt
ref: ${{ matrix.ref }}
- name: Set targets
id: find_targets
run: |
REF=${{ matrix.ref }}
# sdks
JSON='['
FIRST=1
while read -r line;
do
ARCH=$(echo "$line" | cut -d " " -f 1)
[[ $FIRST -ne 1 ]] && JSON="$JSON"','
FIRST=0
JSON="$JSON"'{"arch":"'"$ARCH"'","ref":"'"$REF"'"}'
done <<< $(perl ./scripts/dump-target-info.pl architectures 2>/dev/null)
JSON="$JSON"']'
echo -e "\n---- sdks ----\n"
echo "$JSON"
echo -e "\n---- sdks ----\n"
echo "sdks=$JSON" >> "$GITHUB_OUTPUT"
- uses: cloudposse/github-action-matrix-outputs-write@main
id: out
with:
matrix-step-name: ${{ github.job }}
matrix-key: ${{ matrix.ref }}
outputs: |-
sdks: ${{ steps.find_targets.outputs.sdks }}
gather_matrix:
name: Gather build matrices
runs-on: ubuntu-latest
needs: generate_matrix
outputs:
result: ${{ steps.gather.outputs.result }}
steps:
- uses: cloudposse/github-action-matrix-outputs-read@main
id: read
with:
matrix-step-name: generate_matrix
- name: Gather matrices
id: gather
run: |
result=$(jq -c '.sdks[]' <<< '${{ steps.read.outputs.result }}' | jq -c -s add)
echo "result=${result}" >> $GITHUB_OUTPUT
build:
name: Build for ${{ matrix.arch }}-${{ matrix.ref }}
runs-on: ubuntu-latest
needs: gather_matrix
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.gather_matrix.outputs.result) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Fetch Cloudflared makefile
run: |
sha=$(cat .nvchecker/sha)
curl "https://codeload.github.com/openwrt/packages/tar.gz/$sha" | \
tar -xz --strip=2 "packages-$sha/net/cloudflared"
sed -i 's#\.\./\.\.#$(TOPDIR)/feeds/packages#' cloudflared/Makefile
- name: Build Package
uses: openwrt/gh-action-sdk@main
env:
ARCH: ${{ matrix.arch }}-${{ matrix.ref }}
V: s
IGNORE_ERRORS: n m y
- name: Append architecture to apk filename
if: matrix.ref == 'main'
working-directory: bin/packages/${{ matrix.arch }}
run: |
file=$(find . -name 'cloudflared*.apk')
if [ -n "$file" ] && [[ "$file" != *${{ matrix.arch }}* ]]; then
filename="${file%.*}"
extension="${file##*.}"
mv "$file" "$filename-${{ matrix.arch }}.$extension"
fi
- name: Upload Output Folder
uses: actions/upload-artifact@v4
with:
name: cloudflared-${{ matrix.arch }}-${{ matrix.ref }}
path: bin/packages/${{ matrix.arch }}/action/cloudflared*
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
*.apk
*.ipk