@@ -28,18 +28,29 @@ jobs:
2828
2929 - name : Build Go Binary
3030 run : |
31- echo "Building for ${{ matrix.goos }}-${{ matrix.goarch }}"
31+ # Determine the output binary name, adding .exe for Windows
32+ BINARY_NAME="file-encryptor-${{ matrix.goos }}-${{ matrix.goarch }}"
33+ if [ "${{ matrix.goos }}" == "windows" ]; then
34+ BINARY_NAME="${BINARY_NAME}.exe"
35+ fi
36+
37+ echo "Building for ${{ matrix.goos }}/${{ matrix.goarch }} -> ${BINARY_NAME}"
38+
39+ # Set environment variables for cross-compilation and build
40+ # GO111MODULE=on is default now but explicit doesn't hurt
41+ # CGO_ENABLED=0 is good practice for static cross-platform binaries unless CGO is required
3242 GO111MODULE=on CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
33- go build -o file-encryptor-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/file-encryptor
43+ go build -ldflags="-s -w" -o "${BINARY_NAME}" ./cmd/file-encryptor
44+ # -ldflags="-s -w" strips debug symbols and DWARF info, making the binary smaller
45+
46+ # Verify the binary was created
47+ ls -l "${BINARY_NAME}"
3448
3549 - name : Upload Release Assets
3650 uses : softprops/action-gh-release@v2
3751 with :
3852 files : |
39- file-encryptor-linux-amd64
40- file-encryptor-windows-amd64.exe
41- file-encryptor-darwin-amd64
42- LICENSE
43- README.md
53+ ${{ env.BINARY_NAME_WITH_EXT }} # Use the name determined in the build step
4454 env :
4555 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
56+ BINARY_NAME_WITH_EXT : file-encryptor-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }}
0 commit comments