-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
267 additions
and
1 deletion.
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,87 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, macos-13] | ||
|
||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
repository-projects: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: stable | ||
|
||
- name: Build project | ||
env: | ||
CGO_ENABLED: "1" | ||
run: | | ||
go build \ | ||
-trimpath \ | ||
-ldflags="-s -w" \ | ||
-o playground \ | ||
cmd/playground/main.go | ||
- name: Upload release asset | ||
env: | ||
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
run: | | ||
SYSTEM_UNAME="$(uname | tr '[:upper:]' '[:lower:]')" | ||
SYSTEM_ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/')" | ||
DIR_NAME="$(basename $(pwd))" | ||
CURRENT_TAG="$(git describe --exact-match --tags)" | ||
TARBALL_NAME="${DIR_NAME}_${CURRENT_TAG#v}_${SYSTEM_UNAME}_${SYSTEM_ARCH}.tar.gz" | ||
tar -cf - LICENSE README.md playground | gzip --best >"$TARBALL_NAME" | ||
gh release upload "$CURRENT_TAG" "$TARBALL_NAME" | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: tarball-${{ matrix.os }} | ||
path: | | ||
*.tar.gz | ||
homebrew_update: | ||
needs: build | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout Homebrew tap repository | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: homeport/homebrew-tap | ||
path: homebrew-tap | ||
|
||
- name: Checkout project repository | ||
uses: actions/checkout@v3 | ||
with: | ||
path: repo | ||
|
||
- name: Download all workflow run artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: tarballs | ||
|
||
- name: TAE | ||
env: | ||
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: repo/hack/update-formula.sh |
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,3 @@ | ||
dist | ||
playground | ||
*.tar.gz |
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,13 @@ | ||
--- | ||
project_name: playground | ||
version: 2 | ||
|
||
builds: | ||
- env: | ||
- CGO_ENABLED=1 | ||
main: ./cmd/playground/main.go | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -s -w | ||
mod_timestamp: '{{ .CommitTimestamp }}' |
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
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,2 +1,3 @@ | ||
# playground | ||
|
||
Playground project for tests |
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,3 @@ | ||
module github.com/homeport/playground | ||
|
||
go 1.18 |
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,72 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
BASEDIR="$(pwd)" | ||
|
||
REPO_NAME=homeport/playground | ||
LATEST_RELEASE="$(gh --repo ${REPO_NAME} release list --json tagName,isLatest | jq --raw-output '.[] | select(.isLatest) | .tagName')" | ||
|
||
DARWIN_AMD64_SHA="$(sha256sum "$BASEDIR/tarballs/tarball-macos-13/playground_${LATEST_RELEASE#v}_darwin_amd64.tar.gz" | awk '{print $1}')" | ||
DARWIN_ARM64_SHA="$(sha256sum "$BASEDIR/tarballs/tarball-macos-latest/playground_${LATEST_RELEASE#v}_darwin_arm64.tar.gz" | awk '{print $1}')" | ||
LINUX_AMD64_SHA="$(sha256sum "$BASEDIR/tarballs/tarball-ubuntu-latest/playground_${LATEST_RELEASE#v}_linux_amd64.tar.gz" | awk '{print $1}')" | ||
|
||
pushd "$BASEDIR/homebrew-tap/" >/dev/null | ||
|
||
cat <<EOF >"HomebrewFormula/playground.rb" | ||
# This file was generated by $0. DO NOT EDIT. | ||
class Playground < Formula | ||
desc "Playground project." | ||
homepage "https://github.com/${REPO_NAME}" | ||
version "${LATEST_RELEASE#v}" | ||
license "MIT" | ||
on_macos do | ||
on_intel do | ||
url "https://github.com/${REPO_NAME}/releases/download/v${LATEST_RELEASE#v}/playground_${LATEST_RELEASE#v}_darwin_amd64.tar.gz", using: CurlDownloadStrategy | ||
sha256 "${DARWIN_AMD64_SHA}" | ||
def install | ||
bin.install "playground" | ||
end | ||
end | ||
on_arm do | ||
url "https://github.com/${REPO_NAME}/releases/download/v${LATEST_RELEASE#v}/playground_${LATEST_RELEASE#v}_darwin_arm64.tar.gz", using: CurlDownloadStrategy | ||
sha256 "${DARWIN_ARM64_SHA}" | ||
def install | ||
bin.install "playground" | ||
end | ||
end | ||
end | ||
on_linux do | ||
on_intel do | ||
if Hardware::CPU.is_64_bit? | ||
url "https://github.com/${REPO_NAME}/releases/download/v${LATEST_RELEASE#v}/playground_${LATEST_RELEASE#v}_linux_amd64.tar.gz", using: CurlDownloadStrategy | ||
sha256 "${LINUX_AMD64_SHA}" | ||
def install | ||
bin.install "playground" | ||
end | ||
end | ||
end | ||
end | ||
test do | ||
system "#{bin}/playground" | ||
end | ||
end | ||
EOF | ||
|
||
git config --global user.name "Harbourmaster" | ||
git config --global user.email "[email protected]" | ||
|
||
git add HomebrewFormula/playground.rb | ||
git commit \ | ||
--message "Update playground to \`$LATEST_RELEASE\`" \ | ||
--message "" \ | ||
--message "Update playground formula to \`$LATEST_RELEASE\`." | ||
git push origin HEAD | ||
|
||
popd >/dev/null |
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,87 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, macos-13] | ||
|
||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
repository-projects: write | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: stable | ||
|
||
- name: Build project | ||
env: | ||
CGO_ENABLED: "1" | ||
run: | | ||
go build \ | ||
-trimpath \ | ||
-ldflags="-s -w" \ | ||
-o playground \ | ||
cmd/playground/main.go | ||
- name: Upload release asset | ||
env: | ||
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
run: | | ||
SYSTEM_UNAME="$(uname | tr '[:upper:]' '[:lower:]')" | ||
SYSTEM_ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/aarch64/arm64/')" | ||
DIR_NAME="$(basename $(pwd))" | ||
CURRENT_TAG="$(git describe --exact-match --tags)" | ||
TARBALL_NAME="${DIR_NAME}_${CURRENT_TAG#v}_${SYSTEM_UNAME}_${SYSTEM_ARCH}.tar.gz" | ||
tar -cf - LICENSE README.md playground | gzip --best >"$TARBALL_NAME" | ||
gh release upload "$CURRENT_TAG" "$TARBALL_NAME" | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: tarball-${{ matrix.os }} | ||
path: | | ||
*.tar.gz | ||
homebrew_update: | ||
needs: build | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout Homebrew tap repository | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: homeport/homebrew-tap | ||
path: homebrew-tap | ||
|
||
- name: Checkout project repository | ||
uses: actions/checkout@v3 | ||
with: | ||
path: repo | ||
|
||
- name: Download all workflow run artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: tarballs | ||
|
||
- name: Update Homebrew Formula | ||
env: | ||
GH_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: repo/hack/update-formula.sh |