Skip to content

Commit

Permalink
Add GitHub Actions workflow for automated releases and build script
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmedhossamdev committed Jan 17, 2025
1 parent 7ad9af3 commit a4ac2cd
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/
25 changes: 25 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit a4ac2cd

Please sign in to comment.