feat(build): add output_path workflow alias

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-01 23:43:40 +00:00
parent 29a73bae5a
commit ef72e09c1e
3 changed files with 18 additions and 2 deletions

View file

@ -33,6 +33,7 @@ func setWorkflowI18n() {
func initWorkflowFlags() {
releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowPathInput, "path", "", i18n.T("cmd.build.workflow.flag.path"))
releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowOutputPathInput, "output-path", "", i18n.T("cmd.build.workflow.flag.output_path"))
releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowOutputPathInput, "output_path", "", i18n.T("cmd.build.workflow.flag.output_path"))
releaseWorkflowCmd.Flags().StringVar(&releaseWorkflowOutputPathInput, "output", "", i18n.T("cmd.build.workflow.flag.output"))
}
@ -49,7 +50,7 @@ func AddWorkflowCommand(buildCmd *cli.Command) {
// buildcmd.AddWorkflowCommand(buildCmd)
// runReleaseWorkflow(ctx, "", "") // writes to .github/workflows/release.yml
// runReleaseWorkflow(ctx, "ci/release.yml", "") // writes to ./ci/release.yml under the project root
// runReleaseWorkflow(ctx, "", "ci/release.yml") // output-path and output are aliases for the output path input
// runReleaseWorkflow(ctx, "", "ci/release.yml") // output-path, output_path, and output are aliases for the output path input
func runReleaseWorkflow(_ context.Context, workflowPathInput, workflowOutputPathInput string) error {
projectDir, err := ax.Getwd()

View file

@ -35,16 +35,20 @@ func TestBuildCmd_RunReleaseWorkflow_Good(t *testing.T) {
pathFlag := releaseWorkflowCmd.Flags().Lookup("path")
outputPathFlag := releaseWorkflowCmd.Flags().Lookup("output-path")
outputPathSnakeFlag := releaseWorkflowCmd.Flags().Lookup("output_path")
outputFlag := releaseWorkflowCmd.Flags().Lookup("output")
assert.NotNil(t, pathFlag)
assert.NotNil(t, outputPathFlag)
assert.NotNil(t, outputPathSnakeFlag)
assert.NotNil(t, outputFlag)
assert.NotEmpty(t, pathFlag.Usage)
assert.NotEmpty(t, outputPathFlag.Usage)
assert.NotEmpty(t, outputPathSnakeFlag.Usage)
assert.NotEmpty(t, outputFlag.Usage)
assert.NotEqual(t, pathFlag.Usage, outputFlag.Usage)
assert.NotEqual(t, outputPathFlag.Usage, outputFlag.Usage)
assert.Equal(t, outputPathFlag.Usage, outputPathSnakeFlag.Usage)
})
t.Run("writes to a custom relative path", func(t *testing.T) {
@ -145,4 +149,15 @@ func TestBuildCmd_RunReleaseWorkflow_Good(t *testing.T) {
assert.Contains(t, content, "workflow_call:")
assert.Contains(t, content, "workflow_dispatch:")
})
t.Run("writes to the output_path alias", func(t *testing.T) {
customPath := "ci/output_path-release.yml"
err := runReleaseWorkflowInDir(projectDir, "", customPath)
require.NoError(t, err)
content, err := io.Local.Read(ax.Join(projectDir, customPath))
require.NoError(t, err)
assert.Contains(t, content, "workflow_call:")
assert.Contains(t, content, "workflow_dispatch:")
})
}

View file

@ -113,7 +113,7 @@
},
"workflow": {
"short": "Generate the release workflow",
"long": "Write the embedded GitHub Actions release workflow into .github/workflows/release.yml, or pass --path/--output-path/--output for a custom location.",
"long": "Write the embedded GitHub Actions release workflow into .github/workflows/release.yml, or pass --path/--output-path/--output_path/--output for a custom location.",
"flag": {
"path": "Preferred workflow path input.",
"output_path": "Preferred explicit workflow output path.",