Skip to content

AutoBuild

AutoBuild #226

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: false
# 删除早期的 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: [23.05.4]
arch: [
x86_64
]
include:
- usign_id: ${{ vars.USIGN_ID }}
- gpg_id: ${{ vars.GPG_ID }}
- 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@v4
with:
ref: 'gh-pages'
lfs: false
submodules: false
- name: Download artifact
uses: actions/download-artifact@v4
- name: Move artifact
shell: bash
env:
keepdir: '19.07|21.02|22.03'
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
for f in OpenWRT-Build-*; do
tar -C $release_path/ -xvf $f/$f.tgz
done
- 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 "actions-user@users.noreply.github.com"
#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@v4
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 --no-same-owner --no-same-permissions
popd
- name: Upload DL Cache artifact
uses: actions/upload-artifact@v4
with:
name: DL.txz
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/delete-workflow-runs@v2.0.3
if: env.DELETE_OLD_WORKFLOW == 'true' && !cancelled()
with:
retain_days: ${{ env.WORKFLOW_RETAIN_DAYS }}
keep_minimum_runs: ${{ env.KEEP_RUNS_RECORD }}