From 15d53d4245da991ccd76fdff27f9a21f299e74b6 Mon Sep 17 00:00:00 2001 From: MoetaYuko Date: Wed, 6 Mar 2024 22:19:24 +0800 Subject: [PATCH] chore(ci): enable github actions --- .github/workflows/build.yml | 90 +++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..bf9c511 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,90 @@ +name: Build + +on: + workflow_dispatch: + push: + tags: + - "*" + +jobs: + generate_matrix: + name: Set matrix + runs-on: ubuntu-latest + outputs: + sdks: ${{ steps.find_targets.outputs.sdks }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + repository: openwrt/openwrt + + - name: Set targets + id: find_targets + run: | + # 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"'"}' + 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" + + build: + name: Build for ${{ matrix.arch }} + runs-on: ubuntu-latest + needs: generate_matrix + strategy: + fail-fast: false + matrix: + include: ${{ fromJson(needs.generate_matrix.outputs.sdks) }} + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build Package + uses: openwrt/gh-action-sdk@main + env: + ARCH: ${{ matrix.arch }}-main + V: s + IGNORE_ERRORS: n m y + PACKAGES: cloudflared + + - name: Finding failure logs + working-directory: logs/package/feeds + run: | + sed -ne 's!^ *ERROR: package/feeds/\(passwall[^ ]*\) .*$!\1!p' ../error.txt | sort -u | xargs -r find > ../../../logs.txt + cat ../../../logs.txt + + - name: Upload Output Folder + uses: actions/upload-artifact@v4 + with: + name: cloudflared-${{ matrix.arch }} + path: bin/packages/${{ matrix.arch }}/packages/cloudflared_*.ipk + + release: + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + needs: build + steps: + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + + - name: Release + uses: softprops/action-gh-release@v1 + with: + files: "*.ipk"