Skip to content

Conversation

@lokst
Copy link
Contributor

@lokst lokst commented Aug 21, 2025

This updates our workflows to dispatch Release from the CI workflow.

Currently the Release workflow is directly triggered upon a tag push but as discussed here, it relies on a third-party action to validate that the CI workflow ran successfully for the tagged commit.

With the changes in this PR, we will use workflow_run to make the Release workflow run automatically when the CI workflow completes, with the following necessary accompanying changes:

  • Trigger the CI workflow upon a tag push that matches a valid pattern
  • We introduce a validate-tag job to the Release workflow, that validates that the CI workflow was triggered from a push of a valid tag, and only allows the publish job to run if the validation succeeds. This is necessary because the CI workflow can be triggered by other conditions including a push to main branch.

Addresses #201

Note: Here is a simplified version of the workflows for ease of testing in any repository: https://gist.github.com/lokst/e8ee94f6289bbc82a25b21c96e44bf2f

@lokst lokst self-assigned this Aug 21, 2025
TAG_SHA="$(git rev-parse "$REF^{commit}")"
COMMIT_SHA="${{ github.event.workflow_run.head_sha }}"
if [ "$TAG_SHA" != "$COMMIT_SHA" ]; then
echo "Tag SHA $TAG_SHA does not match pushed commit SHA $COMMIT_SHA"
Copy link
Contributor Author

@lokst lokst Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested (in another repository) that this successfully guards against the following case:

  1. A branch with the same name as an existing valid tag is created
  2. The "CI" workflow in that branch is modified to run upon a push to the branch (thus causing the CI workflow to be triggered on pushes to the branch)
Screenshot 2025-08-21 at 2 16 23 PM

name: Publish Client
needs: validate-tag
runs-on: ubuntu-latest
if: ${{ needs.validate-tag.outputs.valid_tag == 'true' && github.event.workflow_run.conclusion == 'success' }}
Copy link
Contributor Author

@lokst lokst Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test showing that the job will be skipped if the condition is not met

(Conducted in another repository)

Screenshot 2025-08-21 at 2 21 34 PM

A test showing a successful job run

A valid tag is pushed:

Screenshot 2025-08-21 at 2 25 36 PM

The tag is successfully validated:

Screenshot 2025-08-21 at 2 29 13 PM

The publish job is run:

Screenshot 2025-08-21 at 2 26 26 PM

@lokst lokst marked this pull request as ready for review August 21, 2025 06:53
@lokst lokst requested a review from dallasread August 21, 2025 07:00
Copy link
Member

@dallasread dallasread left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me – thanks! 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants