Skip to content

Commit

Permalink
自动发布优化 (#6)
Browse files Browse the repository at this point in the history
* add adapt to tcrp and increasing version

* update 1.2.0

* update 1.2.1

* update 1.2.3

* Close the trigger of push

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
wjz304 and github-actions[bot] committed Nov 17, 2022
1 parent 0e3ecfd commit 4d583fe
Show file tree
Hide file tree
Showing 15 changed files with 367 additions and 19 deletions.
135 changes: 116 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@

name: Build
on:
push:
# push:
workflow_dispatch:
inputs:
version:
description: 'tag'
required: false
type: string

jobs:
build:
Expand All @@ -23,40 +28,132 @@ jobs:
uses: actions/checkout@main

- name: Init Env
run : |
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
echo "release_tag=$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_ENV
sudo timedatectl set-timezone "Asia/Shanghai"
- name: Calculate tag
run: |
function increment_version() {
declare -a part=( ${1//\./ } )
declare new
declare -i carry=1
for (( CNTR=${#part[@]}-1; CNTR>=0; CNTR-=1 )); do
len=${#part[CNTR]}
new=$((part[CNTR]+carry))
[ ${#new} -gt $len ] && carry=1 || carry=0
[ $CNTR -gt 0 ] && part[CNTR]=${new: -len} || part[CNTR]=${new}
done
new="${part[*]}"
echo -e "${new// /.}"
}
git clone ${{ github.server_url }}/${{ github.repository }}
cd ${{ github.event.repository.name }}
CUR_TAG=$(git tag -l | tail -1)
NEW_TAG=$(increment_version ${CUR_TAG})
echo CUR_TAG: ${CUR_TAG} NEW_TAG:${NEW_TAG}
if [ -n "${{ inputs.version }}" ]; then
echo "new_tag=${{ inputs.version }}" >> $GITHUB_ENV
else
echo "new_tag=${NEW_TAG}" >> $GITHUB_ENV
fi
echo 'git_log<<EOF' >> $GITHUB_ENV
git log ${CUR_TAG}..HEAD --oneline >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV

cd ..
rm -rf ${{ github.event.repository.name }}

- name: Build igc for ${{matrix.platform}}
run : |
run: |
mkdir ./${{matrix.platform}} && chmod 777 ./${{matrix.platform}}
sudo docker run -u 1000 --rm -t -v "${PWD}":/input -v "${PWD}/${{matrix.platform}}":/output fbelavenuto/syno-compiler compile-module ${{matrix.platform}}
ls -al ${PWD}/${{matrix.platform}}
tar zcvf igc-${{matrix.platform}}.tgz -C./${{matrix.platform}}/ .
rm -rf ${PWD}/${{matrix.platform}}
- name: Upload firmware to artifacts
uses: actions/upload-artifact@v3
if: (!cancelled())
with:
name: igc
path: ./igc-*.tgz

- name: Upload firmware to release
- name: Upload firmware to releases
uses: softprops/action-gh-release@v1
if: (!cancelled())
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.release_tag }}
files: ./igc*.tgz
tag_name: ${{ env.new_tag }}
body: |
Changes:
${{ env.git_log }}
files: ./igc-*.tgz

- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
retain_days: 1
keep_minimum_runs: 9
ext:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@main

- name: Init Env
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
- name: Remove old Releases
uses: dev-drprasad/[email protected]
- name: download to artifacts
uses: actions/download-artifact@v3
with:
keep_latest: 9
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: igc
path: ./

- name: update exts
run: |
ls -al
git clone ${{ github.server_url }}/${{ github.repository }}
cd ${{ github.event.repository.name }}
NEW_TAG=$(git tag -l | tail -1)
cd ..
rm -rf ${{ github.event.repository.name }}
echo NEW_TAG ${NEW_TAG}
echo "new_tag=${NEW_TAG}" >> $GITHUB_ENV
for i in igc-*.tgz
do
echo ${i}
rm -f ./igc/releases/${i}
cp -f ${i} ./igc/releases/${i}
platform=$(echo ${i} | awk -F'[-.]' '{ print $2 }')
configfile=./igc/releases/${platform}_42218.json
sed -i "s/$(jq -r .files[0].sha256 ${configfile})/$(sha256sum ./igc/releases/igc-${platform}.tgz | awk '{print $1}')/g" ${configfile}
sed -i "s/\"$(jq -r .mod_version ${configfile})\"/\"${NEW_TAG}\"/g" ${configfile}
done
baseurl=$(jq -r .url ./igc/rpext-index.json)
repotmp=${baseurl%/master/*}
oldrepo=${repotmp#*.com/}
echo ${oldrepo}
for i in $(find ./igc -name "*.json")
do
echo ${i}
sed -i "s|${oldrepo}|${{ github.repository }}|g" ${i}
done
- name: Commit and Push
run: |
if [ -n "$(git status -s | grep igc/)" ];then
git add ./igc/*
git commit -m "update ${{ env.new_tag }}"
git push -f
fi
27 changes: 27 additions & 0 deletions igc/releases/apollolake_42218.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"mod_version": "1.2.3",

"files": [
{
"name": "igc-apollolake.tgz",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/releases/igc-apollolake.tgz",
"sha256": "88fabe19a7ffcb26cb02c7c7f7bad9c1428cd6f170d5eb4826269b58502c91e1",
"packed": true
},
{
"name": "check-igc.sh",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/src/check-igc.sh",
"sha256": "4892e37cc4f974700b88332e005d61676257876938f8e57677c655a2eca5a8ef",
"packed": false
}
],

"kmods": {
"igc.ko": ""
},

"scripts": {
"on_boot": "check-igc.sh"
}

}
27 changes: 27 additions & 0 deletions igc/releases/broadwell_42218.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"mod_version": "1.2.3",

"files": [
{
"name": "igc-broadwell.tgz",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/releases/igc-broadwell.tgz",
"sha256": "668c458711dd6a2b57c22f093d9155e4acb464d7e15a5960a1ff32b35130eb2a",
"packed": true
},
{
"name": "check-igc.sh",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/src/check-igc.sh",
"sha256": "4892e37cc4f974700b88332e005d61676257876938f8e57677c655a2eca5a8ef",
"packed": false
}
],

"kmods": {
"igc.ko": ""
},

"scripts": {
"on_boot": "check-igc.sh"
}

}
27 changes: 27 additions & 0 deletions igc/releases/broadwellnk_42218.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"mod_version": "1.2.3",

"files": [
{
"name": "igc-broadwellnk.tgz",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/releases/igc-broadwellnk.tgz",
"sha256": "a573a7dc6100a5d79ab236341edce783615c447174527ad58a3399c976d26cd5",
"packed": true
},
{
"name": "check-igc.sh",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/src/check-igc.sh",
"sha256": "4892e37cc4f974700b88332e005d61676257876938f8e57677c655a2eca5a8ef",
"packed": false
}
],

"kmods": {
"igc.ko": ""
},

"scripts": {
"on_boot": "check-igc.sh"
}

}
27 changes: 27 additions & 0 deletions igc/releases/denverton_42218.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"mod_version": "1.2.3",

"files": [
{
"name": "igc-denverton.tgz",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/releases/igc-denverton.tgz",
"sha256": "c4371ff8e2790688f1dc15ea38855274892114fda15f4ff63f1a639956cd1568",
"packed": true
},
{
"name": "check-igc.sh",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/src/check-igc.sh",
"sha256": "c4371ff8e2790688f1dc15ea38855274892114fda15f4ff63f1a639956cd1568",
"packed": false
}
],

"kmods": {
"igc.ko": ""
},

"scripts": {
"on_boot": "check-igc.sh"
}

}
27 changes: 27 additions & 0 deletions igc/releases/geminilake_42218.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"mod_version": "1.2.3",

"files": [
{
"name": "igc-geminilake.tgz",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/releases/igc-geminilake.tgz",
"sha256": "0393d253f1a989f00660007f7a1eaf4b178da633819eaf89eb5b3d97a2b3a9f2",
"packed": true
},
{
"name": "check-igc.sh",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/src/check-igc.sh",
"sha256": "4892e37cc4f974700b88332e005d61676257876938f8e57677c655a2eca5a8ef",
"packed": false
}
],

"kmods": {
"igc.ko": ""
},

"scripts": {
"on_boot": "check-igc.sh"
}

}
Binary file added igc/releases/igc-apollolake.tgz
Binary file not shown.
Binary file added igc/releases/igc-broadwell.tgz
Binary file not shown.
Binary file added igc/releases/igc-broadwellnk.tgz
Binary file not shown.
Binary file added igc/releases/igc-denverton.tgz
Binary file not shown.
Binary file added igc/releases/igc-geminilake.tgz
Binary file not shown.
Binary file added igc/releases/igc-v1000.tgz
Binary file not shown.
27 changes: 27 additions & 0 deletions igc/releases/v1000_42218.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"mod_version": "1.2.3",

"files": [
{
"name": "igc-v1000.tgz",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/releases/igc-v1000.tgz",
"sha256": "866595bcc65f7c50267d2a5bb83813ff86aa1f6d09d602b9d0861512eafd89ff",
"packed": true
},
{
"name": "check-igc.sh",
"url": "https://raw.githubusercontent.com/wjz304/synology-igc/master/igc/src/check-igc.sh",
"sha256": "4892e37cc4f974700b88332e005d61676257876938f8e57677c655a2eca5a8ef",
"packed": false
}
],

"kmods": {
"igc.ko": ""
},

"scripts": {
"on_boot": "check-igc.sh"
}

}
Loading

0 comments on commit 4d583fe

Please sign in to comment.