Skip to content

openwrt_source_update #44

openwrt_source_update

openwrt_source_update #44

#
# Copyright (c) 2022-2024 SMALLPROGRAM <https://github.com/smallprogram/OpenWrtAction>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
# https://github.com/smallprogram/OpenWrtAction
# Description: Build OpenWrt using GitHub Actions
#
name: Build-OpenWrt_Multi-Platform(V4)
on:
repository_dispatch:
types: [openwrt_source_update]
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
is_display_detailed:
description: 'Whether to display detailed information about compilation'
required: false
default: 'false'
is_single_threaded:
description: 'Whether single-threaded compilation'
required: false
default: 'false'
# schedule:
# - cron: 0 */8 * * *
env:
MAKE_DEFCONFIG_SH: compile_script/step01_make_defconfig.sh
GENERATE_RELEASE_TAG_SH: compile_script/step02_generate_release_tag.sh
GENERATE_GIT_LOG_SH: compile_script/step03_generate_git_log.sh
UPDATE_GIT_LOG_SH: compile_script/step06_update_git_log.sh
ORGANIZE_TAG_SH: compile_script/step07_organize_tag.sh
PLATFORMS_SH: compile_script/platforms.sh
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_ARTIFACT: true
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
job_init:
runs-on: ubuntu-24.04
name: Init
outputs:
output_release_tag: ${{ steps.gen_release_tag.outputs.release_tag }}
platforms: ${{ steps.read-platforms.outputs.matrix }}
platforms_source: ${{ steps.read-platforms.outputs.source_matrix_json }}
steps:
- name: Generate Tag Name
id: gen_release_tag
run: |
echo "release_tag=multi-platform_$(date +"%Y.%m.%d_%H.%M.%S")" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Read Platforms From File
id: read-platforms
run: |
bash $PLATFORMS_SH
job_source_init:
needs: job_init
runs-on: ${{ matrix.value.OS }}
name: Source-Init-${{ matrix.source_code_platform }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.job_init.outputs.platforms_source) }}
steps:
- name: Init System
id: init
run: |
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown -R $USER:$GROUPS /workdir
cd /workdir
sudo mkdir -p output
sudo chown -R $USER:$GROUPS /workdir/output
ln -sf /workdir/output $GITHUB_WORKSPACE/output
df -hT
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Clone Source Code
working-directory: /workdir
run: |
git clone ${{ matrix.value.REPO_URL }} -b ${{matrix.value.REPO_BRANCH}} openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: Load Custom Feeds
run: |
[ -e $FEEDS_CONF ] && cp -r ${{ matrix.value.FEEDS_CONF }} openwrt/feeds.conf.default
chmod +x ${{ matrix.value.DIY_P1_SH }}
cd openwrt
$GITHUB_WORKSPACE/${{ matrix.value.DIY_P1_SH }}
- name: Update Feeds
run: cd openwrt && ./scripts/feeds update -a
- name: Install Feeds
run: cd openwrt && ./scripts/feeds install -a
- name: Pull the latest changes and Create temporary branch
run: |
git fetch origin
git reset --hard origin/${{ github.ref_name }}
git checkout -b temp-${{ matrix.source_code_platform }}
- name: Make Defconfig Custom Configuration
run: |
chmod +x ${{ matrix.value.DIY_P2_SH }}
chmod +x $MAKE_DEFCONFIG_SH
cd openwrt
$GITHUB_WORKSPACE/${{ matrix.value.DIY_P2_SH }}
$GITHUB_WORKSPACE/$MAKE_DEFCONFIG_SH "${{ matrix.source_code_platform }}" "${{ matrix.value.CONFIGS }}"
- name: Merge and push changes with "theirs" strategy
run: |
git checkout temp-${{ matrix.source_code_platform }}
git add .
if ! git diff --cached --quiet; then
git config user.name "smallprogram"
git config user.email "smallprogram@foxmail.com"
git commit -m "Auto update for ${{ matrix.source_code_platform }} configuration"
git checkout ${{ github.ref_name }}
git fetch origin
git reset --hard origin/${{ github.ref_name }}
git checkout temp-${{ matrix.source_code_platform }}
git merge origin/${{ github.ref_name }} --no-ff --strategy-option theirs --no-edit || {
echo "Merge conflict in temp branch, please resolve manually."
exit 100
}
git checkout ${{ github.ref_name }}
git merge temp-${{ matrix.source_code_platform }} --strategy-option theirs --no-edit
git push origin ${{ github.ref_name }} --force
git branch -d temp-${{ matrix.source_code_platform }} || echo "Local temp-${{ matrix.source_code_platform }} not found"
git push origin --delete temp-${{ matrix.source_code_platform }} || echo "Remote temp-${{ matrix.source_code_platform }} not found"
else
echo "No changes to commit."
fi
- name: Generate Source Packages
working-directory: /workdir
id: generate_image
run: |
echo "source folder size:"
du -hs openwrt/
echo
tar -czf output/output.tar.gz openwrt/
echo "source code size:"
cd output
ls -lh output.tar.gz
echo "SOURCE_PATH=$PWD" >> $GITHUB_OUTPUT
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload Source To Artifact
uses: actions/upload-artifact@v4
if: steps.generate_image.outputs.status == 'success'
with:
name: Source_${{ matrix.source_code_platform }}
path: ${{ steps.generate_image.outputs.SOURCE_PATH }}/output.tar.gz
retention-days: 5
- name: Generate Git Log
id: git_log
run: |
chmod +x $GENERATE_GIT_LOG_SH
$GITHUB_WORKSPACE/$GENERATE_GIT_LOG_SH "${{ matrix.source_code_platform }}"
- name: Upload Git Log To Artifact
uses: actions/upload-artifact@v4
if: steps.git_log.outputs.status == 'success'
with:
name: git_log_${{ matrix.source_code_platform }}
path: git_log_${{ matrix.source_code_platform }}.txt
retention-days: 5
- name: Generate Release Tag
id: tag
run: |
chmod +x $GENERATE_RELEASE_TAG_SH
$GITHUB_WORKSPACE/$GENERATE_RELEASE_TAG_SH "${{ needs.job_init.outputs.output_release_tag }}" "${{ matrix.source_code_platform }}" "${{ matrix.value.CONFIGS }}"
- name: Upload Release Tag To Artifact
uses: actions/upload-artifact@v4
with:
name: release_${{ matrix.source_code_platform }}
path: release_${{ matrix.source_code_platform }}.txt
retention-days: 5
job_generate_release_tag:
needs: [job_init, job_source_init]
runs-on: ubuntu-24.04
name: Generate-Release-Tag-And-Git-Log
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Pull the latest changes and Create temporary branch
run: |
git fetch origin
git reset --hard origin/${{ github.ref_name }}
git checkout -b temp-tag-gitlog
- name: Download Git Log From Artifacts
id : download_gitlog
uses: actions/download-artifact@v4
with:
pattern: git_log_*
merge-multiple: true
- name: Download Release Tag From Artifacts
id : download_releasetag
uses: actions/download-artifact@v4
with:
pattern: release_*
merge-multiple: true
- name: Generate Release Tag
id: tag
run: |
chmod +x $UPDATE_GIT_LOG_SH
$GITHUB_WORKSPACE/$UPDATE_GIT_LOG_SH "${{ needs.job_init.outputs.output_release_tag }}"
- name: Upload Tags To Artifact
uses: actions/upload-artifact@v4
with:
name: release_tag
path: release.txt
retention-days: 5
- name: Create Release Tag
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.job_init.outputs.output_release_tag }}
body_path: release.txt
- name: Merge and push changes with "theirs" strategy
run: |
git checkout temp-tag-gitlog
rm -rf release.txt
git add .
if ! git diff --cached --quiet; then
git config user.name "smallprogram"
git config user.email "smallprogram@foxmail.com"
git commit -m "Auto update git log"
git checkout ${{ github.ref_name }}
git fetch origin
git reset --hard origin/${{ github.ref_name }}
git checkout temp-tag-gitlog
git merge origin/${{ github.ref_name }} --no-ff --strategy-option theirs --no-edit || {
echo "Merge conflict in temp branch, please resolve manually."
exit 100
}
git checkout ${{ github.ref_name }}
git merge temp-tag-gitlog --strategy-option theirs --no-edit
git push origin ${{ github.ref_name }} --force
git branch -d temp-tag-gitlog || echo "Local temp-tag-gitlog not found"
git push origin --delete temp-tag-gitlog || echo "Remote temp-tag-gitlog not found"
else
echo "No changes to commit."
fi
job_build_toolchain:
needs: [job_init, job_source_init, job_generate_release_tag]
runs-on: ${{ matrix.value.OS }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.job_init.outputs.platforms) }}
name: Toolchain-${{ matrix.source_code_platform }}-${{ matrix.platform }}
steps:
- name: Initialization Environment
run: |
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown -R $USER:$GROUPS /workdir
- name: Maximize Build Space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 6144
swap-size-mb: 10240
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
build-mount-path: '/workdir'
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Pull the latest changes
run: git pull origin ${{ github.ref_name }}
- name: Install Packages
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get -qq update
sudo -E apt-get -qq install $(curl -fsSL https://github.com/smallprogram/OpenWrtAction/raw/main/diy_script/${{ matrix.source_code_platform }}_dependence)
# sudo -E apt-get -qq autoremove --purge
# sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
df -hT
- name: Initialization Directory
working-directory: /workdir
id: init_directory
run: |
sudo mkdir -p openwrt
sudo mkdir -p download
sudo chown -R $USER:$GROUPS /workdir/openwrt
sudo chown -R $USER:$GROUPS /workdir/download
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
ln -sf /workdir/download $GITHUB_WORKSPACE/download
- name: Download Source From Artifacts
id : download
uses: actions/download-artifact@v4
with:
name: Source_${{ matrix.source_code_platform }}
path: download
- name: File Extraction
working-directory: /workdir
run: |
echo "source packages size:"
ls -lh download/output.tar.gz
tar -xzf download/output.tar.gz
rm -rf download/output.tar.gz
sudo chown -R $USER:$GROUPS /workdir/openwrt
- name: Load Configuration
run: |
# chmod +x $COPY_BACKGROUNDFILES_SH
[ -e ${{ matrix.value.CONFIGS }}/${{ matrix.platform }}.config ] && cp -r ${{ matrix.value.CONFIGS }}/${{ matrix.platform }}.config openwrt/.config
cd openwrt
make defconfig
# $GITHUB_WORKSPACE/$COPY_BACKGROUNDFILES_SH "" "${{ matrix.platform }}"
- name: Download Package
id: package
run: |
df -hT
cd $GITHUB_WORKSPACE/openwrt
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
df -hT
- name: SSH connection to Actions
uses: mxschmitt/action-tmate@v3.16
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
- name: Compile Toolchain
id: compile_toolchain
run: |
cd openwrt
is_complie_error=0
if [[ "${{ github.event.inputs.is_display_detailed }}" == "true" ]]; then
if [[ "${{ github.event.inputs.is_single_threaded }}" == "true" ]]; then
echo "1 threads compile tools"
make tools/compile -j1 V=s
make toolchain/compile -j1 V=s
make package/cleanup -j1 V=s
make target/compile -j1 V=s
is_complie_error=${PIPESTATUS[0]}
else
echo "$(nproc) threads compile tools"
make tools/compile -j$(nproc) V=s
make toolchain/compile -j$(nproc) V=s
make package/cleanup -j$(nproc) V=s
make target/compile -j$(nproc) V=s
is_complie_error=${PIPESTATUS[0]}
fi
else
if [[ "${{ github.event.inputs.is_single_threaded }}" == "true" ]]; then
echo "1 threads compile tools"
make tools/compile -j1
make toolchain/compile -j1
make package/cleanup -j1
make target/compile -j1
is_complie_error=${PIPESTATUS[0]}
else
echo "$(nproc) threads compile tools"
make tools/compile -j$(nproc)
make toolchain/compile -j$(nproc)
make package/cleanup -j$(nproc)
make target/compile -j$(nproc)
is_complie_error=${PIPESTATUS[0]}
fi
fi
echo "complie result: $is_complie_error"
if [ "$is_complie_error" -eq 0 ]; then
echo "status=success" >> $GITHUB_OUTPUT
else
echo "status=failure" >> $GITHUB_OUTPUT
exit $is_complie_error
fi
df -hT
- name: Generate Source Packages
working-directory: /workdir
id: generate_image
run: |
echo "source toolchain folder size:"
du -hs openwrt/
sudo mkdir -p output
sudo chown -R $USER:$GROUPS /workdir/output
ln -sf /workdir/output $GITHUB_WORKSPACE/output
echo
tar -czf output/output_toolchain.tar.gz openwrt/
echo "source toolchain file size:"
cd output
ls -lh output_toolchain.tar.gz
echo "SOURCE_TOOLCHAIN_PATH=$PWD" >> $GITHUB_OUTPUT
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload Source To Artifact
uses: actions/upload-artifact@v4
if: steps.generate_image.outputs.status == 'success'
with:
name: Source_${{ matrix.source_code_platform }}_${{ matrix.platform }}
path: ${{ steps.generate_image.outputs.SOURCE_TOOLCHAIN_PATH }}/output_toolchain.tar.gz
retention-days: 5
job_build:
needs: [job_init, job_source_init, job_generate_release_tag, job_build_toolchain]
runs-on: ${{ matrix.value.OS }}
if: ${{ always() }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.job_init.outputs.platforms) }}
name: Build-${{ matrix.source_code_platform }}-${{ matrix.platform }}
steps:
- name: Initialization Environment
run: |
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown -R $USER:$GROUPS /workdir
df -hT
- name: Maximize Build Space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 6144
swap-size-mb: 10240
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-docker-images: 'true'
build-mount-path: '/workdir'
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Pull the latest changes
run: git pull origin ${{ github.ref_name }}
- name: Install Packages
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get -qq update
sudo -E apt-get -qq install $(curl -fsSL https://github.com/smallprogram/OpenWrtAction/raw/main/diy_script/${{ matrix.source_code_platform }}_dependence)
# sudo -E apt-get -qq autoremove --purge
# sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
df -hT
- name: Initialization Directory
working-directory: /workdir
id: init_directory
run: |
sudo mkdir -p openwrt
sudo mkdir -p download
sudo chown -R $USER:$GROUPS /workdir/openwrt
sudo chown -R $USER:$GROUPS /workdir/download
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
ln -sf /workdir/download $GITHUB_WORKSPACE/download
- name: Download Source From Artifacts
id : download
uses: actions/download-artifact@v4
with:
name: Source_${{ matrix.source_code_platform }}_${{ matrix.platform }}
path: download
- name: File Extraction
working-directory: /workdir
run: |
echo "source packages size:"
ls -lh download/output_toolchain.tar.gz
tar -xzf download/output_toolchain.tar.gz
rm -rf download/output_toolchain.tar.gz
sudo chown -R $USER:$GROUPS /workdir/openwrt
- name: SSH connection to Actions
uses: mxschmitt/action-tmate@v3.16
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
- name: Generate Frimware
id: compile
run: |
cd openwrt
is_complie_error=0
if [[ "${{ github.event.inputs.is_display_detailed }}" == "true" ]]; then
if [[ "${{ github.event.inputs.is_single_threaded }}" == "true" ]]; then
echo "1 threads compile frimware"
make -j1 V=s
is_complie_error=${PIPESTATUS[0]}
else
echo "$(nproc) threads compile frimware"
make -j$(nproc) V=s
is_complie_error=${PIPESTATUS[0]}
fi
else
if [[ "${{ github.event.inputs.is_single_threaded }}" == "true" ]]; then
echo "1 threads compile frimware"
make -j1
is_complie_error=${PIPESTATUS[0]}
else
echo "$(nproc) threads compile frimware"
make -j$(nproc)
is_complie_error=${PIPESTATUS[0]}
fi
fi
echo "complie result: $is_complie_error"
if [ "$is_complie_error" -eq 0 ]; then
echo "status=success" >> $GITHUB_OUTPUT
else
echo "status=failure" >> $GITHUB_OUTPUT
exit $is_complie_error
fi
df -hT
- name: Check Space Usage
if: (!cancelled())
run: df -hT
- name: Upload Bin Directory To Artifact
uses: actions/upload-artifact@v4
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
with:
name: OpenWrt_bin_${{ matrix.source_code_platform }}_${{ matrix.platform }}
path: openwrt/bin
- name: Organize Files
id: organize
if: steps.compile.outputs.status == 'success' && env.UPLOAD_FIRMWARE == 'true' && !cancelled()
run: |
# rm -rf $GITHUB_WORKSPACE/openwrt/bin
# mkdir -p $GITHUB_WORKSPACE/openwrt/bin
# mkdir -p $GITHUB_WORKSPACE/openwrt/bin/targets
# mkdir -p $GITHUB_WORKSPACE/openwrt/bin/targets/aa
# mkdir -p $GITHUB_WORKSPACE/openwrt/bin/targets/aa/bb
# cd $GITHUB_WORKSPACE/openwrt/bin/targets/*/*
# mkdir -p feeds_packages
# firmware_path=$PWD
# dd if=/dev/zero of=${{ matrix.source_code_platform }}_${{ matrix.platform }}.txt bs=1M count=10
# if [[ "${{ matrix.source_code_platform }}" == "lede" ]]; then
# exit 200
# fi
cd $GITHUB_WORKSPACE/openwrt/bin/targets/*/*
mkdir -p feeds_packages
firmware_path=$PWD
cd $GITHUB_WORKSPACE/openwrt/bin/packages/*/
mv * $firmware_path/feeds_packages
cd $firmware_path
# zip -r buildinfo_${{ matrix.source_code_platform }}_${{ matrix.platform }}.zip feeds_packages packages sha256sums version.buildinfo config.buildinfo feeds.buildinfo
# rm -rf packages feeds_packages sha256sums version.buildinfo config.buildinfo feeds.buildinfo
find . ! -name '*-*-*' -exec zip buildinfo_${{ matrix.source_code_platform }}_${{ matrix.platform }}.zip {} +
find . -mindepth 1 ! \( -name '*-*-*' -o -name '*.zip' \) -exec rm -rf {} +
if [[ "${{ matrix.source_code_platform }}" == "lede" ]]; then
for file in openwrt-*; do
if [[ -f "$file" ]]; then
mv "$file" "${file/openwrt-/lean-}"
fi
done
fi
ls
echo "FIRMWARE=$firmware_path" >> $GITHUB_OUTPUT
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload Firmware Directory To Artifact
uses: actions/upload-artifact@v4
if: steps.organize.outputs.status == 'success' && env.UPLOAD_ARTIFACT == 'true' && !cancelled()
with:
name: ${{ matrix.source_code_platform }}_${{ matrix.platform }}_firmware
path: ${{ steps.organize.outputs.FIRMWARE }}
job_upload_release:
needs: [job_init, job_source_init, job_generate_release_tag, job_build_toolchain, job_build]
runs-on: ${{ matrix.value.OS }}
if: ${{ always() }}
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.job_init.outputs.platforms) }}
name: Upload-${{ matrix.source_code_platform }}-${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Initialization Environment
id: init
run: |
sudo timedatectl set-timezone "$TZ"
df -hT
cd $GITHUB_WORKSPACE
sudo mkdir -p release_download
sudo mkdir -p release_tag_download
sudo chown -R $USER:$GROUPS $GITHUB_WORKSPACE/release_download
sudo chown -R $USER:$GROUPS $GITHUB_WORKSPACE/release_tag_download
cd release_download
echo "release_dir=$PWD" >> $GITHUB_OUTPUT
cd ..
cd release_tag_download
echo "release_tag_dir=$PWD" >> $GITHUB_OUTPUT
- name: Download Release From Artifacts
id : download
uses: actions/download-artifact@v4
with:
name: ${{ matrix.source_code_platform }}_${{ matrix.platform }}_firmware
path: ${{ steps.init.outputs.release_dir }}
- name: Download Tags
uses: actions/download-artifact@v4
with:
name: release_tag
path: ${{ steps.init.outputs.release_tag_dir }}
- name: File Show
run: |
echo "release files:"
echo "---------------------------------------------"
cd ${{ steps.init.outputs.release_dir }}
ls
echo "-------------end release files---------------"
cd ..
echo "release tag:"
echo "---------------------------------------------"
cd ${{ steps.init.outputs.release_tag_dir }}
ls
echo "-------------end release tag-----------------"
- name: SSH connection to Actions
uses: mxschmitt/action-tmate@v3.16
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
- name: Upload Firmware To Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.job_init.outputs.output_release_tag }}
body_path: ${{ steps.init.outputs.release_tag_dir }}/release.txt
files: |
${{ steps.init.outputs.release_dir }}/*
job_organize_tags:
needs: [job_init, job_source_init, job_generate_release_tag, job_build_toolchain, job_build, job_upload_release]
if: ${{ always() }}
runs-on: ubuntu-24.04
name: Organize-Release-Tags
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Pull the latest changes
run: |
git pull origin ${{ github.ref_name }}
- name: Download Tags
uses: actions/download-artifact@v4
with:
name: release_tag
- name: Organize Tags
id: organize_tags
# env:
# GH_TOKEN: ${{ github.token }}
run: |
chmod +x $ORGANIZE_TAG_SH
$GITHUB_WORKSPACE/$ORGANIZE_TAG_SH "${{ github.token }}" "${{ github.repository }}" "${{ github.run_id }}" "${{ fromJSON(github.run_attempt) }}" "3"
- name: Upload Tags To Artifact
uses: actions/upload-artifact@v4
with:
name: release_tag_final_attempt_${{ fromJSON(github.run_attempt) }}
path: release.txt
retention-days: 5
- name: Update Release Tag
uses: softprops/action-gh-release@v2
if: steps.organize_tags.outputs.status == 'success'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.job_init.outputs.output_release_tag }}
body_path: release.txt
rerun-failed-jobs:
runs-on: ubuntu-24.04
needs: [job_init, job_source_init, job_generate_release_tag, job_build_toolchain, job_build, job_upload_release, job_organize_tags]
if: failure() && fromJSON(github.run_attempt) < 3 && !cancelled()
steps:
- name: Rerun failed jobs in the current workflow
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
run: |
echo "Retry failed jobs for the ${{ fromJSON(github.run_attempt) }} time, Retry 3 times in total"
gh workflow run Retry_Failure_Jobs.yml -F run_id=${{ github.run_id }}
final-execution-jobs:
runs-on: ubuntu-24.04
needs: [rerun-failed-jobs]
if: ${{ always() }}
steps:
- name: Trigger build
if: ${{ needs.rerun-failed-jobs.result == 'skipped' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.MY_SECRET_PAT }}
repository: smallprogram/MyAction
event-type: openwrt_compilation_completed