Skip to content

add build.sh and run.sh #15

add build.sh and run.sh

add build.sh and run.sh #15

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "main" ]
tags: [ "v*" ]
pull_request:
branches: [ "main" ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Test
run: go test -v ./...
build:
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
exclude:
- goos: windows
goarch: arm64
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build binary
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
BINARY_NAME=gomail
if [ "$GOOS" = "windows" ]; then
BINARY_NAME="${BINARY_NAME}.exe"
fi
# Build the binary
go build -o "$BINARY_NAME" .
# Create archive
if [ "$GOOS" = "windows" ]; then
ARCHIVE_NAME="gomail_${GOOS}_${GOARCH}.zip"
zip "$ARCHIVE_NAME" "$BINARY_NAME"
else
ARCHIVE_NAME="gomail_${GOOS}_${GOARCH}.tar.gz"
tar -czf "$ARCHIVE_NAME" "$BINARY_NAME"
fi
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: gomail-${{ matrix.goos }}-${{ matrix.goarch }}
path: |
*.zip
*.tar.gz
release:
if: (github.ref == 'refs/heads/main' && github.event_name == 'push') || startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Generate version
id: version
run: |
# Check if workflow was triggered by a tag
if [[ $GITHUB_REF == refs/tags/* ]]; then
# Use the tag name directly
VERSION=${GITHUB_REF#refs/tags/}
echo "Using tag: $VERSION"
else
# Generate version based on date and short commit hash
DATE=$(date +'%Y%m%d')
SHORT_SHA=${GITHUB_SHA::7}
VERSION="v${DATE}-${SHORT_SHA}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag=${VERSION}" >> $GITHUB_OUTPUT
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: List downloaded files
run: |
echo "Files in current directory:"
ls -la
echo "Archive files:"
find . -name "*.zip" -o -name "*.tar.gz" | sort
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.tag }}
files: |
gomail_linux_amd64.tar.gz
gomail_linux_arm64.tar.gz
gomail_darwin_amd64.tar.gz
gomail_darwin_arm64.tar.gz
gomail_windows_amd64.zip
draft: false
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
generate_release_notes: true
name: GoMail ${{ steps.version.outputs.version }} ${{ startsWith(github.ref, 'refs/tags/') && '' || '(Pre-release)' }}
body: |
## GoMail ${{ steps.version.outputs.version }} ${{ startsWith(github.ref, 'refs/tags/') && '' || '- Pre-release Build' }}
**Commit:** ${{ github.sha }}
**Build Date:** ${{ steps.date.outputs.date }}
Terminal-based email client built with Go and Bubble Tea.
### Downloads
**Linux:**
- `gomail_linux_amd64.tar.gz` - Linux x64
- `gomail_linux_arm64.tar.gz` - Linux ARM64
**macOS:**
- `gomail_darwin_amd64.tar.gz` - macOS Intel
- `gomail_darwin_arm64.tar.gz` - macOS Apple Silicon
**Windows:**
- `gomail_windows_amd64.zip` - Windows x64
### Installation
1. Download the appropriate archive for your platform
2. Extract the binary
3. Run `./gomail` (or `gomail.exe` on Windows)
${{ startsWith(github.ref, 'refs/tags/') && '' || '**Note:** Pre-release builds may contain experimental features and bugs. Use stable releases for production.' }}
Send emails from your terminal! ✉