Skip to content

Commit 2cfa8ef

Browse files
committed
init
0 parents  commit 2cfa8ef

23 files changed

+2445
-0
lines changed

.github/workflows/go.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
11+
build:
12+
name: Build
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Set up Go 1.x
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version: '1.20'
19+
20+
- name: Check out code into the Go module directory
21+
uses: actions/checkout@v4
22+
23+
- name: Get dependencies
24+
run: go get -v -t -d ./...
25+
26+
- name: Test building with vendoring (#35)
27+
run: go mod vendor && go build -mod=vendor ./cli/main.go
28+
29+
- name: Build
30+
run: |
31+
CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build -ldflags="-s -w" -o auth-thu.macos.x86_64 ./cli/main.go
32+
CGO_ENABLED=0 GOARCH=arm64 GOOS=darwin go build -ldflags="-s -w" -o auth-thu.macos.arm64 ./cli/main.go
33+
CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -ldflags="-s -w" -o auth-thu.win64.exe ./cli/main.go
34+
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.x86_64 ./cli/main.go
35+
CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.arm64 ./cli/main.go
36+
CGO_ENABLED=0 GOARCH=arm GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.arm ./cli/main.go
37+
CGO_ENABLED=0 GOARCH=arm GOARM=5 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.armv5 ./cli/main.go
38+
CGO_ENABLED=0 GOARCH=arm GOARM=6 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.armv6 ./cli/main.go
39+
CGO_ENABLED=0 GOARCH=mipsle GOOS=linux GOMIPS=softfloat go build -ldflags="-s -w" -o auth-thu.linux.mipsle ./cli/main.go
40+
CGO_ENABLED=0 GOARCH=mips GOOS=linux GOMIPS=softfloat go build -ldflags="-s -w" -o auth-thu.linux.mipsbe ./cli/main.go
41+
CGO_ENABLED=0 GOARCH=ppc64le GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.ppc64le ./cli/main.go
42+
CGO_ENABLED=0 GOARCH=riscv64 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.riscv64 ./cli/main.go
43+
CGO_ENABLED=0 GOARCH=loong64 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.loong64 ./cli/main.go
44+
45+
build-image:
46+
name: Build Docker Image
47+
runs-on: ubuntu-latest
48+
needs: build
49+
steps:
50+
- name: Check out code into the Go module directory
51+
uses: actions/checkout@v4
52+
53+
- name: Set up QEMU
54+
uses: docker/setup-qemu-action@v3
55+
56+
- name: Set up Docker Buildx
57+
uses: docker/setup-buildx-action@v3
58+
59+
- name: Build the Docker image
60+
uses: docker/build-push-action@v5
61+
with:
62+
push: false
63+
context: .

.github/workflows/release.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
10+
build:
11+
name: Build
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Set up Go 1.x
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version: '1.20'
18+
19+
- name: Check out code into the Go module directory
20+
uses: actions/checkout@v4
21+
22+
- name: Get dependencies
23+
run: go get -v -t -d ./...
24+
25+
- name: Build
26+
run: |
27+
CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build -ldflags="-s -w" -o auth-thu.macos.x86_64 ./cli/main.go
28+
CGO_ENABLED=0 GOARCH=arm64 GOOS=darwin go build -ldflags="-s -w" -o auth-thu.macos.arm64 ./cli/main.go
29+
CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -ldflags="-s -w" -o auth-thu.win64.exe ./cli/main.go
30+
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.x86_64 ./cli/main.go
31+
CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.arm64 ./cli/main.go
32+
CGO_ENABLED=0 GOARCH=arm GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.arm ./cli/main.go
33+
CGO_ENABLED=0 GOARCH=arm GOARM=5 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.armv5 ./cli/main.go
34+
CGO_ENABLED=0 GOARCH=arm GOARM=6 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.armv6 ./cli/main.go
35+
CGO_ENABLED=0 GOARCH=mipsle GOOS=linux GOMIPS=softfloat go build -ldflags="-s -w" -o auth-thu.linux.mipsle ./cli/main.go
36+
CGO_ENABLED=0 GOARCH=mips GOOS=linux GOMIPS=softfloat go build -ldflags="-s -w" -o auth-thu.linux.mipsbe ./cli/main.go
37+
CGO_ENABLED=0 GOARCH=ppc64le GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.ppc64le ./cli/main.go
38+
CGO_ENABLED=0 GOARCH=riscv64 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.riscv64 ./cli/main.go
39+
CGO_ENABLED=0 GOARCH=loong64 GOOS=linux go build -ldflags="-s -w" -o auth-thu.linux.loong64 ./cli/main.go
40+
41+
- name: Create Release
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: |
45+
tag_name="${GITHUB_REF##*/}"
46+
gh release create "$tag_name" -t "$tag_name" auth-thu.*
47+
48+
build-image:
49+
name: Build Image
50+
runs-on: ubuntu-latest
51+
needs: build
52+
env:
53+
REGISTRY: ghcr.io
54+
IMAGE_NAME: ${{ github.repository }}
55+
56+
steps:
57+
- name: Check out code into the Go module directory
58+
uses: actions/checkout@v4
59+
60+
- name: Set up QEMU
61+
uses: docker/setup-qemu-action@v3
62+
63+
- name: Set up Docker Buildx
64+
uses: docker/setup-buildx-action@v3
65+
66+
- name: Log in to the Container Registry
67+
uses: docker/login-action@v3
68+
with:
69+
registry: ${{ env.REGISTRY }}
70+
username: ${{ github.actor }}
71+
password: ${{ secrets.GITHUB_TOKEN }}
72+
73+
- name: Extract metadata
74+
id: metadata
75+
uses: docker/metadata-action@v5
76+
with:
77+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
78+
79+
- name: Build and push the Docker image
80+
uses: docker/build-push-action@v5
81+
with:
82+
push: true
83+
context: .
84+
tags: ${{ steps.metadata.outputs.tags }}
85+
labels: ${{ steps.metadata.outputs.labels }}

Dockerfile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM golang:alpine AS builder
2+
3+
WORKDIR /app
4+
COPY . .
5+
6+
RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /app/auth-thu /app/cli/main.go
7+
8+
FROM scratch
9+
10+
COPY --from=builder /app/auth-thu /auth-thu
11+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
12+
13+
ENTRYPOINT [ "/auth-thu" ]

0 commit comments

Comments
 (0)