Skip to content

Commit 75b0fe4

Browse files
authored
Merge pull request #790 from fullsend-ai/fix-dev-version-pin
fix: prevent dev build versions from being pinned in action.yml
2 parents 050c28f + e8e5301 commit 75b0fe4

2 files changed

Lines changed: 47 additions & 5 deletions

File tree

internal/layers/workflows.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7+
"regexp"
78

89
"github.com/fullsend-ai/fullsend/internal/forge"
910
"github.com/fullsend-ai/fullsend/internal/scaffold"
@@ -173,13 +174,19 @@ func (l *WorkflowsLayer) Analyze(ctx context.Context) (*LayerReport, error) {
173174
return report, nil
174175
}
175176

177+
// releaseVersionPattern matches a clean release tag: v1.2.3 or 1.2.3.
178+
// Dev builds from git describe (e.g. v0.7.0-58-g4273effb, v0.7.0-dirty)
179+
// will NOT match and are treated as non-release.
180+
var releaseVersionPattern = regexp.MustCompile(`^v?\d+\.\d+\.\d+$`)
181+
176182
// pinVersionInAction replaces the "default: latest" line in the action.yml
177-
// version input with the concrete CLI version. If the version is "dev"
178-
// (local build), it falls back to "latest" and logs a warning.
183+
// version input with the concrete CLI version. Non-release versions (dev
184+
// builds, git-describe output like v0.7.0-58-gXXXXXXX) fall back to
185+
// "latest" so that workflows don't try to download a nonexistent release.
179186
func (l *WorkflowsLayer) pinVersionInAction(content []byte) []byte {
180-
if l.cliVersion == "" || l.cliVersion == "dev" {
181-
if l.cliVersion == "dev" {
182-
l.ui.StepWarn("CLI version is \"dev\"; action.yml will use \"latest\" (unpinned)")
187+
if !releaseVersionPattern.MatchString(l.cliVersion) {
188+
if l.cliVersion != "" {
189+
l.ui.StepWarn(fmt.Sprintf("CLI version %q is not a release; action.yml will use \"latest\" (unpinned)", l.cliVersion))
183190
}
184191
return content
185192
}

internal/layers/workflows_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,41 @@ func TestWorkflowsLayer_Install_ReinstallUpdatesVersion(t *testing.T) {
192192
"re-install should update pinned version")
193193
}
194194

195+
func TestWorkflowsLayer_Install_GitDescribeVersionFallsBackToLatest(t *testing.T) {
196+
devVersions := []string{
197+
"v0.7.0-58-g4273effb",
198+
"v0.7.0-dirty",
199+
"v0.7.0-3-g1234567-dirty",
200+
"4273effb",
201+
"dev",
202+
"v1.0.0-rc.1",
203+
}
204+
for _, ver := range devVersions {
205+
t.Run(ver, func(t *testing.T) {
206+
client := forge.NewFakeClient()
207+
var buf bytes.Buffer
208+
printer := ui.New(&buf)
209+
layer := NewWorkflowsLayer("test-org", client, printer, "admin-user", ver)
210+
211+
err := layer.Install(context.Background())
212+
require.NoError(t, err)
213+
214+
var actionContent string
215+
for _, f := range client.CommittedFiles[0].Files {
216+
if f.Path == actionYMLPath {
217+
actionContent = string(f.Content)
218+
break
219+
}
220+
}
221+
require.NotEmpty(t, actionContent, "action.yml should have been written")
222+
assert.Contains(t, actionContent, "default: latest",
223+
"non-release version %q should fall back to latest", ver)
224+
assert.Contains(t, buf.String(), "not a release",
225+
"should warn about non-release version")
226+
})
227+
}
228+
}
229+
195230
func TestWorkflowsLayer_Install_Error(t *testing.T) {
196231
client := &forge.FakeClient{
197232
Errors: map[string]error{

0 commit comments

Comments
 (0)