Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,37 +40,47 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: nxtcoder17/nixy@feat/github-action

- uses: nxtcoder17/actions/setup-cache-go@v1
with:
cache_key: "run"
working_directory: .

- uses: nxtcoder17/actions/setup-nix-cachix@v1
with:
flake_lock: "./flake.lock"
nix_develop_arguments: ".#default"
cachix_cache_name: ${{ secrets.CACHIX_CACHE_NAME }}
cachix_auth_token: ${{ secrets.CACHIX_AUTH_TOKEN }}
# - uses: nxtcoder17/actions/setup-nix-cachix@v1
# with:
# flake_lock: "./flake.lock"
# nix_develop_arguments: ".#default"
# cachix_cache_name: ${{ secrets.CACHIX_CACHE_NAME }}
# cachix_auth_token: ${{ secrets.CACHIX_AUTH_TOKEN }}

- uses: nxtcoder17/actions/metadata@main
id: meta

# - name: Build Binary
# shell: bash
# env:
# VERSION: ${{steps.meta.outputs.version}}
# run: |+
# nixy build runfile

- name: Build Binary
shell: bash
env:
CGO_ENABLED: 0
VERSION: "${{ steps.meta.outputs.version }}.${{ steps.meta.outputs.commit_slug }}"
run: |+
arch_list=("amd64" "arm64")
os_list=("linux" "darwin")


for os in "${os_list[@]}"; do
for arch in "${arch_list[@]}"; do
echo "🚧 building binary for os=$os arch=$arch"
export GOARCH=$arch
export GOOS=$os
export GOARCH=$arch

binary=bin/run-$GOOS-$GOARCH
time go build -o $binary -ldflags="-s -w -X main.Version=${{ steps.meta.outputs.version }}-${{steps.meta.outputs.short_sha}}" -tags urfave_cli_no_docs ./cmd/run
echo "🚧 building binary for os=$GOOS arch=$GOARCH"
go build -o bin/run-${GOOS}-${GOARCH} -ldflags="-s -w -X main.Version=$VERSION" -tags urfave_cli_no_docs ./cmd/run
done
done

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ bin/
Taskfile.yml
go.work*
tags
.nixy
19 changes: 14 additions & 5 deletions Runfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@ tasks:
build:
env:
CGO_ENABLED: 0
GOOS:
sh: go env GOOS
GOARCH:
sh: go env GOARCH
version:
required: true
cmd:
- |+
echo "building ..."
go build -o bin/run -ldflags="-s -w" -tags urfave_cli_no_docs ./cmd/run
go build -o bin/run-${GOOS}-${GOARCH} -ldflags="-s -w -X main.Version=$VERSION" -tags urfave_cli_no_docs ./cmd/run
echo "DONE"

build:dev:
watch:
enabled: true
dirs:
- .
cmd:
- |+
echo "building ..."
go build -o bin/run-nightly -ldflags="-s -w" -tags urfave_cli_no_docs ./cmd/run
echo "DONE"
- run: build
Comment on lines +14 to +23
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): Mismatch between version env key and use of $VERSION in the build command likely results in an empty version string.

version is defined in the task env (lowercase), but the go build command uses $VERSION (uppercase). Unless something else exports VERSION, main.Version will be empty.

To align them, either:

  • Use $version in the -ldflags and rely on Runfile env injection, or
  • Rename the env key to VERSION and keep using $VERSION.

The same issue applies to build:dev, where version: "nightly" is set but $VERSION is referenced, so the nightly marker may never be applied.

env:
version: "nightly"

example:
dir: ./examples
Expand Down
21 changes: 18 additions & 3 deletions nixy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,22 @@ packages:
- pre-commit
- gotestfmt

builds:
runfile:
command: |+
echo "VERSION: $VERSION"

onShellEnter: |+
export PATH="/workspace/bin:$PATH"
source $HOME/.profile
run build GOOS=linux GOARCH=amd64 version=$VERSION
run build GOOS=linux GOARCH=arm64 version=$VERSION
run build GOOS=darwin GOARCH=amd64 version=$VERSION
run build GOOS=darwin GOARCH=arm64 version=$VERSION
Comment on lines +12 to +17
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): VERSION env usage here may not be wired correctly into the Runfile build task.

The build task defines version as an env key but still uses $VERSION in go build. Unless something else exports VERSION and maps versionVERSION, the value from nixy.yml may never reach main.Version. After aligning on either version or VERSION in Runfile.yml, please verify that the pipeline still passes the correct value through and that main.Version matches what nixy and CI set.


paths:
- ./bin/run-linux-amd64
- ./bin/run-linux-arm64
- ./bin/run-darwin-amd64
- ./bin/run-darwin-arm64

# onShellEnter: |+
# export PATH="/workspace/bin:$PATH"
# # source $HOME/.profile
9 changes: 5 additions & 4 deletions pkg/runfile/resolver/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,19 @@ func printCommand(w *writer.LogWriter, prefix, lang, cmd string) {

// w.Mu.Lock()
// defer w.Mu.Unlock()
fmt.Fprintf(w, "\r\033[K%s\n", padString(hlCode.String(), prefix))
fmt.Fprintf(w, "\r\033[K%s\n", formatCommandPreview(hlCode.String(), prefix))
}

func padString(str string, withPrefix string) string {
func formatCommandPreview(str string, withPrefix string) string {
sp := strings.Split(str, "\n")
indent := strings.Repeat(" ", prefixDisplayWidth(withPrefix))
rail := lipgloss.NewStyle().Foreground(lipgloss.Color("2")).Faint(true).Render("│")
for i := range sp {
if i == 0 {
sp[i] = fmt.Sprintf("%s %s", writer.GetStyledPrefix(withPrefix), sp[i])
sp[i] = fmt.Sprintf("%s %s %s", writer.GetStyledPrefix(withPrefix), rail, sp[i])
continue
}
sp[i] = indent + sp[i]
sp[i] = indent + rail + " " + sp[i]
}

return strings.Join(sp, "\n")
Expand Down
Loading