Skip to content

AutoBuild

AutoBuild #198

Workflow file for this run

name: AutoBuild
on:
workflow_dispatch:
inputs:
build_mode:
description: 'Build mode'
required: true
default: 'build_pkgs_and_imgs'
type: choice
options:
- build_pkgs_and_imgs
- build_imgs
- build_pkgs
compile_packages:
description: 'Compile packages'
required: false
default: 'A B C etc.'
type: string
no_pages:
description: 'Donot deploy pages'
required: true
default: false
type: boolean
export_dl:
description: 'Export DL'
required: true
default: false
type: boolean
push:
branches: [ master ]
paths:
- 'Makefile'
watch:
types: [started]
env:
# Release path
release_path: 'releases'
# 删除早期的 packages
DELETE_OLD_PACKAGES: true
# 删除早期的 workflow 任务
DELETE_OLD_WORKFLOW: true
WORKFLOW_RETAIN_DAYS: 14
KEEP_RUNS_RECORD: 100
### End
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: false
jobs:
compile:
permissions:
contents: write # To push a branch
strategy:
matrix:
version: [22.03.5, 23.05.2]
arch: [
x86_64,
mips_24kc,
arm_cortex-a7_neon-vfpv4,
aarch64_cortex-a53,
aarch64_cortex-a72,
arm_cortex-a9,
arm_cortex-a15_neon-vfpv4,
mipsel_24kc,
aarch64_generic
]
include:
- usign_id: '53FF2B6672243D28'
- gpg_id: 'A5F2461EC8F6DCAA'
- release_path: 'releases'
- no_img: true
- arch: x86_64
target: ['x86', '64'] # for imagebuilder
profile: generic # for imagebuilder
no_img: false
uses: ./.github/workflows/compile.yml
with:
build_mode: ${{ inputs.build_mode }}
compiles: ${{ inputs.compile_packages }}
no_img: ${{ matrix.no_img }}
TPATH: ${{ matrix.release_path }}
VERSION: ${{ matrix.version }}
TARGET: ${{ matrix.target[0] }}
SUBTARGET: ${{ matrix.target[1] }}
PROFILE: ${{ matrix.profile }}
ARCH: ${{ matrix.arch }}
USIGN_ID: ${{ matrix.usign_id }}
GPG_ID: ${{ matrix.gpg_id }}
secrets: inherit
push_packages:
needs: compile
if: (inputs.build_mode == 0 || inputs.build_mode == 'build_pkgs_and_imgs' || inputs.build_mode == 'build_pkgs') && !cancelled()
permissions:
contents: write # To push a branch
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: 'gh-pages'
lfs: false
submodules: false
- name: Download artifact
uses: actions/download-artifact@v3
- name: Move artifact
shell: bash
env:
keepdir: '18.06|19.07|21.02'
run: |
if [ "$DELETE_OLD_PACKAGES" == "true" ]; then
find $release_path/* -maxdepth 0 -type d 2>/dev/null | grep -Ev "\b($keepdir)$" | xargs -I{} rm -rf "{}"
fi
mkdir -p $release_path 2>/dev/null
cp -rf OpenWRT-Build-*/*/ $release_path/
rm -rf OpenWRT-Build-*/ 2>/dev/null
- name: Display structure of downloaded files
working-directory: ${{ env.release_path }}
run: ls -R
- name: Commit and push Packages
env:
Branch: gh-pages
run: |
git config --local user.name "GitHub Action"
git config --local user.email "[email protected]"
#git remote update # include submodules
#git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin $Branch
#git checkout -B $Branch refs/remotes/origin/$Branch
git add $release_path/**/
git reset HEAD $release_path/**/targets/
git diff-index --cached --quiet HEAD $release_path/**/packages/**/*.ipk \
&& git diff-index --cached --quiet HEAD $release_path/**/packages/**/Packages.manifest \
&& git diff-index --cached --quiet HEAD $release_path/**/*.pub \
|| (git commit -m "Update packages" && git push)
export_dl:
needs: compile
if: inputs.export_dl == 1 && (inputs.build_mode == 0 || inputs.build_mode == 'build_pkgs_and_imgs' || inputs.build_mode == 'build_pkgs') && !cancelled()
runs-on: ubuntu-latest
steps:
- name: Initialize Environment
run: |
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
mkdir -p /workdir/DL
- name: Cache DL dependencies
uses: actions/cache@v3
with:
path: /workdir/DL
key: ${{ runner.os }}-OpenWRT-SDK-DL-Cache-Makefile-${{ hashFiles('**/Makefile') }}
restore-keys: |
${{ runner.os }}-OpenWRT-SDK-DL-Cache-Makefile-
- name: Compress DL Cache
run: |
pushd /workdir/DL
tar -cJvf /workdir/DL.txz * --owner=0 --group=0
popd
- name: Upload DL Cache artifact
uses: actions/upload-artifact@v3
with:
name: DL.txz.zip
path: /workdir/DL.txz
retention-days: 1
deploy_pages:
needs: [compile, push_packages]
if: inputs.no_pages == 0 && !cancelled()
permissions:
contents: read
pages: write
id-token: write
strategy:
matrix:
release_path: ['releases']
uses: ./.github/workflows/jekyll.yml
with:
destination_path: ${{ matrix.release_path }}
clean-up-old-workflow:
needs: push_packages
permissions:
contents: read
actions: write
runs-on: ubuntu-latest
steps:
- name: Delete old Workflow Runs
uses: Mattraks/[email protected]
if: env.DELETE_OLD_WORKFLOW == 'true' && !cancelled()
with:
retain_days: ${{ env.WORKFLOW_RETAIN_DAYS }}
keep_minimum_runs: ${{ env.KEEP_RUNS_RECORD }}