Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Aug 5, 2023
0 parents commit 3ad2bbb
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: go

on:
schedule:
- cron: '50 10 * * *'

jobs:
go:
runs-on: ubuntu-16.04
strategy:
matrix:
branch: [master, release-branch.go1.20, release-branch.go1.19, release-branch.go1.18]
goos: [linux, windows, darwin]
goarch: [amd64, arm64]
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.20'
check-latest: true
- name: Setup
run: |
sudo DEBIAN_FRONTEND=noninteractive apt install -yq golang pigz bzip2
- name: Clone
run: |
git clone -b ${{ matrix.branch }} https://go.googlesource.com/go
sudo mv go /opt/
- name: Patch
run: |
wget https://github.com/phuslu/go/raw/master/01-dot-goenv.patch
patch -p1 -d /opt/go < 01-dot-goenv.patch
- name: Make
run: |
cd /opt/go/src
cgo_enabled=$(test "${{ matrix.goos }}_${{ matrix.goarch }}" = "linux_amd64" && echo 1 || echo 0)
env CGO_ENABLED=${cgo_enabled} GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} ./make.bash
- name: Tarball
run: |
cd /opt/go/bin
test -d ${{ matrix.goos }}_${{ matrix.goarch }} && rm -f go gofmt && mv -f ${{ matrix.goos }}_${{ matrix.goarch }}/* . && rmdir ${{ matrix.goos }}_${{ matrix.goarch }}
cd /opt
gover=$(echo ${{ matrix.branch }} | grep -oP 'go1.+' || echo gotip)
tar -cf /tmp/${gover}.${{ matrix.goos }}-${{ matrix.goarch }}.tar go
pigz -9 /tmp/${gover}.${{ matrix.goos }}-${{ matrix.goarch }}.tar
- name: Release
run: |
curl -L https://github.com/github-release/github-release/releases/download/v0.10.0/linux-amd64-github-release.bz2 | bzip2 -d >github-release
chmod +x github-release
gover=$(echo ${{ matrix.branch }} | grep -oP 'go1.+' || echo gotip)
./github-release upload --replace --user phuslu --repo go --tag v0.0.0 --name ${gover}.${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz --file /tmp/${gover}.${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GOTIP_TOKEN }}
62 changes: 62 additions & 0 deletions 01-dot-goenv.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
commit 33fda521f72037473a9153266a28e2dedc510f02
Author: phus.lu <phus.lu@gmail.com>
Date: 2022-06-17 23:49:02 +0800

go/build: add .goenv support

diff --git a/src/go/build/build.go b/src/go/build/build.go
index 420873c256..c038380bc9 100644
--- a/src/go/build/build.go
+++ b/src/go/build/build.go
@@ -351,6 +351,51 @@ func defaultContext() Context {
c.CgoEnabled = false
}

+ if os.Getenv("GOENV_ENABLED") == "1" {
+ dir, _ := os.Getwd()
+ var lines []string
+ for i := 0; i < 6; i++ {
+ if data, _ := os.ReadFile(filepath.Join(dir, ".goenv")); len(data) != 0 {
+ lines = strings.Split(string(data), "\n")
+ break
+ }
+ if dir = filepath.Dir(dir); dir == "/" {
+ break
+ }
+ }
+ for _, line := range lines {
+ parts := strings.SplitN(line, "=", 2)
+ if len(parts) == 1 || strings.HasPrefix(strings.TrimSpace(line), "#") {
+ continue
+ }
+ key := strings.TrimSpace(parts[0])
+ value := strings.TrimSpace(parts[1])
+ os.Setenv(key, value)
+ switch key {
+ case "CGO_ENABLED":
+ switch value {
+ case "1":
+ c.CgoEnabled = true
+ case "0":
+ c.CgoEnabled = false
+ }
+ case "GOOS":
+ c.GOOS = value
+ case "GOARCH":
+ c.GOARCH = value
+ case "GOPATH":
+ c.GOPATH = value
+ case "GOROOT":
+ c.GOROOT = value
+ case "http_proxy":
+ os.Setenv("http_proxy", value)
+ os.Setenv("https_proxy", value)
+ os.Setenv("HTTP_PROXY", value)
+ os.Setenv("HTTPS_PROXY", value)
+ }
+ }
+ }
+
return c
}

33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## go daily builds

### gotip
- [gotip.linux-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/gotip.linux-amd64.tar.gz)
- [gotip.linux-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/gotip.linux-arm64.tar.gz)
- [gotip.windows-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/gotip.windows-amd64.tar.gz)
- [gotip.windows-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/gotip.windows-arm64.tar.gz)
- [gotip.darwin-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/gotip.darwin-amd64.tar.gz)
- [gotip.darwin-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/gotip.darwin-arm64.tar.gz)

### go1.20
- [go1.20.linux-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.20.linux-amd64.tar.gz)
- [go1.20.linux-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.20.linux-arm64.tar.gz)
- [go1.20.windows-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.20.windows-amd64.tar.gz)
- [go1.20.windows-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.20.windows-arm64.tar.gz)
- [go1.20.darwin-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.20.darwin-amd64.tar.gz)
- [go1.20.darwin-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.20.darwin-arm64.tar.gz)

### go1.19
- [go1.19.linux-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.19.linux-amd64.tar.gz)
- [go1.19.linux-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.19.linux-arm64.tar.gz)
- [go1.19.windows-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.19.windows-amd64.tar.gz)
- [go1.19.windows-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.19.windows-arm64.tar.gz)
- [go1.19.darwin-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.19.darwin-amd64.tar.gz)
- [go1.19.darwin-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.19.darwin-arm64.tar.gz)

### go1.18
- [go1.18.linux-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.18.linux-amd64.tar.gz)
- [go1.18.linux-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.18.linux-arm64.tar.gz)
- [go1.18.windows-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.18.windows-amd64.tar.gz)
- [go1.18.windows-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.18.windows-arm64.tar.gz)
- [go1.18.darwin-amd64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.18.darwin-amd64.tar.gz)
- [go1.18.darwin-arm64.tar.gz](https://github.com/phuslu/go/releases/download/v0.0.0/go1.18.darwin-arm64.tar.gz)

0 comments on commit 3ad2bbb

Please sign in to comment.