Skip to content

Commit

Permalink
update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Gzxhwq committed Feb 16, 2024
1 parent ddc1c0c commit 32f2529
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 151 deletions.
48 changes: 13 additions & 35 deletions .github/workflows/build-openwrt-n1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ env:
DIY_P2_SH: n1-diy-part2.sh
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_COWTRANSFER: false
UPLOAD_WETRANSFER: true
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
FILE_NAME: Phicomm_N1
Expand All @@ -38,10 +36,13 @@ env:
jobs:
build:
runs-on: ubuntu-22.04
permissions:
actions: write
contents: write

steps:
- name: Checkout
uses: actions/checkout@main
uses: actions/checkout@v4

- name: Initialization environment
env:
Expand Down Expand Up @@ -69,7 +70,7 @@ jobs:
echo "DATE1=$(date "+%Y-%m-%d")" >> $GITHUB_ENV
- name: Cache
uses: klever1988/cachewrtbuild@main
uses: stupidloud/cachewrtbuild@main
with:
ccache: 'true'
prefix: ${{ github.workspace }}/openwrt
Expand Down Expand Up @@ -97,11 +98,8 @@ jobs:
$GITHUB_WORKSPACE/$DIY_P2_SH
- name: SSH connection to Actions
uses: P3TERX/ssh2actions@v1.0.0
uses: mxschmitt/action-tmate@v3
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
env:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}

- name: Download package
id: package
Expand All @@ -128,7 +126,7 @@ jobs:
run: df -hT

- name: Upload bin directory
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v4
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
with:
name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
Expand Down Expand Up @@ -157,50 +155,30 @@ jobs:
OPENWRT_VER: 21.02-SNAPSHOT
SCRIPT_REPO_URL: Gzxhwq/openwrt_packit
SCRIPT_REPO_BRANCH: master
GH_TOKEN: ${{ secrets.GH_TOKEN }}

- name: Upload firmware directory
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v4
if: steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: ${{ env.FIRMWARE }}

- name: Upload artifact to Actions
uses: kittaakos/upload-artifact-as-is@master
uses: kittaakos/upload-artifact-as-is@v0
if: env.PACKAGED_STATUS == 'success' && env.UPLOAD_FIRMWARE == 'true' && !cancelled()
with:
path: ${{ env.PACKAGED_OUTPUTPATH }}/

