diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..366fe49 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,35 @@ +name: Release + +on: + push: + tags: + - "v*" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.23.5" + + - name: Run build script + run: ./scripts/build.sh + + - name: Upload binaries + uses: actions/upload-artifact@v3 + with: + name: binaries + path: bin/ + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: | + bin/printlayout-linux-amd64 + bin/printlayout-darwin-amd64 + bin/printlayout-windows-amd64.exe diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e660fd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +bin/ diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..e991538 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +OUTPUT_DIR="bin" +mkdir -p $OUTPUT_DIR + +PLATFORMS=( + "windows/amd64" + "linux/amd64" + "darwin/amd64" +) + +for PLATFORM in "${PLATFORMS[@]}"; do + OS=$(echo $PLATFORM | cut -d'/' -f1) + ARCH=$(echo $PLATFORM | cut -d'/' -f2) + OUTPUT_NAME="printlayout-$OS-$ARCH" + + if [ "$OS" = "windows" ]; then + OUTPUT_NAME="$OUTPUT_NAME.exe" + fi + + echo "Building for $OS/$ARCH..." + env GOOS=$OS GOARCH=$ARCH go build -o "$OUTPUT_DIR/$OUTPUT_NAME" ./cmd/main.go +done + +echo "Binaries built successfully in the $OUTPUT_DIR directory."