瀏覽代碼

Refactor build timestamp handling in workflows to set SOURCE_DATE_EPOCH and KBUILD_BUILD_TIMESTAMP from kernel commit

TheWildJames 3 月之前
父節點
當前提交
fabd753e8f
共有 2 個文件被更改,包括 8 次插入10 次删除
  1. 0 10
      .github/actions/apply-kernel-branding/action.yml
  2. 8 0
      .github/workflows/build.yml

+ 0 - 10
.github/actions/apply-kernel-branding/action.yml

@@ -54,16 +54,6 @@ runs:
 
         : > .scmversion
 
-        echo "Getting last commit timestamp from kernel source..."
-
-        COMMIT_TIMESTAMP=$(git log -1 --format=%ct 2>/dev/null || echo "$(date +%s)")
-
-        export SOURCE_DATE_EPOCH=$COMMIT_TIMESTAMP
-        echo "SOURCE_DATE_EPOCH=$COMMIT_TIMESTAMP" >> $GITHUB_ENV
-        
-        export KBUILD_BUILD_TIMESTAMP="@${COMMIT_TIMESTAMP}"
-        echo "KBUILD_BUILD_TIMESTAMP=@${COMMIT_TIMESTAMP}" >> "$GITHUB_ENV"
-
     - name: Apply Kernel Configuration
       if: ${{ inputs.variant == 'Wild' }}
       shell: bash

+ 8 - 0
.github/workflows/build.yml

@@ -76,6 +76,14 @@ jobs:
         os_patch_level: ${{ inputs.os_patch_level }}
         use_repo: ${{ inputs.use_repo }}
 
+    - name: Set Build Timestamp from Kernel Commit
+      shell: bash
+      run: |
+        SOURCE_DATE_EPOCH=$(git -C "${{ github.workspace }}/kernel/common" log -1 --format=%ct 2>/dev/null || date -u +%s)
+        echo "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH" >> $GITHUB_ENV
+        echo "KBUILD_BUILD_TIMESTAMP=$(date -u -d @${SOURCE_DATE_EPOCH} '+%a %b %d %H:%M:%S UTC %Y')" >> $GITHUB_ENV
+        echo "Build timestamp set to: $(date -u -d @${SOURCE_DATE_EPOCH} '+%Y-%m-%d %H:%M:%S UTC')"
+
     - name: Extract Sublevel and Set File Name
       id: extract
       uses: ./.github/actions/extract-sublevel-file-name