-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add build script for Gex (#11)
* Add build-gex script * Add github workflow for generating gex bins * Add setup-go action to gen-gex workflow
- Loading branch information
1 parent
504ddaa
commit 298d0f1
Showing
10 changed files
with
84 additions
and
4 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,34 @@ | ||
name: Generate nodetime binaries | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'gex/*.go' | ||
- 'scripts/gen-gex' | ||
|
||
jobs: | ||
gen-gex: | ||
name: "Generate gex binaries" | ||
runs-on: ubuntu-latest | ||
concurrency: gen-gex | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-go@v4 | ||
if: env.GIT_DIFF | ||
with: | ||
go-version: '1.21' | ||
|
||
- run: ./scripts/gen-gex | ||
|
||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v4 | ||
with: | ||
title: "feat(gex): update binaries" | ||
commit-message: "feat(gex): update binaries" | ||
body: "" | ||
branch: feat/gen-gex | ||
delete-branch: true |
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
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,46 @@ | ||
#!/bin/bash | ||
|
||
# This script builds Gex for multiple platforms and creates a tarball for each platform. | ||
# It clones the Gex repository, checks out the specified version, and builds the binary for each platform. | ||
# The resulting tarballs are saved in the gex directory. | ||
|
||
set -e | ||
|
||
GIT_REPOSITORY="https://github.com/cosmos/gex.git" | ||
GOROOT=$(go env GOROOT) | ||
WORKDIR=$(pwd) | ||
PLATFORMS="darwin/amd64 darwin/arm64 linux/amd64 linux/arm64" | ||
|
||
# Cleans up temporary files and directories | ||
clean_up() { | ||
test -d "$tmp_dir" && rm -fr "$tmp_dir" | ||
} | ||
|
||
# Creates a temporary directory and sets up a trap to clean it up on exit | ||
tmp_dir=$(mktemp -d -t gex.XXXXXX) | ||
trap "clean_up $tmp_dir" EXIT | ||
|
||
# Clones the Gex repository into the temporary directory and checkout the latest version | ||
git clone --quiet ${GIT_REPOSITORY} ${tmp_dir} | ||
cd ${tmp_dir} | ||
version=$(git tag --list --sort=version:refname 'v*' | tail -1) | ||
git checkout --quiet ${version} | ||
echo "Latest Version: ${version}" | ||
|
||
# Builds Gex for each platform and creates a tarball for each one | ||
for platform in ${PLATFORMS} | ||
do | ||
goos=${platform%/*} | ||
goarch=${platform#*/} | ||
|
||
GOOS=$goos GOARCH=$goarch go build -o gex-${goarch}-${goos} 2>&1 | ||
|
||
# The sorting, owner, group and mtime is to ensure md5 equality of the tar output | ||
# From: https://stackoverflow.com/questions/32997526/how-to-create-a-tar-file-that-omits-timestamps-for-its-contents | ||
# piping into gzip with --no-name is to ensure md5 equality of the compressed tar ball (if not you get different hash every time). | ||
# From: https://stackoverflow.com/questions/36464358/why-do-the-md5-hashes-of-two-tarballs-of-the-same-file-differ | ||
TZ=UTC0 tar --sort=name --owner=root:0 --group=root:0 --mtime='2019-01-01 00:00:00' -cvf - gex-${goarch}-${goos} | gzip --no-name > gex-${goarch}-${goos}.tar.gz | ||
done | ||
|
||
# Moves the tarballs to the gex directory | ||
mv gex-*.tar.gz ${WORKDIR}/gex |