- Updated the build workflow to disable caching for the Go setup action. - This change aims to ensure a clean build environment for better consistency.
81 lines
1.9 KiB
YAML
81 lines
1.9 KiB
YAML
name: Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- dev
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
- dev
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.25'
|
|
cache: false
|
|
|
|
- name: Set up Go Proxy
|
|
run: |
|
|
echo "GOPROXY=https://goproxy.cn,direct" >> $GITHUB_ENV
|
|
echo "GOSUMDB=off" >> $GITHUB_ENV
|
|
echo "已设置国内 Go 代理"
|
|
|
|
- name: Download dependencies
|
|
run: go mod download
|
|
|
|
- name: Build
|
|
env:
|
|
GOOS: linux
|
|
GOARCH: amd64
|
|
CGO_ENABLED: 0
|
|
run: go build -v -o mcauth-linux-amd64 ./cmd/server
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: mcauth-linux-amd64
|
|
path: mcauth-linux-amd64
|
|
|
|
build-docker:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Gitea Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: code.littlelan.cn
|
|
username: ${{ secrets.GIT_USERNAME }}
|
|
password: ${{ secrets.GIT_TOKEN }}
|
|
|
|
- name: Download artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: mcauth-linux-amd64
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
build-args: |
|
|
BINARY_NAME=mcauth-linux-amd64
|
|
tags: |
|
|
code.littlelan.cn/${{ github.repository_owner }}/mcauth:latest
|
|
code.littlelan.cn/${{ github.repository_owner }}/mcauth:${{ github.sha }}
|
|
platforms: linux/amd64
|