3131 with :
3232 go-version : ${{ matrix.go-version }}
3333
34- - name : Create output directory
35- run : mkdir -p ./dist
34+ - name : Create directories
35+ run : mkdir -p ./dist/package
36+ shell : bash
3637
3738 - name : Build
3839 env :
@@ -41,29 +42,37 @@ jobs:
4142 CGO_ENABLED : 0 # Disable CGO for static binaries
4243 run : |
4344 BINARY_NAME="dir-dumper"
45+ OUTPUT_NAME="${BINARY_NAME}"
46+
47+ # Add exe extension for Windows
4448 if [ "${{ matrix.platform.os }}" = "windows" ]; then
45- BINARY_NAME ="${BINARY_NAME }.exe"
49+ OUTPUT_NAME ="${OUTPUT_NAME }.exe"
4650 fi
47- OUTPUT_PATH="./dist/${BINARY_NAME}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}"
51+
4852 # Build with optimization flags
49- go build -trimpath -ldflags="-s -w" -o $OUTPUT_PATH ./cmd/dir-dumper/
53+ go build -trimpath -ldflags="-s -w" -o "./dist/${OUTPUT_NAME}" ./cmd/dir-dumper/
54+
55+ # List the build directory
56+ ls -la ./dist/
5057 shell : bash
5158
52- - name : List dist directory
53- run : ls -la ./dist
54-
5559 - name : Create Archive
5660 run : |
5761 BINARY_NAME="dir-dumper"
5862 ARCHIVE_BASE_NAME="${BINARY_NAME}-${{ github.ref_name }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}"
59- SOURCE_BINARY="./dist/${BINARY_NAME}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}"
6063
61- # Create a temporary directory for packaging
62- mkdir -p ./dist/package
64+ # Clear package directory to avoid mixing files from previous matrix runs
65+ rm -rf ./dist/package/*
6366
6467 # Copy binary and README to package directory
65- cp "${SOURCE_BINARY}$([ "${{ matrix.platform.os }}" = "windows" ] && echo ".exe" || echo "")" ./dist/package/
66- cp README.md ./dist/package/
68+ if [ "${{ matrix.platform.os }}" = "windows" ]; then
69+ cp "./dist/${BINARY_NAME}.exe" ./dist/package/
70+ else
71+ cp "./dist/${BINARY_NAME}" ./dist/package/
72+ fi
73+
74+ # Copy README to package directory
75+ cp README.md ./dist/package/ || echo "Warning: README.md not found"
6776
6877 # Create different archive types based on target OS
6978 if [ "${{ matrix.platform.os }}" = "windows" ]; then
0 commit comments