Skip to content

Commit

Permalink
chore(ci): build both apk and ipk
Browse files Browse the repository at this point in the history
Fixes #3
  • Loading branch information
moetayuko committed Nov 26, 2024
1 parent 527428f commit a585193
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
67 changes: 50 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@ jobs:
name: Set matrix
runs-on: ubuntu-latest
outputs:
sdks: ${{ steps.find_targets.outputs.sdks }}
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
Expand All @@ -32,7 +40,7 @@ jobs:
[[ $FIRST -ne 1 ]] && JSON="$JSON"','
FIRST=0
JSON="$JSON"'{"arch":"'"$ARCH"'"}'
JSON="$JSON"'{"arch":"'"$ARCH"'","ref":"'"$REF"'"}'
done <<< $(perl ./scripts/dump-target-info.pl architectures 2>/dev/null)
JSON="$JSON"']'
Expand All @@ -41,40 +49,63 @@ jobs:
echo -e "\n---- sdks ----\n"
echo "sdks=$JSON" >> "$GITHUB_OUTPUT"
build:
name: Build for ${{ matrix.arch }}
- 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.generate_matrix.outputs.sdks) }}
include: ${{ fromJson(needs.gather_matrix.outputs.result) }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Fetch upstream git reversion
id: op_version
run: echo sha=$(cat .nvchecker/sha) >> $GITHUB_OUTPUT
- 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 }}-main
ARCH: ${{ matrix.arch }}-${{ matrix.ref }}
V: s
IGNORE_ERRORS: n m y
NO_DEFAULT_FEEDS: 1
EXTRA_FEEDS: >-
src-git-full|base|https://github.com/openwrt/openwrt.git
src-git|packages|https://github.com/openwrt/packages.git^${{ steps.op_version.outputs.sha }}
PACKAGES: cloudflared

- name: Upload Output Folder
uses: actions/upload-artifact@v4
with:
name: cloudflared-${{ matrix.arch }}
path: bin/packages/${{ matrix.arch }}/packages/cloudflared_*.ipk
name: cloudflared-${{ matrix.arch }}-${{ matrix.ref }}
path: bin/packages/${{ matrix.arch }}/packages/cloudflared*

release:
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -91,4 +122,6 @@ jobs:
- name: Release
uses: softprops/action-gh-release@v2
with:
files: "*.ipk"
files: |
"*.apk"
"*.ipk"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
/.nvchecker/config.toml
/.nvchecker/new_ver.json
/cloudflared/

0 comments on commit a585193

Please sign in to comment.