Merge pull request #1521 from trheyi/main
fix(workflows): improve version and run ID resolution in notarization…
This commit is contained in:
commit
4e645d1ed9
2 changed files with 28 additions and 17 deletions
24
.github/workflows/notarize-macos.yml
vendored
24
.github/workflows/notarize-macos.yml
vendored
|
|
@ -18,7 +18,7 @@ permissions:
|
||||||
actions: write
|
actions: write
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: notarize-${{ github.event.workflow_run.head_branch || github.run_id }}
|
group: notarize-${{ github.run_id }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
@ -29,8 +29,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: >
|
if: >
|
||||||
github.event_name == 'workflow_dispatch' ||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
(github.event.workflow_run.conclusion == 'success' &&
|
github.event.workflow_run.conclusion == 'success'
|
||||||
startsWith(github.event.workflow_run.head_branch, 'v'))
|
|
||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.resolve.outputs.version }}
|
version: ${{ steps.resolve.outputs.version }}
|
||||||
run_id: ${{ steps.resolve.outputs.run_id }}
|
run_id: ${{ steps.resolve.outputs.run_id }}
|
||||||
|
|
@ -43,21 +42,24 @@ jobs:
|
||||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
VERSION="${{ github.event.inputs.version }}"
|
VERSION="${{ github.event.inputs.version }}"
|
||||||
RUN_ID="${{ github.event.inputs.run_id }}"
|
RUN_ID="${{ github.event.inputs.run_id }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Auto-detect version from latest GitHub Release
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then
|
||||||
TAG=$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName -q '.tagName')
|
TAG=$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName -q '.tagName')
|
||||||
VERSION="${TAG#v}"
|
VERSION="${TAG#v}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
echo "::error::Could not determine version from latest release"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Auto-detect macOS build run_id
|
||||||
if [ -z "$RUN_ID" ]; then
|
if [ -z "$RUN_ID" ]; then
|
||||||
RUN_ID=$(gh run list --repo "$GITHUB_REPOSITORY" \
|
RUN_ID=$(gh run list --repo "$GITHUB_REPOSITORY" \
|
||||||
--workflow="Release macOS" --branch="v${VERSION}" --limit=1 \
|
--workflow="Release macOS" --branch="v${VERSION}" --limit=1 \
|
||||||
--json databaseId --jq '.[0].databaseId')
|
--json databaseId,conclusion --jq '.[] | select(.conclusion=="success") | .databaseId')
|
||||||
fi
|
|
||||||
else
|
|
||||||
TAG="${{ github.event.workflow_run.head_branch }}"
|
|
||||||
VERSION="${TAG#v}"
|
|
||||||
RUN_ID=$(gh run list --repo "$GITHUB_REPOSITORY" \
|
|
||||||
--workflow="Release macOS" --branch="${TAG}" --limit=1 \
|
|
||||||
--json databaseId --jq '.[0].databaseId')
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$VERSION" ] || [ -z "$RUN_ID" ]; then
|
if [ -z "$VERSION" ] || [ -z "$RUN_ID" ]; then
|
||||||
|
|
|
||||||
9
.github/workflows/release.yml
vendored
9
.github/workflows/release.yml
vendored
|
|
@ -24,9 +24,18 @@ jobs:
|
||||||
|
|
||||||
- name: Get Version
|
- name: Get Version
|
||||||
id: version
|
id: version
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
|
# Prefer head_branch from upstream (works for first-level workflow_run)
|
||||||
TAG="${{ github.event.workflow_run.head_branch }}"
|
TAG="${{ github.event.workflow_run.head_branch }}"
|
||||||
|
if [[ "$TAG" =~ ^v ]]; then
|
||||||
VERSION="${TAG#v}"
|
VERSION="${TAG#v}"
|
||||||
|
else
|
||||||
|
# Fallback: get from latest GitHub Release
|
||||||
|
TAG=$(gh release view --repo "$GITHUB_REPOSITORY" --json tagName -q '.tagName')
|
||||||
|
VERSION="${TAG#v}"
|
||||||
|
fi
|
||||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||||
echo "TAG=${TAG} VERSION=${VERSION}"
|
echo "TAG=${TAG} VERSION=${VERSION}"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue