Skip to content

Autorelease on tag creation doesn't get triggered by other workflow #82

Closed
@CoderJoshDK

Description

GitHub workflows do not trigger other workflows. As such, the creation of the tag in mirror.py does not trigger the release workflow. Manual creation and pushing of the tag, does trigger this workflow. As such, there are 2 fixes (but really only 1). Where we keep the release.yml file and trigger it manually through the main.yml workflow. Or just simplify things by having it all in a single file. The change would end up looking like:

      - name: Check for unpushed commits
        id: check_unpushed
        run: |
          UNPUSHED_COMMITS=$(git log origin/main..HEAD)
          if [ -z "$UNPUSHED_COMMITS" ]; then
            echo "No unpushed commits found."
            echo "changes_exist=false" >> $GITHUB_ENV
          else
            echo "Unpushed commits found."
            echo "changes_exist=true" >> $GITHUB_ENV
          fi

      - run: |
          git push origin HEAD:refs/heads/main
          git push origin HEAD:refs/heads/main --tags
        if: env.changes_exist == 'true'

      - run: |
          TAG_NAME=$(git describe --tags $(git rev-list --tags --max-count=1))
          echo $TAG_NAME
          gh release create "$TAG_NAME" \
            --title "$TAG_NAME" \
            --notes "See: https://github.com/astral-sh/uv/releases/tag/$TAG_NAME" \
            --latest
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        if: env.changes_exist == 'true'

There are other subtle things being changed here too.

For one, gh release create is now being passed the --latest flag. While this flag is active by default, this helps make that more explicit and clear.

Another thing, is the change to how the tag name is picked up. Before was a little more brittle since there was a possibility for:

TAG_NAME=${GITHUB_REF#refs/tags/}

to return something besides a tag name. In normal operation, this is correct. But as an example, if someone would fork this repo, that line would cause a failed run.

Please let me know if these changes make sense or if you have any notes. If this seems reasonable, I will create a PR for the change.

Activity

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions