diff --git a/.gitea/workflows/7zip_update.yml b/.gitea/workflows/7zip_update.yml deleted file mode 100644 index 5a87206..0000000 --- a/.gitea/workflows/7zip_update.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: Update 7-Zip Binaries - -on: - schedule: - - cron: '0 0 * * *' # Daily at midnight UTC - workflow_dispatch: # Allow manual trigger - -jobs: - update: - runs-on: ubuntu-latest # Adjust to your runner OS - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITEA_TOKEN }} - - - name: Set up environment - run: | - # Install dependencies (e.g., curl, git) - sudo apt-get update && sudo apt-get install -y curl git jq - # Ensure 7zz is available for extraction (download latest if not in PATH) - if ! command -v 7zz &> /dev/null; then - curl -L https://github.com/ip7z/7zip/releases/latest/download/7zz -o /tmp/7zz - chmod +x /tmp/7zz - export PATH="/tmp:$PATH" - fi - - - name: Fetch latest release - id: release - run: | - RELEASE_INFO=$(curl -s -H "Accept: application/vnd.github+json" \ - -H "Authorization: token ${{ secrets.GH_TOKEN || '' }}" \ - https://api.github.com/repos/ip7z/7zip/releases/latest) - - VERSION=$(echo "$RELEASE_INFO" | jq -r .tag_name | sed 's/v//') # e.g., 25.01 - ASSETS=$(echo "$RELEASE_INFO" | jq -r '.assets[] | "\(.name)|\(.browser_download_url)|\(.size)"') - - echo "version=$VERSION" >> $GITHUB_OUTPUT - echo "assets<> $GITHUB_OUTPUT - echo "$ASSETS" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Download and extract binary - if: steps.release.outputs.version != '' - run: | - VERSION=${{ steps.release.outputs.version }} - mkdir -p /app/7zip/$VERSION - - # Find binary asset (prefer .7z or .tar.gz containing 7zz) - ASSET_URL="" - while IFS='|' read -r name url size; do - if [[ "$name" == *.7z || "$name" == *.tar.gz ]]; then - ASSET_URL="$url" - ASSET_NAME="$name" - break - fi - done <<< "${{ steps.release.outputs.assets }}" - - if [ -z "$ASSET_URL" ]; then - echo "No binary asset found, skipping." - exit 0 - fi - - echo "Downloading $ASSET_NAME..." - curl -L -o /tmp/asset "$ASSET_URL" - - echo "Extracting 7zz..." - cd /tmp - if [[ "$ASSET_NAME" == *.7z ]]; then - 7zz x asset 7zz -o/app/7zip/$VERSION/ - elif [[ "$ASSET_NAME" == *.tar.gz ]]; then - tar -xzf asset --wildcards '*7zz*' -C /app/7zip/$VERSION/ || (echo "Extraction failed, may not contain 7zz"; exit 1) - fi - - chmod +x /app/7zip/$VERSION/7zz - echo "Saved 7zz to /app/7zip/$VERSION/" - - - name: Commit changes - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - - BRANCH="update-7zip-${{ steps.release.outputs.version }}" - git checkout -b $BRANCH - git add /app/7zip/ || true # Add if changes detected - git commit -m "Update 7-Zip to version ${{ steps.release.outputs.version }}" || echo "No changes to commit" - git push origin $BRANCH - - - name: Create Pull Request - if: steps.release.outputs.version != '' - run: | - BRANCH="update-7zip-${{ steps.release.outputs.version }}" - curl -X POST \ - -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \ - -H "Content-Type: application/json" \ - -d '{ - "title": "Update 7-Zip to version ${{ steps.release.outputs.version }}", - "body": "Automated update of 7zz binary from GitHub release.", - "head": "'$BRANCH'", - "base": "main" - }' \ - ${{ secrets.GITEA_INSTANCE_URL || 'https://gitea.com' }}/api/v1/repos/${{ github.repository }}/pulls \ No newline at end of file diff --git a/.gitea/workflows/zellij_update.yml b/.gitea/workflows/zellij_update.yml new file mode 100644 index 0000000..159f79d --- /dev/null +++ b/.gitea/workflows/zellij_update.yml @@ -0,0 +1,81 @@ +# 工作流名称 +name: Zellij 最新版本自动更新 + +# 触发器配置 +on: + # 1. 定时触发 (Cron 表达式: 每天 UTC 时间 00:00 运行) + schedule: + - cron: '0 0 * * *' + # 2. 允许手动通过 Gitea UI 触发 + workflow_dispatch: + +# 定义 Job +jobs: + update_zellij_binary: + # 运行环境 + runs-on: ubuntu-latest + + steps: + - name: 检出仓库代码 (Checkout Repository) + uses: actions/checkout@v4 + with: + # 使用 Gitea Token 来允许推送操作 + token: ${{ secrets.GITEA_TOKEN }} + # 或使用 Gitea 默认的内置 token,但 Gitea 对其支持可能因版本而异。如果默认 token 无法推送,请改用 GITEA_TOKEN secret。 + # token: ${{ secrets.GITHUB_TOKEN }} # (Gitea Actions 通常也识别此变量名) + + - name: 设置 Git 用户信息 (Set up Git user) + run: | + git config user.name "Gitea Actions Bot" + git config user.email "gitea-actions[bot]@example.com" + + - name: 定义变量 (Define Variables) + id: vars + run: | + # 最新版本的下载链接 + RELEASE_URL="https://github.com/zellij-org/zellij/releases/latest/download/zellij-x86_64-unknown-linux-musl.tar.gz" + # 仓库内的目标目录 + TARGET_DIR="app/zellij" + echo "RELEASE_URL=$RELEASE_URL" >> $GITHUB_ENV + echo "TARGET_DIR=$TARGET_DIR" >> $GITHUB_ENV + + - name: 下载、解压并放置 Zellij 二进制文件 (Download, Extract, and Place Zellij Binary) + run: | + # 确保目标目录存在 + mkdir -p ${{ env.TARGET_DIR }} + + echo "开始下载最新的 Zellij 二进制文件..." + # 使用 curl 下载文件到临时位置 + curl -sSL -o zellij.tar.gz "${{ env.RELEASE_URL }}" + + # 解压文件,会释放出一个名为 'zellij' 的二进制文件 + tar -xzf zellij.tar.gz + + # 将二进制文件移动到指定的目录,并重命名为 'zellij' (如果它不是) + mv zellij ${{ env.TARGET_DIR }}/zellij + + # 赋予执行权限 + chmod +x ${{ env.TARGET_DIR }}/zellij + + # 清理下载的压缩包 + rm zellij.tar.gz + + - name: 检查更改并创建提交 (Check for Changes and Commit) + id: commit + run: | + # 检查目标文件是否发生了变化 + if git diff --exit-code ${{ env.TARGET_DIR }}/zellij ; then + echo "status=no-change" >> $GITHUB_OUTPUT + echo "::notice file=${{ env.TARGET_DIR }}/zellij::Zellij 二进制文件没有变化,跳过提交。" + else + echo "status=changed" >> $GITHUB_OUTPUT + git add ${{ env.TARGET_DIR }}/zellij + git commit -m "chore(deps): 自动更新 Zellij 到最新版本" + echo "::notice file=${{ env.TARGET_DIR }}/zellij::发现新版本 Zellij,已创建提交。" + fi + + - name: 推送更改到 Gitea (Push Changes to Gitea) + # 仅当检测到文件变化时才推送 + if: steps.commit.outputs.status == 'changed' + run: | + git push