Skip to content

build

build #501

Workflow file for this run

name: build
on:
workflow_dispatch:
# schedule:
# - cron: '0 6 * * *'
jobs:
check:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.gh.outputs.tag }}
date: ${{ steps.gh.outputs.date }}
sha: ${{ steps.gh.outputs.sha }}
url: ${{ steps.gh.outputs.url }}
message: ${{ steps.gh.outputs.message }}
is_active: ${{ steps.activity.outputs.is_active }}
steps:
- name: Get repo data via GH API
id: gh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: 'bol-van/zapret'
run: |
BRANCH=$(gh api repos/$REPO --jq '.default_branch')
DATE=$(gh api repos/$REPO/commits/$BRANCH --jq '.commit.committer.date')
{
echo "date=$(date --utc -d $DATE +%Y%m%d)"
echo "tag=$(gh api repos/$REPO/releases/latest --jq '.tag_name')"
echo "sha=$(gh api repos/$REPO/commits/$BRANCH --jq '.sha[0:7]')"
echo "url=$(gh api repos/$REPO/commits/$BRANCH --jq '.html_url')"
echo "message<<EOF"
gh api repos/$REPO/commits/$BRANCH --jq '.commit.message'
echo EOF
} >> $GITHUB_OUTPUT
echo "DATE=$DATE" >> $GITHUB_ENV
- name: Check for repo activity
id: activity
env:
DATE: ${{ env.DATE }}
URL: ${{ steps.gh.outputs.url }}
run: |
TIMESTAMP=$(date --utc -d $DATE +%s)
DAYS=$(( ( $(date --utc +%s) - $TIMESTAMP ) / 86400 ))
echo "Repository activity: $(date --utc -d $DATE)"
echo "Commit: $URL"
if [ "${{ github.event_name }}" != "schedule" ]; then
is_active=true
elif [[ $DAYS -lt 1 ]] ; then
is_active=true
else
echo "Repository not updated within last 24 hours."
is_active=false
fi
echo "is_active=$is_active" >> $GITHUB_OUTPUT
build:
needs: check
if: needs.check.outputs.is_active == 'true'
name: "${{ matrix.branch }} :: ${{ matrix.arch }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch:
# - openwrt-19.07
- openwrt-21.02
- openwrt-22.03
- openwrt-23.05
arch:
- aarch64_cortex-a53
- aarch64_cortex-a72
- aarch64_generic
- arm_arm1176jzf-s_vfp
- arm_arm926ej-s
- arm_cortex-a15_neon-vfpv4
- arm_cortex-a5_vfpv4
- arm_cortex-a7
- arm_cortex-a7_neon-vfpv4
- arm_cortex-a7_vfpv4
- arm_cortex-a8_vfpv3
- arm_cortex-a9
- arm_cortex-a9_neon
- arm_cortex-a9_vfpv3-d16
- arm_fa526
- arm_mpcore
- arm_xscale
- mips64_octeonplus
- mips_24kc
- mips_4kec
- mips_mips32
- mipsel_24kc
- mipsel_24kc_24kf
- mipsel_74kc
- mipsel_mips32
- x86_64
include:
- branch: SNAPSHOT
arch: x86_64
exclude:
# - branch: openwrt-19.07
# arch: arm_cortex-a7
# - branch: openwrt-19.07
# arch: arm_cortex-a7_vfpv4
# - branch: openwrt-19.07
# arch: mips_4kec
- branch: openwrt-21.02
arch: arm_cortex-a7_vfpv4
container:
image: openwrt/sdk:${{ matrix.arch }}-${{ matrix.branch }}
options: --user root
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: 'bol-van/zapret'
path: zapret
- name: Apply diff from PR
if: false
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget -qO- --header="Authorization: token $GH_TOKEN" https://api.github.com/repos/cli/cli/releases/latest | grep -Po '"tag_name": "v\K.+(?=")' |\
xargs -I{} wget -qO- https://github.com/cli/cli/releases/download/v{}/gh_{}_linux_amd64.tar.gz | tar -xz --wildcards '*/bin/gh' --strip-components=2
cd zapret && ../gh pr diff 413 | git apply -
- name: Set up SDK
if: ${{ matrix.branch == 'openwrt-23.05' || matrix.branch == 'SNAPSHOT' }}
working-directory: /builder
shell: bash
run: |
gpg --verbose --keyserver keyserver.ubuntu.com --recv-keys 0x1D53D1877742E911 ||\
gpg --verbose --import <(wget -qO- 'https://git.openwrt.org/?p=keyring.git;a=blob_plain;f=gpg/0x1D53D1877742E911.asc')
sed -r -i 's/^rm.+//' setup.sh
./setup.sh
ls -lh
- name: Set up ccache
uses: actions/cache@v4
with:
path: ${{ matrix.branch == 'openwrt-19.07' && '/home/build/openwrt/.ccache' || '/builder/.ccache' }}
key: ccache-${{ matrix.arch }}-${{ matrix.branch }}-${{ github.run_id }}
restore-keys: |
ccache-${{ matrix.arch }}-${{ matrix.branch }}-
- name: Build packages
id: build
continue-on-error: true
working-directory: ${{ matrix.branch == 'openwrt-19.07' && '/home/build/openwrt' || '/builder' }}
env:
# DATE: ${{ needs.check.outputs.date }}
TAG: ${{ needs.check.outputs.tag }}
# SHA: ${{ needs.check.outputs.sha }}
ARCH: ${{ matrix.arch }}
BRANCH: ${{ matrix.branch }}
SIGN_KEY: ${{ secrets.SIGN_PRIVATE_KEY }}
CCACHE_DIR: ${{ matrix.branch == 'openwrt-19.07' && '/home/build/openwrt/.ccache' || '/builder/.ccache' }}
shell: bash
run: |
# export PKG_VERSION=$(date --utc -d $DATE +%Y%m%d)
export PKG_VERSION=${TAG#v}
find $GITHUB_WORKSPACE/zapret -type d -path '*/package/zapret' -exec cp -vr {} ./package \;
cp -vr $GITHUB_WORKSPACE/zapret/tpws ./package/zapret/tpws/
cp -vr $GITHUB_WORKSPACE/zapret/nfq ./package/zapret/nfqws/
cp -vr $GITHUB_WORKSPACE/zapret/mdig ./package/zapret/mdig/
cp -vr $GITHUB_WORKSPACE/zapret/ip2net ./package/zapret/ip2net/
find ./package/zapret -type f -name Makefile -exec sed 's/PKG_RELEASE.*//g' -i {} \;
mv feeds.conf.default feeds.conf
sed -e 's|base.*\.git|base https://github.com/openwrt/openwrt.git|' \
-e 's|packages.*\.git|packages https://github.com/openwrt/packages.git|' -i feeds.conf
./scripts/feeds update base packages
./scripts/feeds install -a
make defconfig
make package/{ip2net,nfqws,mdig,tpws}/compile V=s -j$(nproc) CONFIG_CCACHE=1 BUILD_LOG=1
find ./bin/packages/*/base -type f ! -regex ".*\(ip2net\|nfqws\|mdig\|tpws\).*\.[ai]pk$" -delete
echo "$SIGN_KEY" | base64 -d > key-build
make package/index
tar -C ./bin/packages/*/base -cvf $GITHUB_WORKSPACE/pkg-$BRANCH-$ARCH.tar --transform "s|^\./|${BRANCH/openwrt-}/$ARCH/|" --show-transformed-names .
./staging_dir/host/bin/ccache --max-size=10M --show-stats
- name: Compress build logs
if: always()
env:
ARCH: ${{ matrix.arch }}
BRANCH: ${{ matrix.branch }}
LOGS_DIR: ${{ matrix.branch == 'openwrt-19.07' && '/home/build/openwrt/logs' || '/builder/logs' }}
run: |
tar -cJvf logs-$BRANCH-$ARCH.tar.xz $LOGS_DIR
- name: Upload packages
if: steps.build.outcome == 'success'
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: pkg-${{ matrix.branch }}-${{ matrix.arch }}
path: pkg-*.tar
# if-no-files-found: error
- name: Upload build logs
if: always()
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: logs-${{ matrix.branch }}-${{ matrix.arch }}
path: logs-*.tar.xz
gh-pages:
needs: [ check, build ]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: pkg-*
- name: Prepare files
run: |
mkdir public
find . -name 'pkg-*.tar' -exec tar -C ./public -xvf {} \;
- name: Deploy to GH pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
full_commit_message: ${{ needs.check.outputs.tag }}
force_orphan: true
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
continue-on-error: true
release:
needs: [ check, gh-pages ]
permissions:
contents: write
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
branch:
# - '19.07'
- '21.02'
- '22.03'
- '23.05'
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: pkg-*
- name: Put packages into zip
env:
BRANCH: ${{ matrix.branch }}
TAG: ${{ needs.check.outputs.tag }}
run: |
mkdir -p public
find . -name "*-openwrt-$BRANCH-*.tar" -exec tar -xvf {} --wildcards '*.*pk' \;
find $BRANCH -mindepth 1 -type d -exec sh -c 'zip -0 ./public/zapret_${TAG}_$(basename {}).zip -j {} {}/*' \;
ls -lh ./public/*.zip
- name: Upload assets
uses: andelf/nightly-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: false
tag_name: ${{ needs.check.outputs.tag }}-${{ matrix.branch }}
name: '${{ needs.check.outputs.tag }} for OpenWrt ${{ matrix.branch }}'
body: |
### zapret ${{ needs.check.outputs.tag }}
files: ./public/*.zip