qinglong-go/.gitea/workflows/ci.yml

94 lines
3.2 KiB
YAML
Raw Normal View History

2023-09-05 11:35:54 +00:00
name: CI
on: [push, pull_request]
env:
2023-12-29 11:19:40 +00:00
BINARY_Name: "qinglong-go"
2023-09-05 11:35:54 +00:00
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"
GOPROXY: "https://goproxy.cn,direct"
jobs:
build:
name: Build binary CI
runs-on: ubuntu-latest
container:
2023-12-29 11:19:40 +00:00
image: ghcr.io/catthehacker/ubuntu:act-latest
2023-09-05 11:35:54 +00:00
# 持久化工具目录
steps:
2023-09-08 09:52:24 +00:00
- name: Checkout
2024-05-09 16:18:51 +00:00
uses: https://huoxue.link:12300/huoxue1/checkout@main
2023-09-08 09:52:24 +00:00
with:
fetch-depth: 0
2023-09-05 11:35:54 +00:00
- name: setup go
2023-12-29 11:19:40 +00:00
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
2023-09-05 11:35:54 +00:00
- name: Fetch all tags
run: git fetch --force --tags
2023-12-29 11:19:40 +00:00
- 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 }}
2023-09-05 11:35:54 +00:00
- name: Run GoReleaser
2023-12-29 11:19:40 +00:00
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
export GITEA_TOKEN=${{ secrets.TOKEN }}
goreleaser build --snapshot --timeout 5h30m --clean
2023-09-05 11:35:54 +00:00
env:
GITEA_TOKEN: ${{ secrets.TOKEN }}
2023-12-29 11:19:40 +00:00
- name: Set up QEMU
id: qemu
2024-05-09 16:18:51 +00:00
uses: https://huoxue.link:12300/huoxue1/setup-qemu-action@master
2023-12-29 11:19:40 +00:00
- name: Set up Docker Buildx
id: buildx
2024-05-09 16:18:51 +00:00
uses: https://huoxue.link:12300/huoxue1/setup-buildx-action@master
2023-12-29 11:19:40 +00:00
- name: Docker meta
id: meta
2024-05-09 16:18:51 +00:00
uses: https://huoxue.link:12300/huoxue1/metadata-action@master
2023-12-29 11:19:40 +00:00
with:
2024-05-09 15:32:13 +00:00
images: registry.cn-hangzhou.aliyuncs.com/huoxue1/qinglong-go
2023-12-29 11:19:40 +00:00
tags: |
type=raw,value=latest
type=ref,event=tag
- name: Docker Login
if: github.event_name != 'pull_request'
2024-05-09 16:18:51 +00:00
uses: https://huoxue.link:12300/huoxue1/login-action@master
2023-12-29 11:19:40 +00:00
with:
2024-05-09 15:32:13 +00:00
registry: registry.cn-hangzhou.aliyuncs.com
2023-12-29 11:19:40 +00:00
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
- name: Build and push
id: docker_build
2024-05-09 16:18:51 +00:00
uses: https://huoxue.link:12300/huoxue1/build-push-action@master
2023-12-29 11:19:40 +00:00
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
2023-09-08 09:52:24 +00:00
2023-09-05 11:35:54 +00:00