Update README #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Credits: | |
# https://github.com/Waujito | |
# https://github.com/Waujito/youtubeUnblock/blob/main/.github/workflows/build-ci.yml | |
name: CI | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '.editorconfig' | |
- '.gitignore' | |
- 'LICENSE' | |
- 'README.md' | |
workflow_dispatch: | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.gh.outputs.version }} | |
release: ${{ steps.gh.outputs.release }} | |
sha: ${{ steps.gh.outputs.sha }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: GH | |
id: gh | |
env: | |
REPO: ${{ github.repository }} | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
shell: bash | |
run: | | |
echo "version=$(cat Makefile | grep "PKG_VERSION:=" | sed 's/PKG_VERSION:=//')" >> $GITHUB_OUTPUT | |
echo "release=$(cat Makefile | grep "PKG_RELEASE:=" | sed 's/PKG_RELEASE:=//')" >> $GITHUB_OUTPUT | |
if [[ "${{ github.event_name }}" != "pull_request" ]]; then | |
echo "sha=$(echo ${GITHUB_SHA::7})" >> $GITHUB_OUTPUT | |
else | |
echo "sha=$(gh api repos/$REPO/commits/main --jq '.sha[:7]')" >> $GITHUB_OUTPUT | |
fi | |
build-entware: | |
needs: prepare | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
arch: | |
- aarch64-3.10 | |
- armv7-3.2 | |
- mips-3.4 | |
- mipsel-3.4 | |
- x64-3.2 | |
include: | |
- arch: armv7-2.6 | |
k26: true | |
- arch: x86-2.6 | |
k26: true | |
steps: | |
- name: Set up Entware docker container | |
run: | | |
git clone --depth 1 https://github.com/Entware/docker.git | |
docker build docker --pull --tag builder | |
docker volume create entware-home | |
- name: Restore Entware from cache | |
id: cache-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: ~/entware | |
key: entware-${{ matrix.arch }} | |
- name: Load Entware from cache | |
if: steps.cache-restore.outputs.cache-hit == 'true' | |
run: | | |
docker run --rm --mount source=entware-home,target=/backup_vol -v ~/entware:/backup ubuntu tar -xf /backup/entware.tar -C /backup_vol | |
docker run --rm --mount source=entware-home,target=/home/me -w /home/me ubuntu bash -c 'cp -r ./backup_vol/* ./' | |
docker run --rm --mount source=entware-home,target=/home/me -w /home/me ubuntu bash -c 'chown -R 1000:1000 ./* ./' | |
- name: Obtain Entware | |
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' && ! matrix.k26 }} | |
run: | | |
docker run --rm -i --mount source=entware-home,target=/home/me -w /home/me --name builder builder git clone --depth 1 https://github.com/Entware/Entware.git | |
- name: Obtain Entware k2.6 | |
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' && matrix.k26 }} | |
run: | | |
docker run --rm -i --mount source=entware-home,target=/home/me -w /home/me --name builder builder git clone --depth 1 https://github.com/Entware/Entware.git -b k2.6 | |
- name: Build Entware | |
if: steps.cache-restore.outputs.cache-hit != 'true' | |
run: | | |
docker run --rm -i --mount source=entware-home,target=/home/me -w /home/me/Entware --name builder builder make package/symlinks | |
docker run --rm -i --mount source=entware-home,target=/home/me -w /home/me/Entware --name builder builder cp -v configs/${{ matrix.arch }}.config .config | |
docker run --rm -i --mount source=entware-home,target=/home/me -w /home/me/Entware --name builder builder make -j$(nproc) toolchain/install | |
docker run --rm --mount source=entware-home,target=/backup_vol -v ~/entware:/backup ubuntu tar -cf /backup/entware.tar /backup_vol | |
- name: Save Entware to cache | |
if: steps.cache-restore.outputs.cache-hit != 'true' | |
id: cache-save | |
uses: actions/cache/save@v4 | |
with: | |
path: ~/entware | |
key: entware-${{ matrix.arch }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
ref: 'entware' | |
- name: Prepare build | |
env: | |
VERSION: ${{ needs.prepare.outputs.version }} | |
RELEASE: ${{ needs.prepare.outputs.release }} | |
SHA: ${{ needs.prepare.outputs.sha }} | |
run: | | |
sed -i "s/PKG_REV:=.*$/PKG_REV:=$SHA/;s/PKG_VERSION:=.*$/PKG_VERSION:=$VERSION-$RELEASE-$SHA/" keenetic-pbr/Makefile | |
- name: Build packages | |
id: build | |
run: | | |
echo "src-link keeneticPbr /keenetic-pbr" | docker run --rm -i --mount source=entware-home,target=/home/me -v $GITHUB_WORKSPACE:/keenetic-pbr -w /home/me/Entware --name builder builder tee -a feeds.conf | |
docker run --rm -i --mount source=entware-home,target=/home/me -v $GITHUB_WORKSPACE:/keenetic-pbr -w /home/me/Entware --name builder builder ./scripts/feeds update keeneticPbr | |
docker run --rm -i --mount source=entware-home,target=/home/me -v $GITHUB_WORKSPACE:/keenetic-pbr -w /home/me/Entware --name builder builder ./scripts/feeds install -a -p keeneticPbr | |
echo "CONFIG_PACKAGE_keenetic-pbr=m" | docker run --rm -i --mount source=entware-home,target=/home/me -v $GITHUB_WORKSPACE:/keenetic-pbr -w /home/me/Entware --name builder builder tee -a .config | |
docker run --rm -i --mount source=entware-home,target=/home/me -v $GITHUB_WORKSPACE:/keenetic-pbr -w /home/me/Entware --name builder builder make package/keenetic-pbr/compile V=s | |
- name: Extract packages | |
if: steps.build.outcome == 'success' | |
shell: bash | |
env: | |
VERSION: ${{ needs.prepare.outputs.version }} | |
RELEASE: ${{ needs.prepare.outputs.release }} | |
SHA: ${{ needs.prepare.outputs.sha }} | |
run: | | |
mkdir output | |
docker run --rm --user root -i --mount source=entware-home,target=/home/me -v $(pwd):/target -w /home/me/Entware --name builder builder find ./bin -type f -name 'keenetic-pbr*.ipk' -exec cp -v {} /target/output \; | |
rm -rf keenetic-pbr || true | |
mkdir keenetic-pbr | |
bash -c "cp -r ./output/*.ipk keenetic-pbr-$VERSION-$RELEASE-$SHA-${{ matrix.arch }}-entware.ipk" | |
- name: Upload packages | |
if: steps.build.outcome == 'success' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: keenetic-pbr-entware-${{ matrix.arch }} | |
path: | | |
./**/keenetic-pbr*-entware.ipk | |
if-no-files-found: error | |
pre-release: | |
if: github.event_name != 'pull_request' && github.ref_name == 'main' | |
needs: [build-entware] | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
- name: Upload assets | |
uses: slord399/action-automatic-releases@v1.0.1 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
automatic_release_tag: 'continuous' | |
prerelease: true | |
draft: true | |
title: 'Development build' | |
files: | | |
./**/keenetic-pbr*.ipk |