release #668
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| program: | |
| description: '软件名称' | |
| required: true | |
| type: choice | |
| options: | |
| - openresty | |
| - nezha-agent | |
| - nezha-server | |
| - onedrive | |
| - openssh | |
| - frp | |
| - gitea | |
| - openlist | |
| - git | |
| - vaultwarden | |
| - hysteria | |
| - openssl | |
| - xray | |
| - nodejs | |
| - uptime-kuma | |
| - electerm | |
| - new-api | |
| - codetiger-util | |
| - minio | |
| - openlist-api | |
| - copilot-proxies | |
| - nacos | |
| - eureka | |
| - xxl-job-admin | |
| - rustfs | |
| version: | |
| description: '软件版本' | |
| required: true | |
| default: '1.0' | |
| remove: | |
| description: '是否删除历史版本' | |
| required: false | |
| default: 'true' | |
| type: choice | |
| options: | |
| - 'true' | |
| - 'false' | |
| ssh: | |
| description: '是否开启ssh调试' | |
| required: true | |
| default: 'false' | |
| type: choice | |
| options: | |
| - 'true' | |
| - 'false' | |
| env: | |
| REMOVE_WORKFLOW_RUNS: true | |
| jobs: | |
| build: | |
| name: build-rpms-${{ github.event.inputs.program }}-${{ matrix.arch }}-${{ matrix.release }} | |
| runs-on: ${{ matrix.arch == 'x86_64' && 'ubuntu-latest' || matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: | |
| - x86_64 | |
| - aarch64 | |
| release: | |
| - 9 | |
| - 10 | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Initialization environment | |
| env: | |
| DEBIAN_FRONTEND: noninteractive | |
| run: | | |
| sudo rm -rf /etc/localtime | |
| sudo ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | |
| # sudo apt remove php* dotnet* google* | |
| sudo rm -rf \ | |
| /usr/share/dotnet \ | |
| /etc/mysql \ | |
| /etc/php | |
| # 初始化环境变量 | |
| - name: init-env | |
| run: | | |
| echo "export project_program=${{ github.event.inputs.program }}" >> $HOME/.profile | |
| echo "export project_version=${{ github.event.inputs.version }}" >> $HOME/.profile | |
| echo "export project_arch=${{ matrix.arch }}" >> $HOME/.profile | |
| source $HOME/.profile | |
| - name: run-redhat ${{ github.event.inputs.program }}-${{ matrix.arch }} | |
| # 出错继续 | |
| continue-on-error: true | |
| run: | | |
| mkdir rpm | |
| case ${{ matrix.arch }} in | |
| aarch64) | |
| echo "使用arm64编译" | |
| ;; | |
| x86_64) | |
| echo "使用x86编译" | |
| ;; | |
| *) | |
| echo "未知架构,请检查" | |
| exit 0 | |
| ;; | |
| esac | |
| centos=`docker run -itd -v $(pwd)/rpm:/opt ghcr.io/codetiger666/images/rocky:${{ matrix.release }}` | |
| echo "export centos=$centos" >> $HOME/.profile | |
| source $HOME/.profile | |
| docker cp $GITHUB_WORKSPACE/.rpmmacros $centos:/root/.rpmmacros | |
| docker exec -i $centos rpmdev-setuptree | |
| docker cp $GITHUB_WORKSPACE/.rpmmacros $centos:/root/.rpmmacros | |
| - name: init ${{ github.event.inputs.program }}-${{ matrix.arch }} | |
| run: | | |
| source $HOME/.profile | |
| source init/common.sh | |
| if [ -f "./scripts/${{ github.event.inputs.program }}.sh" ]; | |
| then | |
| source ./scripts/${{ github.event.inputs.program }}.sh | |
| program_init | |
| fi | |
| sudo /bin/cp specs/${{ github.event.inputs.program }}.spec rpm/rpmbuild/SPECS/${{ github.event.inputs.program }}.spec | |
| - name: SSH connection to Actions | |
| uses: P3TERX/ssh2actions@main | |
| 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: build ${{ github.event.inputs.program }}-${{ matrix.arch }} | |
| run: | | |
| source $HOME/.profile | |
| docker stop $centos | |
| docker start $centos | |
| docker cp $GITHUB_WORKSPACE/.rpmmacros $centos:/root/.rpmmacros | |
| docker exec -i $centos rpmbuild -ba --with systemd /opt/rpmbuild/SPECS/${{ github.event.inputs.program }}.spec | |
| # 上传文件 | |
| - name: upload ${{ github.event.inputs.program }}-${{ matrix.arch }} | |
| uses: actions/upload-artifact@main | |
| with: | |
| name: ${{ github.event.inputs.program }}-${{ matrix.arch }}-${{ matrix.release }} | |
| path: rpm/rpmbuild/RPMS/${{ matrix.arch }}/${{ github.event.inputs.program }}*.el${{ matrix.release }}.${{ matrix.arch }}.rpm | |
| - name: send tg message | |
| if: failure() | |
| run: | | |
| arch=${{ matrix.arch }} | |
| source $HOME/.profile | |
| text="\\\\[${project_program//-/\\\\-}\\\\] \\\\[❌ 编译失败\\\\]\n版本\`${project_version//./\\\\.}\`\n架构\`${arch//_/\\\\_}\`" | |
| content=$(cat <<EOF | |
| { | |
| "chat_id": "${{ secrets.TG_BOT_USER_ID }}", | |
| "text": "$text", | |
| "parse_mode": "MarkdownV2" | |
| } | |
| EOF | |
| ) | |
| source $HOME/.profile | |
| curl -X POST \ | |
| --url https://api.telegram.org/bot${{ secrets.TG_BOT_KEY }}/sendMessage \ | |
| --header 'Accept: */*' \ | |
| --header 'Accept-Encoding: gzip, deflate, br' \ | |
| --header 'Connection: keep-alive' \ | |
| --header 'Content-Type: application/json' \ | |
| --data "$content" | |
| upload: | |
| name: upload-rpms-${{ github.event.inputs.program }} | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: ${{ github.event.inputs.program }} checkout_rpm | |
| uses: actions/checkout@v2 | |
| with: | |
| ref: release | |
| - name: download ${{ github.event.inputs.program }} artifact | |
| uses: actions/download-artifact@main | |
| with: | |
| path: artifacts | |
| # 初始化环境变量 | |
| - name: init-env | |
| run: | | |
| echo "export project_program=${{ github.event.inputs.program }}" >> $HOME/.profile | |
| echo "export project_version=${{ github.event.inputs.version }}" >> $HOME/.profile | |
| source $HOME/.profile | |
| - name: upload ${{ github.event.inputs.program }} | |
| run: | | |
| source $HOME/.profile | |
| archs=("x86_64" "aarch64") | |
| releases=("9" "10") | |
| git pull | |
| for arch in "${archs[@]}"; do | |
| for release in "${releases[@]}"; do | |
| sudo mkdir -p redhat/$release/$arch/ | |
| if [ "${{ github.event.inputs.remove }}" = "true" ]; | |
| then | |
| sudo rm -f redhat/$release/$arch/${{ github.event.inputs.program }}*.$arch.rpm | |
| fi | |
| sudo /bin/cp -ra artifacts/${{ github.event.inputs.program }}-$arch-$release/${{ github.event.inputs.program }}*.el$release.$arch.rpm redhat/$release/$arch | |
| done | |
| done | |
| rm -rf $GITHUB_WORKSPACE/artifacts | |
| rpms=`docker run -itd -v $GITHUB_WORKSPACE:/centos_rpms ghcr.io/codetiger666/images/rocky:9` | |
| for release in "${releases[@]}"; do | |
| for arch in "${archs[@]}"; do | |
| docker exec -i $rpms createrepo /centos_rpms/redhat/$release/$arch | |
| done | |
| done | |
| - name: git add | |
| run: | | |
| git pull | |
| git config --local user.email ${{ secrets.email }} | |
| git config --local user.name "codetiger666" | |
| # 创建一个新的孤立分支 | |
| git checkout --orphan temp_main | |
| # 添加所有文件并进行提交 | |
| git add -A | |
| git commit -m "update" | |
| git branch -D release | |
| git branch -m release | |
| git push -f origin release | |
| update: | |
| name: update-version-${{ github.event.inputs.program }} | |
| runs-on: ubuntu-latest | |
| needs: upload | |
| steps: | |
| - name: checkout | |
| uses: actions/checkout@v3 | |
| # 初始化环境变量 | |
| - name: init-env | |
| run: | | |
| echo "export project_program=${{ github.event.inputs.program }}" >> $HOME/.profile | |
| echo "export project_version=${{ github.event.inputs.version }}" >> $HOME/.profile | |
| echo "export project_arch=${{ matrix.arch }}" >> $HOME/.profile | |
| source $HOME/.profile | |
| - name: git init | |
| run: | | |
| git config --global user.email ${{ secrets.email }} | |
| git config --global user.name "codetiger666" | |
| git config pull.rebase true | |
| - name: update version | |
| run: | | |
| # 替换版本 | |
| echo '开始替换版本' | |
| perl -i -pe "s/${{ github.event.inputs.program }}---((?!---)[0-9A-Za-z.\-])*/${{ github.event.inputs.program }}---${{ github.event.inputs.version }}/" version | |
| echo '替换版本完成' | |
| git add . | |
| git commit -m "chore: ${{ github.event.inputs.program }} bump version to ${{ github.event.inputs.version }}" | |
| git pull && git push | |
| - name: send tg message | |
| run: | | |
| source $HOME/.profile | |
| curl -X POST \ | |
| --url https://api.telegram.org/bot${{ secrets.TG_BOT_KEY }}/sendMessage \ | |
| --header 'Accept: */*' \ | |
| --header 'Accept-Encoding: gzip, deflate, br' \ | |
| --header 'Connection: keep-alive' \ | |
| --header 'Content-Type: application/json' \ | |
| --data "{ | |
| \"chat_id\": \"${{ secrets.TG_BOT_USER_ID }}\", | |
| \"text\": \"\\\\[${project_program//-/\\\\-}\\\\] \\\\[✅ 编译成功\\\\]\n版本\`${project_version//./\\\\.}\`\", | |
| \"parse_mode\": \"MarkdownV2\" | |
| }" |