name: CI on: [push, pull_request] env: BINARY_Name: "qinglong-go" COMMIT_ID: "${{ github.sha }}" PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request." LD_FLAGS: "-w -s" GO111MODULE: "on" GOPROXY: "https://mirrors.aliyun.com/goproxy/,direct" jobs: build: name: Build binary CI runs-on: ubuntu-latest container: image: ghcr.io/catthehacker/ubuntu:act-latest # 持久化工具目录 steps: - name: Checkout uses: https://huoxue.link:12300/huoxue1/checkout@main with: fetch-depth: 0 - name: setup go run: | wget https://studygolang.com/dl/golang/go1.21.3.linux-amd64.tar.gz tar -xzf ./go1.21.3.linux-amd64.tar.gz -C /usr/local echo 'export GOROOT=/usr/local/go' >> $GITHUB_ENV ln -s /usr/local/go/bin/go /usr/bin/go wget https://huoxue.link:12300/api/packages/huoxue1/generic/goreleaser/amd64_latest/goreleaser.tar.gz tar -xzvf ./goreleaser.tar.gz -C /usr/local rm ./go1.21.3.linux-amd64.tar.gz rm ./goreleaser.tar.gz ln -s /usr/local/goreleaser /usr/bin/goreleaser - name: Fetch all tags run: git fetch --force --tags - name: Check snapshot if: "!startsWith(github.ref, 'refs/tags/')" id: snapshot run: echo '::set-output name=ARG::--snapshot' - name: push release if: "startsWith(github.ref, 'refs/tags/')" run: | export GITEA_TOKEN=${{ secrets.TOKEN }} goreleaser release --timeout 5h30m --clean env: GITEA_TOKEN: ${{ secrets.TOKEN }} - name: Run GoReleaser if: "!startsWith(github.ref, 'refs/tags/')" run: | export GITEA_TOKEN=${{ secrets.TOKEN }} goreleaser build --snapshot --timeout 5h30m --clean env: GITEA_TOKEN: ${{ secrets.TOKEN }} - name: Set up QEMU id: qemu uses: https://huoxue.link:12300/huoxue1/setup-qemu-action@master - name: Set up Docker Buildx id: buildx uses: https://huoxue.link:12300/huoxue1/setup-buildx-action@master - name: Docker meta id: meta uses: https://huoxue.link:12300/huoxue1/metadata-action@master with: images: registry.cn-hangzhou.aliyuncs.com/huoxue1/qinglong-go tags: | type=raw,value=latest type=ref,event=tag - name: Docker Login if: github.event_name != 'pull_request' uses: https://huoxue.link:12300/huoxue1/login-action@master with: registry: registry.cn-hangzhou.aliyuncs.com username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} - name: Build and push id: docker_build uses: https://huoxue.link:12300/huoxue1/build-push-action@master with: context: . push: ${{ github.event_name != 'pull_request' }} platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max shm-size: 2g ulimit: core=0:0