Skip to content

gh aw add records source: as a commit SHA, so gh aw update follows the default branch instead of releases #73077

Done

Description

@kdowswell

Summary

gh aw add owner/repo/workflows/x.md@v1.2.0 writes source: owner/repo/workflows/x.md@<40-char sha>, not @v1.2.0. gh aw update then sees a SHA, and per its help, "if the ref is a commit SHA, it fetches the latest commit from the default branch". So a workflow installed from a release silently starts tracking unreleased main. reference/frontmatter.md shows source: with a tag, and guides/sharing-workflows.md says exact tags stay pinned and @v1 follows releases. Neither works for an installed workflow until the user edits source: by hand.

Root cause

  • pkg/cli/add_workflow_content.go:287-294 passes sourceInfo.CommitSHA to buildSourceStringWithCommitSHA.
  • pkg/cli/spec.go:483-512 prefers the commit SHA over workflow.Version whenever one exists ("include the precise commit that was installed").
  • pkg/cli/update_workflows.go:356-360: IsCommitSHA(currentRef) → resolveLatestCommitFromDefaultBranchWithDeps.

Reproducibility doesn't depend on the SHA in source:: the lock file and .github/aw/imports/ already pin by SHA.

Implementation plan

  1. In pkg/cli/spec.go buildSourceStringWithCommitSHA, keep workflow.Version when it is a release tag (isSemanticVersionTag) or a major ref like v1. Use the SHA only when the user gave a SHA or no ref. Do the same for the manifest branch (FromRepositoryManifest).
  2. Optionally record the resolved SHA for auditing somewhere that update doesn't read as the ref, such as the lock file metadata.
  3. Tests in pkg/cli/add_command_test.go and spec_manifest_source_test.go:
    • @v1.2.0 → source: ...@v1.2.0;
    • @<sha> → SHA;
    • a branch ref → the branch name.
  4. Test in pkg/cli/update_workflows_test.go: a workflow added at a tag updates to the next release, not to the default branch head.

Acceptance criteria

gh aw add .../x.md@v1.2.0 followed by gh aw update (once the cool-down allows it) moves the workflow to the newest v1 release.

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions