-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
113 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
class Trdsql < Formula | ||
desc "Tools for executing SQL queries to CSV, LTSV, JSON and TBLN" | ||
homepage "https://github.com/noborus/trdsql/" | ||
version "{{ version }}" | ||
|
||
on_macos do | ||
if Hardware::CPU.arm? | ||
url "{{ DARWIN_ARM64_URL }}" | ||
sha256 "{{ DARWIN_ARM64_SHA256 }}" | ||
def install | ||
bin.install "trdsql" | ||
end | ||
end | ||
if Hardware::CPU.intel? | ||
url "{{ DARWIN_AMD64_URL }}" | ||
sha256 "{{ DARWIN_AMD64_SHA256 }}" | ||
def install | ||
bin.install "trdsql" | ||
end | ||
end | ||
end | ||
|
||
on_linux do | ||
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit? | ||
url "{{ LINUX_ARM64_URL }}" | ||
sha256 "{{ LINUX_ARM64_SHA256 }}" | ||
def install | ||
bin.install "trdsql" | ||
end | ||
end | ||
|
||
if Hardware::CPU.intel? | ||
url "{{ LINUX_AMD64_URL }}" | ||
sha256 "{{ LINUX_AMD64_SHA256 }}" | ||
def install | ||
bin.install "trdsql" | ||
end | ||
end | ||
end | ||
|
||
test do | ||
assert_equal "3\n", pipe_output("#{bin}/trdsql 'select count(*) from -'", "a\nb\nc\n") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
template_file=".github/trdsql.template.rb" | ||
|
||
output_file=".github/trdsql.rb" | ||
|
||
VERSION=$(git describe --tags 2>/dev/null) | ||
|
||
get_url_and_sha256() { | ||
local file_path="$1" | ||
local file_name=$(basename "$file_path") | ||
local url="https://github.com/noborus/trdsql/releases/download/$VERSION/$file_name" | ||
local sha256=$(sha256sum "$file_path" | awk '{print $1}') | ||
echo "$url $sha256" | ||
} | ||
|
||
darwin_arm64=$(get_url_and_sha256 "dist/trdsql_${VERSION}_darwin_arm64.zip") | ||
darwin_arm64_url=$(echo "${darwin_arm64% *}" | sed 's/\//\\\//g') | ||
darwin_arm64_sha256=${darwin_arm64#* } | ||
|
||
darwin_amd64=$(get_url_and_sha256 "dist/trdsql_${VERSION}_darwin_amd64.zip") | ||
darwin_amd64_url=$(echo "${darwin_amd64% *}" | sed 's/\//\\\//g') | ||
darwin_amd64_sha256=${darwin_amd64#* } | ||
|
||
linux_arm64=$(get_url_and_sha256 "dist/trdsql_${VERSION}_linux_arm64.zip") | ||
linux_arm64_url=$(echo "${linux_arm64% *}" | sed 's/\//\\\//g') | ||
linux_arm64_sha256=${linux_arm64#* } | ||
|
||
linux_amd64=$(get_url_and_sha256 "dist/trdsql_${VERSION}_linux_amd64.zip") | ||
linux_amd64_url=$(echo "${linux_amd64% *}" | sed 's/\//\\\//g') | ||
linux_amd64_sha256=${linux_amd64#* } | ||
|
||
ver=$(echo "$VERSION" | sed 's/^v//g') | ||
sed -e "s/{{ version }}/$ver/g" \ | ||
-e "s/{{ DARWIN_ARM64_URL }}/$darwin_arm64_url/g" \ | ||
-e "s/{{ DARWIN_ARM64_SHA256 }}/$darwin_arm64_sha256/g" \ | ||
-e "s/{{ DARWIN_AMD64_URL }}/$darwin_amd64_url/g" \ | ||
-e "s/{{ DARWIN_AMD64_SHA256 }}/$darwin_amd64_sha256/g" \ | ||
-e "s/{{ LINUX_ARM64_URL }}/$linux_arm64_url/g" \ | ||
-e "s/{{ LINUX_ARM64_SHA256 }}/$linux_arm64_sha256/g" \ | ||
-e "s/{{ LINUX_AMD64_URL }}/$linux_amd64_url/g" \ | ||
-e "s/{{ LINUX_AMD64_SHA256 }}/$linux_amd64_sha256/g" \ | ||
"$template_file" > "$output_file" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,46 @@ | ||
name: Release upload | ||
"on": | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
- name: Install Go | ||
if: success() | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.21" | ||
- name: Set environment variables | ||
shell: bash | ||
run: | | ||
echo "GOPATH=${{ runner.workspace }}" >> $GITHUB_ENV | ||
echo "${{ runner.workspace }}/bin" >> $GITHUB_PATH | ||
shell: bash | ||
- name: Setup XGO | ||
run: go install github.com/crazy-max/xgo@latest | ||
- name: Run dist | ||
run: make dist | ||
- name: Upload Asset to Release with a wildcard | ||
uses: AButler/[email protected] | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: dist/*.zip | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
name: Release upload | ||
"on": | ||
release: | ||
types: | ||
- published | ||
- name: update homebrew | ||
run: | | ||
bash .github/update-homebrew-tap.sh | ||
- name: Pushes homebrew-tap | ||
uses: dmnemec/copy_file_to_another_repo_action@main | ||
env: | ||
API_TOKEN_GITHUB: ${{ secrets.TAP_GITHUB_TOKEN }} | ||
with: | ||
source_file: '.github/trdsql.rb' | ||
destination_repo: 'noborus/homebrew-tap' | ||
destination_branch: 'master' | ||
user_email: '[email protected]' | ||
user_name: 'Noboru Saito' | ||
commit_message: 'Brew formula update for trdsql' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters