From 6a5fbe7ef112c77cc285dcdacfffbee28a76e4a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Wed, 2 Jul 2025 22:56:55 +0800 Subject: [PATCH] feat: optimize CI triggers and add latest version tracking to OSS (#33) * feat: optimize CI triggers and add latest version tracking to OSS * feat: optimize CI triggers and add latest version tracking to OSS --- .github/workflows/build.yml | 53 +++++++++++++++++++++++++++++++----- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++-- .github/workflows/docker.yml | 9 +++--- 3 files changed, 90 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 85a99314..44347dec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,13 +19,19 @@ on: schedule: - cron: "0 0 * * 0" # at midnight of each sunday push: + tags: ["v*", "*"] branches: - main - tags: ["v*", "*"] jobs: build-rustfs: runs-on: ${{ matrix.os }} + # Only execute in the following cases: 1) tag push 2) scheduled run 3) commit message contains --build + if: | + startsWith(github.ref, 'refs/tags/') || + github.event_name == 'schedule' || + github.event_name == 'workflow_dispatch' || + contains(github.event.head_commit.message, '--build') strategy: fail-fast: false matrix: @@ -382,12 +388,6 @@ jobs: fi echo "ossutil2 installation completed" - # Set the OSS configuration - # ossutil config set Region oss-cn-beijing - # ossutil config set endpoint oss-cn-beijing.aliyuncs.com - # ossutil config set accessKeyID ${{ secrets.ALICLOUDOSS_KEY_ID }} - # ossutil config set accessKeySecret ${{ secrets.ALICLOUDOSS_KEY_SECRET }} - - name: Upload to Aliyun OSS if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main' shell: bash @@ -403,6 +403,44 @@ jobs: ossutil cp "${{ steps.package.outputs.artifact_name }}.zip" "oss://rustfs-artifacts/artifacts/rustfs/${{ steps.package.outputs.artifact_name }}.latest.zip" --force echo "Successfully uploaded artifacts to OSS" + # Create and upload latest version info + - name: Create and Upload latest.json + if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest' && matrix.variant.target == 'x86_64-unknown-linux-musl' + shell: bash + env: + OSS_ACCESS_KEY_ID: ${{ secrets.ALICLOUDOSS_KEY_ID }} + OSS_ACCESS_KEY_SECRET: ${{ secrets.ALICLOUDOSS_KEY_SECRET }} + OSS_REGION: cn-beijing + OSS_ENDPOINT: https://oss-cn-beijing.aliyuncs.com + run: | + echo "::group::Creating latest.json file" + + # Extract version from tag (remove 'refs/tags/' prefix) + VERSION="${GITHUB_REF#refs/tags/}" + # Remove 'v' prefix if present + VERSION="${VERSION#v}" + + # Get current timestamp in ISO 8601 format + RELEASE_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + + # Create latest.json content + cat > latest.json << EOF + { + "version": "${VERSION}", + "release_date": "${RELEASE_DATE}", + "release_notes": "Release ${VERSION}", + "download_url": "https://github.com/rustfs/rustfs/releases/tag/${GITHUB_REF#refs/tags/}" + } + EOF + + echo "Generated latest.json:" + cat latest.json + + echo "::group::Uploading latest.json to OSS" + # Upload latest.json to rustfs-version bucket + ossutil cp latest.json "oss://rustfs-version/latest.json" --force + echo "Successfully uploaded latest.json to OSS" + # Determine whether to perform GUI construction based on conditions - name: Prepare for GUI build if: startsWith(github.ref, 'refs/tags/') @@ -535,6 +573,7 @@ jobs: merge: runs-on: ubuntu-latest needs: [build-rustfs] + # Only execute merge operation when tag is pushed if: startsWith(github.ref, 'refs/tags/') steps: - uses: actions/upload-artifact/merge@v4 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c7bb208..62942408 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,11 +18,47 @@ on: push: branches: - main + paths-ignore: + - "**.md" + - "**.txt" + - "docs/**" + - "deploy/**" + - "scripts/dev_*.sh" + - "scripts/probe.sh" + - "LICENSE*" + - ".gitignore" + - ".dockerignore" + - "README*" + - "**/*.png" + - "**/*.jpg" + - "**/*.svg" + - ".github/workflows/build.yml" + - ".github/workflows/docker.yml" + - ".github/workflows/audit.yml" + - ".github/workflows/samply.yml" pull_request: branches: - main + paths-ignore: + - "**.md" + - "**.txt" + - "docs/**" + - "deploy/**" + - "scripts/dev_*.sh" + - "scripts/probe.sh" + - "LICENSE*" + - ".gitignore" + - ".dockerignore" + - "README*" + - "**/*.png" + - "**/*.jpg" + - "**/*.svg" + - ".github/workflows/build.yml" + - ".github/workflows/docker.yml" + - ".github/workflows/audit.yml" + - ".github/workflows/samply.yml" schedule: - - cron: '0 0 * * 0' # at midnight of each sunday + - cron: "0 0 * * 0" # at midnight of each sunday workflow_dispatch: jobs: @@ -37,7 +73,7 @@ jobs: - id: skip_check uses: fkirc/skip-duplicate-actions@v5 with: - concurrent_skipping: 'same_content_newer' + concurrent_skipping: "same_content_newer" cancel_others: true paths_ignore: '["*.md"]' @@ -89,4 +125,4 @@ jobs: - uses: actions/upload-artifact@v4 with: name: s3s-e2e.logs - path: /tmp/rustfs.log \ No newline at end of file + path: /tmp/rustfs.log diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8fa6868d..7cf2985b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,10 +16,10 @@ name: Build and Push Docker Images on: push: - branches: - - main tags: - "v*" + branches: + - main pull_request: branches: - main @@ -28,7 +28,7 @@ on: push_to_registry: description: "Push images to registry" required: false - default: "true" + default: true type: boolean env: @@ -55,7 +55,8 @@ jobs: # Build RustFS binary for different platforms build-binary: needs: skip-check - if: needs.skip-check.outputs.should_skip != 'true' + # Only execute in the following cases: 1) tag push 2) commit message contains --build 3) workflow_dispatch 4) PR + if: needs.skip-check.outputs.should_skip != 'true' && (startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, '--build') || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request') strategy: matrix: include: