Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/build-and-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and Lint

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Build
run: go build -v ./...

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
73 changes: 61 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,77 @@
name: release
name: Release

on:
push:
tags:
- "v*"
- 'v*'

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
build:
strategy:
matrix:
include:
- target: darwin-amd64
os: macos-latest
goos: darwin
goarch: amd64
name: draw-x86_64-apple-darwin
- target: darwin-arm64
os: macos-latest
goos: darwin
goarch: arm64
name: draw-aarch64-apple-darwin
- target: linux-amd64
os: ubuntu-latest
goos: linux
goarch: amd64
name: draw-x86_64-unknown-linux-gnu

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-go@v5
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- uses: goreleaser/goreleaser-action@v6
- name: Build
run: |
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o draw .

- name: Package
run: |
mkdir -p dist
cp draw dist/
cd dist
tar -czvf ${{ matrix.name }}.tar.gz draw
shasum -a 256 ${{ matrix.name }}.tar.gz > ${{ matrix.name }}.tar.gz.sha256

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
args: release --rm-dist
name: ${{ matrix.name }}
path: dist/${{ matrix.name }}.tar.gz*

release:
needs: build
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true

- name: Create Release and Upload Assets
run: gh release create ${{ github.ref_name }} artifacts/* --generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
dist/

.DS_Store

/Formula
51 changes: 0 additions & 51 deletions .goreleaser.yaml

This file was deleted.

79 changes: 79 additions & 0 deletions scripts/update-homebrew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash
set -e

if [ -z "$1" ]; then
echo "Usage: $0 <version>"
echo "Example: $0 0.1.3"
exit 1
fi

VERSION=$1
REPO="Doarakko/draw"
TMP_DIR=$(mktemp -d)

echo "Downloading release assets for v${VERSION}..."
gh release download "v${VERSION}" --repo "$REPO" --pattern "*.tar.gz" --dir "$TMP_DIR"

echo ""
echo "Calculating sha256..."
X86_64_DARWIN=$(shasum -a 256 "$TMP_DIR/draw-x86_64-apple-darwin.tar.gz" | awk '{print $1}')
AARCH64_DARWIN=$(shasum -a 256 "$TMP_DIR/draw-aarch64-apple-darwin.tar.gz" | awk '{print $1}')
X86_64_LINUX=$(shasum -a 256 "$TMP_DIR/draw-x86_64-unknown-linux-gnu.tar.gz" | awk '{print $1}')

echo "x86_64-apple-darwin: $X86_64_DARWIN"
echo "aarch64-apple-darwin: $AARCH64_DARWIN"
echo "x86_64-unknown-linux-gnu: $X86_64_LINUX"

echo ""
echo "Generating formula..."

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
OUTPUT_FILE="$SCRIPT_DIR/../Formula/draw.rb"
mkdir -p "$(dirname "$OUTPUT_FILE")"

cat > "$OUTPUT_FILE" << EOF
class Draw < Formula
desc "Display Yu-Gi-Oh! card image on the terminal"
homepage "https://github.com/Doarakko/draw"
version "${VERSION}"
license "MIT"

on_macos do
on_intel do
url "https://github.com/Doarakko/draw/releases/download/v#{version}/draw-x86_64-apple-darwin.tar.gz"
sha256 "${X86_64_DARWIN}"
end

on_arm do
url "https://github.com/Doarakko/draw/releases/download/v#{version}/draw-aarch64-apple-darwin.tar.gz"
sha256 "${AARCH64_DARWIN}"
end
end

on_linux do
on_intel do
url "https://github.com/Doarakko/draw/releases/download/v#{version}/draw-x86_64-unknown-linux-gnu.tar.gz"
sha256 "${X86_64_LINUX}"
end
end

def install
bin.install "draw"
end

test do
assert_match "draw", shell_output("#{bin}/draw --help", 2)
end
end
EOF

echo ""
echo "Generated: $OUTPUT_FILE"
cat "$OUTPUT_FILE"

echo ""
echo "Cleaning up..."
rm -rf "$TMP_DIR"

echo ""
echo "Done! Copy Formula/draw.rb to homebrew-tap/Formula/draw.rb"