|
| 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 }} |
0 commit comments