- name: Upload firmware to cowtransfer
id: cowtransfer
if: env.PACKAGED_STATUS == 'success' && env.UPLOAD_COWTRANSFER == 'true' && !cancelled()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer cow --block 2621440 -s -p 64 --no-progress ${{ env.PACKAGED_OUTPUTPATH }}/openwrt_s905d_n1_* 2>&1 | tee cowtransfer.log
echo "::warning file=cowtransfer.com::$(cat cowtransfer.log | grep https)"
echo "url=$(cat cowtransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT
- name: Upload firmware to WeTransfer
id: wetransfer
if: env.PACKAGED_STATUS == 'success' && env.UPLOAD_WETRANSFER == 'true' && !cancelled()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer wet -s -p 16 --no-progress ${PACKAGED_OUTPUTPATH} 2>&1 | tee wetransfer.log
echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)"
echo "url=$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT
- name: Upload OpenWrt Firmware to Release
id: release
uses: ncipollo/release-action@main
uses: ncipollo/release-action@v1
if: env.PACKAGED_STATUS == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
name: R${{ env.DATE }} for ${{ env.FILE_NAME }}
allowUpdates: true
removeArtifacts: true
tag: ${{ env.FILE_NAME }}
commit: main
token: ${{ secrets.GH_TOKEN }}
artifacts: ${{ env.PACKAGED_OUTPUTPATH }}/*
body: |
默认IP:192.168.0.1 默认密码:password
Expand All @@ -209,16 +187,16 @@ jobs:
${{ env.useVersionInfo }}
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
uses: Mattraks/delete-workflow-runs@v2
with:
retain_days: 7
keep_minimum_runs: 10

- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@master
uses: dev-drprasad/delete-older-releases@v0.3.2
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 3
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70 changes: 34 additions & 36 deletions .github/workflows/build-openwrt-rpi4b.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ env:
DIY_P2_SH: rpi4b-diy-part2.sh
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_COWTRANSFER: false
UPLOAD_WETRANSFER: true
UPLOAD_RELEASE: false
TZ: Asia/Shanghai
FILE_NAME: rpi4b

jobs:
build:
runs-on: ubuntu-22.04
permissions:
actions: write
contents: write

steps:
- name: Checkout
uses: actions/checkout@main
uses: actions/checkout@v4

- name: Initialization environment
env:
Expand All @@ -60,9 +62,14 @@ jobs:
df -hT $PWD
git clone $REPO_URL -b $REPO_BRANCH openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
cd openwrt
useVersionInfo=$(git show -s --date=short --format="Author: %an<br/>date: %cd<br/>commit: %s<br/>commit hash: %H")
echo "useVersionInfo=$useVersionInfo" >> $GITHUB_ENV
echo "DATE=$(date "+%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV
echo "DATE1=$(date "+%Y-%m-%d")" >> $GITHUB_ENV
- name: Cache
uses: klever1988/cachewrtbuild@main
uses: stupidloud/cachewrtbuild@main
with:
ccache: 'true'
prefix: ${{ github.workspace }}/openwrt
Expand Down Expand Up @@ -90,11 +97,8 @@ jobs:
$GITHUB_WORKSPACE/$DIY_P2_SH
- name: SSH connection to Actions
uses: P3TERX/ssh2actions@v1.0.0
uses: mxschmitt/action-tmate@v3
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
env:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}

- name: Download package
id: package
Expand All @@ -121,77 +125,71 @@ jobs:
run: df -hT

- name: Upload bin directory
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v4
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
with:
name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: openwrt/bin

- name: Organize files
id: organize
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()
if: steps.compile.outputs.status == 'success' && env.UPLOAD_FIRMWARE == 'true' && !cancelled()
run: |
cd openwrt/bin/targets/*/*
rm -rf packages
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware directory
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v4
if: steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: ${{ env.FIRMWARE }}

- name: Upload firmware to cowtransfer
id: cowtransfer
if: steps.organize.outputs.status == 'success' && env.UPLOAD_COWTRANSFER == 'true' && !cancelled()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer cow --block 2621440 -s -p 64 --no-progress ${FIRMWARE} 2>&1 | tee cowtransfer.log
echo "::warning file=cowtransfer.com::$(cat cowtransfer.log | grep https)"
echo "url=$(cat cowtransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT
- name: Upload firmware to WeTransfer
id: wetransfer
if: steps.organize.outputs.status == 'success' && env.UPLOAD_WETRANSFER == 'true' && !cancelled()
run: |
curl -fsSL git.io/file-transfer | sh
./transfer wet -s -p 16 --no-progress ${FIRMWARE} 2>&1 | tee wetransfer.log
echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)"
echo "url=$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT
- name: Generate release tag
id: tag
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
run: |
echo "release_tag=$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_OUTPUT
touch release.txt
[ $UPLOAD_COWTRANSFER = true ] && echo "🔗 [Cowtransfer](${{ steps.cowtransfer.outputs.url }})" >> release.txt
[ $UPLOAD_WETRANSFER = true ] && echo "🔗 [WeTransfer](${{ steps.wetransfer.outputs.url }})" >> release.txt
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware to release
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*

- name: Upload OpenWrt Firmware to Release
id: release
if: steps.compile.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
uses: ncipollo/release-action@v1
with:
name: R${{ env.DATE }} for ${{ env.FILE_NAME }}
allowUpdates: true
removeArtifacts: true
tag: ${{ env.FILE_NAME }}
commit: main
artifacts: ${{ env.FIRMWARE }}/*
body: |
- 默认IP:10.10.10.100 默认密码:password
- 当前使用版本:【编译前的最后一次[➦主源码](https://github.com/immortalwrt/immortalwrt/tree/openwrt-21.02)更新记录】
${{ env.useVersionInfo }}
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
uses: Mattraks/delete-workflow-runs@v2
with:
retain_days: 7
keep_minimum_runs: 10

- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@master
uses: dev-drprasad/delete-older-releases@v0.3.2
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 3
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 32f2529

Please sign in to comment.