Fix release artifact checkout ref (#1006)

This commit is contained in:
ZacharyZcR
2026-07-10 08:02:06 +08:00
committed by GitHub
parent b9a995c9cb
commit 37f9402060
3 changed files with 35 additions and 3 deletions
+14 -1
View File
@@ -14,6 +14,10 @@ on:
options: options:
- Development - Development
- Production - Production
source_ref:
description: "Git ref/SHA to build (defaults to the workflow ref)"
required: false
default: ""
workflow_call: workflow_call:
inputs: inputs:
version: version:
@@ -29,6 +33,11 @@ on:
required: false required: false
type: boolean type: boolean
default: false default: false
source_ref:
description: "Git ref/SHA to build"
required: false
type: string
default: ""
jobs: jobs:
build: build:
@@ -37,8 +46,12 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v7
with: with:
ref: ${{ inputs.source_ref || github.ref }}
fetch-depth: 1 fetch-depth: 1
- name: Resolve source revision
run: echo "SOURCE_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v4 uses: docker/setup-qemu-action@v4
with: with:
@@ -98,7 +111,7 @@ jobs:
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
labels: | labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }} org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }} org.opencontainers.image.revision=${{ env.SOURCE_SHA }}
org.opencontainers.image.created=${{ github.run_id }} org.opencontainers.image.created=${{ github.run_id }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
+16
View File
@@ -23,6 +23,10 @@ on:
- file - file
- release - release
- submit - submit
source_ref:
description: "Git ref/SHA to build (defaults to the workflow ref)"
required: false
default: ""
workflow_call: workflow_call:
inputs: inputs:
build_type: build_type:
@@ -38,6 +42,11 @@ on:
required: false required: false
type: string type: string
default: "" default: ""
source_ref:
description: "Git ref/SHA to build"
required: false
type: string
default: ""
outputs: outputs:
macos_universal_dmg_sha256: macos_universal_dmg_sha256:
description: "SHA256 of the universal macOS DMG (for Homebrew cask)" description: "SHA256 of the universal macOS DMG (for Homebrew cask)"
@@ -54,6 +63,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v7
with: with:
ref: ${{ inputs.source_ref || github.ref }}
fetch-depth: 1 fetch-depth: 1
- name: Setup Node.js - name: Setup Node.js
@@ -144,6 +154,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v7
with: with:
ref: ${{ inputs.source_ref || github.ref }}
fetch-depth: 1 fetch-depth: 1
- name: Setup Node.js - name: Setup Node.js
@@ -354,6 +365,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v7
with: with:
ref: ${{ inputs.source_ref || github.ref }}
fetch-depth: 1 fetch-depth: 1
- name: Setup Node.js - name: Setup Node.js
@@ -580,6 +592,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v7
with: with:
ref: ${{ inputs.source_ref || github.ref }}
fetch-depth: 1 fetch-depth: 1
- name: Get version from package.json - name: Get version from package.json
@@ -686,6 +699,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v7
with: with:
ref: ${{ inputs.source_ref || github.ref }}
fetch-depth: 1 fetch-depth: 1
- name: Get version from package.json - name: Get version from package.json
@@ -823,6 +837,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v7
with: with:
ref: ${{ inputs.source_ref || github.ref }}
fetch-depth: 1 fetch-depth: 1
- name: Get version from package.json - name: Get version from package.json
@@ -933,6 +948,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v7
with: with:
ref: ${{ inputs.source_ref || github.ref }}
fetch-depth: 1 fetch-depth: 1
- name: Setup Node.js - name: Setup Node.js
+5 -2
View File
@@ -278,7 +278,7 @@ jobs:
MAIN_SHA=$(gh api repos/${{ github.repository }}/commits/main -q .sha) MAIN_SHA=$(gh api repos/${{ github.repository }}/commits/main -q .sha)
echo "main_sha=$MAIN_SHA" >> "$GITHUB_OUTPUT" echo "main_sha=$MAIN_SHA" >> "$GITHUB_OUTPUT"
echo "build_ref=main" >> "$GITHUB_OUTPUT" echo "build_ref=$MAIN_SHA" >> "$GITHUB_OUTPUT"
docker: docker:
needs: [prep, merge-to-main] needs: [prep, merge-to-main]
@@ -287,6 +287,7 @@ jobs:
version: ${{ needs.prep.outputs.version }} version: ${{ needs.prep.outputs.version }}
build_type: Production build_type: Production
dry_run: ${{ inputs.mode == 'Dry run' }} dry_run: ${{ inputs.mode == 'Dry run' }}
source_ref: ${{ needs.merge-to-main.outputs.build_ref }}
secrets: inherit secrets: inherit
create-release: create-release:
@@ -351,15 +352,17 @@ jobs:
build_type: all build_type: all
artifact_destination: ${{ inputs.mode == 'Dry run' && 'file' || 'release' }} artifact_destination: ${{ inputs.mode == 'Dry run' && 'file' || 'release' }}
release_tag: ${{ needs.prep.outputs.release_tag }} release_tag: ${{ needs.prep.outputs.release_tag }}
source_ref: ${{ needs.merge-to-main.outputs.build_ref }}
secrets: inherit secrets: inherit
electron-submit: electron-submit:
needs: [prep, electron-release] needs: [prep, merge-to-main, electron-release]
if: ${{ inputs.mode != 'Dry run' && inputs.mode != 'Skip submit' }} if: ${{ inputs.mode != 'Dry run' && inputs.mode != 'Skip submit' }}
uses: ./.github/workflows/electron.yml uses: ./.github/workflows/electron.yml
with: with:
build_type: all build_type: all
artifact_destination: submit artifact_destination: submit
source_ref: ${{ needs.merge-to-main.outputs.build_ref }}
secrets: inherit secrets: inherit
cask-commit-back: cask-commit-back: