-
-
Notifications
You must be signed in to change notification settings - Fork 113
149 lines (132 loc) · 5.1 KB
/
Copy pathbuild.yml
File metadata and controls
149 lines (132 loc) · 5.1 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
139
140
141
142
143
144
145
146
147
148
149
name: Build packages
on:
release:
types: [published]
push:
branches: [master, "dev**"]
tags:
- v*
- '!v2020*'
paths:
- ".github/workflows/build.yml"
- "libremesh.mk"
- "packages/**"
workflow_dispatch:
inputs:
packages:
description: "Packages to build (empty for all)"
required: false
jobs:
# Build all packages for x86_64 using the openwrt sdk
# for the branches 'main', 'stable', 'oldstable' of openwrt
generate_matrix:
name: 'Generate matrix'
runs-on: ubuntu-latest
outputs:
matrix_builds: ${{ steps.define_matrix.outputs.matrix_builds }}
dest_dir: ${{ steps.set_package_destination.outputs.dest_dir }}
steps:
- name: Set package destination
id: set_package_destination
run: |
export TAG=$(echo "${{ github.ref }}" | cut -d '/' -f 3- | perl -pe 's/v([0-9])/$1/')
echo "$TAG"
echo "DEST_DIR=$TAG" >> $GITHUB_OUTPUT
- name: Define matrix of branches and archs
id: define_matrix
run: |
JSON='['
FIRST_BUILD=1
versions_json=$(curl -s https://downloads.openwrt.org/.versions.json)
stable_version=$(echo "$versions_json" | jq -r '.stable_version')
oldstable_version=$(echo "$versions_json" | jq -r '.oldstable_version')
upcoming_version=$(echo "$versions_json" | jq -r '.upcoming_version')
stable_branch=$(echo "$stable_version" | cut -d. -f1,2)
oldstable_branch=$(echo "$oldstable_version" | cut -d. -f1,2)
upcoming_branch=$(echo "$upcoming_version" | cut -d. -f1,2)
for branch in "main" "$stable_branch" "$oldstable_branch" "$upcoming_branch"; do
if [ ! -z "$branch" ] && [ -n "$branch" ]; then
VERSION=$([ "$branch" == "main" ] && echo "main" || echo "openwrt-$branch")
OPENWRT_BRANCH_PATH="openwrt-$branch"
echo $VERSION
[[ $FIRST_BUILD -ne 1 ]] && JSON="$JSON"','
FIRST_BUILD=0
JSON="$JSON"'{"version": "'"$VERSION"'", "openwrt_branch_path": "'"$OPENWRT_BRANCH_PATH"'" }'
fi
done
matrix_include='{"include": '"$JSON"']}'
echo "matrix_builds=${matrix_include}" >> "$GITHUB_OUTPUT"
build:
name: Build ${{ matrix.openwrt_branch_path }} x86_64
runs-on: ubuntu-latest
needs: generate_matrix
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate_matrix.outputs.matrix_builds) }}
steps:
- uses: actions/checkout@v5
- name: Build packages
uses: openwrt/gh-action-sdk@v9
env:
ARCH: x86_64-${{ matrix.version }}
FEEDNAME: "libremesh"
IGNORE_ERRORS: "n m y"
KEY_BUILD: "${{ secrets.KEY_BUILD }}"
PRIVATE_KEY: "${{ secrets.PRIVATE_KEY }}"
INDEX: 1
NO_DEFAULT_FEEDS: 1
NO_REFRESH_CHECK: 1
NO_SHFMT_CHECK: 1
PACKAGES: ${{ github.event.inputs.packages }}
# V: sc
- name: Prepare artifacts paths
run: |
bin_path="bin_dir/${{ matrix.openwrt_branch_path }}/x86_64"
mkdir -p "$bin_path"
mv bin/packages/x86_64/libremesh/* "$bin_path"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.openwrt_branch_path }}
path: bin_dir/
publish:
name: Publish
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [generate_matrix, build]
steps:
- uses: actions/checkout@v5
- name: Checkout lime-feed
uses: actions/checkout@v5
with:
repository: libremesh/lime-feed
path: lime-feed
- uses: actions/download-artifact@v5
with:
merge-multiple: true
path: artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/
- name: Replace packages
run: |
mkdir -p lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}
for branch in $(ls artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/); do
rm -rf lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/$branch/x86_64
done;
cp -r artifacts/${{ needs.generate_matrix.outputs.dest_dir }}/* lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/
- name: Upload packages to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository: libremesh/lime-feed
publish_dir: ./lime-feed/${{ needs.generate_matrix.outputs.dest_dir }}/
destination_dir: "${{ needs.generate_matrix.outputs.dest_dir }}"
# - name: Upload packages to S3
# uses: jakejarvis/s3-sync-action@master
# with:
# args: --acl public-read --follow-symlinks --delete
# env:
# AWS_S3_BUCKET: libremesh
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# AWS_S3_ENDPOINT: ${{ secrets.AWS_S3_ENDPOINT }}
# SOURCE_DIR: bin/packages/x86_64/libremesh/
# DEST_DIR: ${{ env.DEST_DIR }}