Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 10 additions & 43 deletions .github/actions/dispatch-and-watch-workflow/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,14 @@ inputs:
token:
description: "Token with `actions: write` on the target repository."
required: true
locate-attempts:
description: How many times to poll for the dispatched run before giving up.
required: false
default: "30"
locate-interval:
description: Seconds to wait between locate polls.
required: false
default: "5"

outputs:
run-id:
description: Numeric ID of the dispatched run.
value: ${{ steps.locate.outputs.run-id }}
value: ${{ steps.dispatch.outputs.run-id }}
run-url:
description: HTML URL of the dispatched run.
value: ${{ steps.locate.outputs.run-url }}
value: ${{ steps.dispatch.outputs.run-url }}

runs:
using: composite
Expand All @@ -57,44 +49,19 @@ runs:
IS_ACTIVE_MAJOR: ${{ inputs.is_active_major }}
run: |
set -euo pipefail
CORR=$(uuidgen)
echo "correlation-id=$CORR" >> "$GITHUB_OUTPUT"

gh workflow run "$WORKFLOW" --repo "$REPO" --ref "$REF" \
RUN_URL=$(gh workflow run "$WORKFLOW" --repo "$REPO" --ref "$REF" \
-f version="$VERSION" \
-f is_stable="$IS_STABLE" \
-f is_active_major="$IS_ACTIVE_MAJOR" \
-f correlation_id="$CORR"
-f is_active_major="$IS_ACTIVE_MAJOR")

Comment thread
tobias-tengler marked this conversation as resolved.
- name: 🔎 Locate dispatched run
id: locate
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
REPO: ${{ inputs.repo }}
WORKFLOW: ${{ inputs.workflow }}
CORR: ${{ steps.dispatch.outputs.correlation-id }}
ATTEMPTS: ${{ inputs.locate-attempts }}
INTERVAL: ${{ inputs.locate-interval }}
run: |
set -euo pipefail
RUN_ID=""
RUN_URL=""
for _ in $(seq 1 "$ATTEMPTS"); do
read -r RUN_ID RUN_URL < <(gh run list --repo "$REPO" --workflow "$WORKFLOW" \
--limit 20 --json databaseId,name,url \
--jq "[.[] | select(.name | contains(\"$CORR\"))][0] | \"\(.databaseId) \(.url)\"")
if [ -n "$RUN_ID" ] && [ "$RUN_ID" != "null" ]; then
break
fi
sleep "$INTERVAL"
done

if [ -z "$RUN_ID" ] || [ "$RUN_ID" = "null" ]; then
echo "::error::Could not locate dispatched run for $REPO ($WORKFLOW) with correlation_id=$CORR"
if [ -z "$RUN_URL" ]; then
echo "::error::Dispatch did not return a run URL. Requires gh >= 2.87.0 against github.com."
exit 1
fi
Comment thread
tobias-tengler marked this conversation as resolved.

RUN_ID="${RUN_URL##*/}"

echo "run-id=$RUN_ID" >> "$GITHUB_OUTPUT"
echo "run-url=$RUN_URL" >> "$GITHUB_OUTPUT"
echo "Dispatched run: $RUN_URL"
Expand All @@ -104,5 +71,5 @@ runs:
env:
GH_TOKEN: ${{ inputs.token }}
REPO: ${{ inputs.repo }}
RUN_ID: ${{ steps.locate.outputs.run-id }}
run: gh run watch "$RUN_ID" --repo "$REPO" --exit-status
RUN_ID: ${{ steps.dispatch.outputs.run-id }}
run: gh run watch "$RUN_ID" --repo "$REPO" --exit-status --compact
17 changes: 2 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ jobs:
echo "is_active_major=$IS_ACTIVE_MAJOR" >> "$GITHUB_OUTPUT"
echo "is_highest_stable_major=$IS_HIGHEST_STABLE_MAJOR" >> "$GITHUB_OUTPUT"

{
echo "## Release context"
echo "- git_tag: \`$GIT_TAG\`"
echo "- major: \`$MAJOR\`"
echo "- is_stable: \`$IS_STABLE\`"
echo "- is_active_major: \`$IS_ACTIVE_MAJOR\`"
echo "- is_highest_stable_major: \`$IS_HIGHEST_STABLE_MAJOR\`"
echo "- highest_stable_major (registry): \`$HIGHEST\`"
} >> "$GITHUB_STEP_SUMMARY"

create-draft:
name: 📝 Create Draft Release
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -181,11 +171,7 @@ jobs:
- name: 📤 Attach .nupkg assets to GitHub release
shell: bash
run: |
set -euo pipefail
for file in ./output/packages/*.nupkg; do
echo "📤 Uploading $file"
gh release upload ${{ env.GIT_TAG }} "$file" --repo "${{ github.repository }}"
done
gh release upload "$GIT_TAG" ./output/packages/*.nupkg --repo "${{ github.repository }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -625,6 +611,7 @@ jobs:
name: 🍺 Update Homebrew Tap
runs-on: ubuntu-latest
needs: [compute-release-context, publish-release]
if: needs.compute-release-context.outputs.is_stable == 'true' || needs.compute-release-context.outputs.is_active_major == 'true'

steps:
- name: 📦 Checkout
Expand Down
Loading