add ci
CI / Build binary CI (push) Successful in 18m35s
Details
CI / Build binary CI (push) Successful in 18m35s
Details
This commit is contained in:
parent
5bbe6c3bcd
commit
e088ad6990
|
@ -3,13 +3,11 @@ name: CI
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
BINARY_PREFIX: "qinglong-go_"
|
|
||||||
BINARY_SUFFIX: ""
|
BINARY_Name: "qinglong-go"
|
||||||
COMMIT_ID: "${{ github.sha }}"
|
COMMIT_ID: "${{ github.sha }}"
|
||||||
PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request."
|
PR_PROMPT: "::warning:: Build artifact will not be uploaded due to the workflow is trigged by pull request."
|
||||||
LD_FLAGS: "-w -s"
|
LD_FLAGS: "-w -s"
|
||||||
HTTP_PROXY: "http://172.17.0.1:7890"
|
|
||||||
HTTPS_PROXY: "http://172.17.0.1:7890"
|
|
||||||
GOPROXY: "https://goproxy.cn,direct"
|
GOPROXY: "https://goproxy.cn,direct"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -17,31 +15,79 @@ jobs:
|
||||||
name: Build binary CI
|
name: Build binary CI
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: node:16-bullseye
|
image: ghcr.io/catthehacker/ubuntu:act-latest
|
||||||
# 持久化工具目录
|
# 持久化工具目录
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: https://gh.huoxue.store/actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: setup go
|
- name: setup go
|
||||||
uses: https://github.com/actions/setup-go@v4
|
run: |
|
||||||
with:
|
wget https://studygolang.com/dl/golang/go1.21.3.linux-amd64.tar.gz
|
||||||
go-version: '1.20'
|
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
|
- name: Fetch all tags
|
||||||
run: git fetch --force --tags
|
run: git fetch --force --tags
|
||||||
- name: Run GoReleaser
|
- name: Check snapshot
|
||||||
uses: https://huoxue.link:12300/huoxue1/goreleaser-action@master
|
if: "!startsWith(github.ref, 'refs/tags/')"
|
||||||
with:
|
id: snapshot
|
||||||
version: latest
|
run: echo '::set-output name=ARG::--snapshot'
|
||||||
args: build --snapshot
|
- name: push release
|
||||||
|
if: "startsWith(github.ref, 'refs/tags/')"
|
||||||
|
run: |
|
||||||
|
export GITEA_TOKEN=${{ secrets.TOKEN }}
|
||||||
|
goreleaser release --timeout 5h30m --clean
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.TOKEN }}
|
GITEA_TOKEN: ${{ secrets.TOKEN }}
|
||||||
# - name: upload-artifact
|
- name: Run GoReleaser
|
||||||
# uses: actions/upload-artifact@v3
|
if: "!startsWith(github.ref, 'refs/tags/')"
|
||||||
# with:
|
run: |
|
||||||
# name: my-artifact
|
export GITEA_TOKEN=${{ secrets.TOKEN }}
|
||||||
# path: dist/*/*
|
goreleaser build --snapshot --timeout 5h30m --clean
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.TOKEN }}
|
||||||
|
- name: Set up QEMU
|
||||||
|
id: qemu
|
||||||
|
uses: https://gh.huoxue.store/docker/setup-qemu-action@v2
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: https://gh.huoxue.store/docker/setup-buildx-action@v2
|
||||||
|
- name: Docker meta
|
||||||
|
id: meta
|
||||||
|
uses: https://gh.huoxue.store/docker/metadata-action@v4
|
||||||
|
with:
|
||||||
|
images: huoxue.link:12300/huoxue1/qinglong-go
|
||||||
|
tags: |
|
||||||
|
type=raw,value=latest
|
||||||
|
type=ref,event=tag
|
||||||
|
- name: Docker Login
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: https://gh.huoxue.store/docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: huoxue.link:12300
|
||||||
|
username: ${{ secrets.USERNAME }}
|
||||||
|
password: ${{ secrets.PASSWORD }}
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: https://gh.huoxue.store/docker/build-push-action@v3
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,89 +0,0 @@
|
||||||
name: docker build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'Main'
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- 'Main'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
-
|
|
||||||
name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
-
|
|
||||||
name: Fetch all tags
|
|
||||||
run: git fetch --force --tags
|
|
||||||
-
|
|
||||||
name: Set up Go
|
|
||||||
uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: "1.20"
|
|
||||||
-
|
|
||||||
name: Cache Go modules
|
|
||||||
uses: actions/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cache/go-build
|
|
||||||
~/go/pkg/mod
|
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-go-
|
|
||||||
-
|
|
||||||
name: Set up QEMU
|
|
||||||
id: qemu
|
|
||||||
uses: docker/setup-qemu-action@v2
|
|
||||||
-
|
|
||||||
name: Set up Docker Buildx
|
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@v2
|
|
||||||
-
|
|
||||||
name: Check snapshot
|
|
||||||
if: "!startsWith(github.ref, 'refs/tags/')"
|
|
||||||
id: snapshot
|
|
||||||
run: echo '::set-output name=ARG::--snapshot'
|
|
||||||
-
|
|
||||||
name: Run GoReleaser
|
|
||||||
uses: goreleaser/goreleaser-action@v3
|
|
||||||
with:
|
|
||||||
distribution: goreleaser
|
|
||||||
version: latest
|
|
||||||
args: build --rm-dist --id docker ${{ steps.snapshot.outputs.ARG }}
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
-
|
|
||||||
name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
images: huoxue1/qinglong-go
|
|
||||||
tags: |
|
|
||||||
type=raw,value=latest
|
|
||||||
type=ref,event=tag
|
|
||||||
-
|
|
||||||
name: Docker Login
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
||||||
-
|
|
||||||
name: Build and push
|
|
||||||
id: docker_build
|
|
||||||
uses: docker/build-push-action@v3
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
platforms: linux/amd64,linux/arm64,linux/386,linux/arm
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
cache-from: type=gha
|
|
||||||
cache-to: type=gha,mode=max
|
|
||||||
ulimit: core=0:0
|
|
|
@ -1,31 +0,0 @@
|
||||||
name: release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v*'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
goreleaser:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v2.3.4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v2
|
|
||||||
with:
|
|
||||||
go-version: '1.20'
|
|
||||||
|
|
||||||
- name: Run GoReleaser
|
|
||||||
uses: goreleaser/goreleaser-action@v2
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
args: release --rm-dist
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.TOKEN }}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ before:
|
||||||
- go mod tidy
|
- go mod tidy
|
||||||
builds:
|
builds:
|
||||||
|
|
||||||
- id: nowin
|
- id: docker
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
- GO111MODULE=on
|
- GO111MODULE=on
|
||||||
|
@ -19,19 +19,7 @@ builds:
|
||||||
- -trimpath
|
- -trimpath
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w -X github.com/huoxue1/qinglong-go/service/config.VERSION=v{{.Version}}
|
- -s -w -X github.com/huoxue1/qinglong-go/service/config.VERSION=v{{.Version}}
|
||||||
- id: win
|
|
||||||
env:
|
|
||||||
- CGO_ENABLED=0
|
|
||||||
- GO111MODULE=on
|
|
||||||
goos:
|
|
||||||
- windows
|
|
||||||
goarch:
|
|
||||||
- amd64
|
|
||||||
mod_timestamp: "{{ .CommitTimestamp }}"
|
|
||||||
flags:
|
|
||||||
- -trimpath
|
|
||||||
ldflags:
|
|
||||||
- -s -w -X github.com/huoxue1/qinglong-go/service/config.VERSION.VERSION=v{{.Version}}
|
|
||||||
checksum:
|
checksum:
|
||||||
name_template: "{{ .ProjectName }}_checksums.txt"
|
name_template: "{{ .ProjectName }}_checksums.txt"
|
||||||
changelog:
|
changelog:
|
||||||
|
@ -47,17 +35,10 @@ changelog:
|
||||||
- go mod tidy
|
- go mod tidy
|
||||||
|
|
||||||
archives:
|
archives:
|
||||||
- id: binary
|
|
||||||
builds:
|
|
||||||
- win
|
|
||||||
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
|
|
||||||
format_overrides:
|
|
||||||
- goos: windows
|
|
||||||
format: binary
|
|
||||||
- id: nowin
|
- id: nowin
|
||||||
builds:
|
builds:
|
||||||
- nowin
|
- docker
|
||||||
- win
|
|
||||||
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
|
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
|
||||||
format_overrides:
|
format_overrides:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
|
|
|
@ -46,8 +46,8 @@ RUN set -x \
|
||||||
&& rm -rf /root/.npm \
|
&& rm -rf /root/.npm \
|
||||||
&& mkdir -p ${QL_DIR}/data \
|
&& mkdir -p ${QL_DIR}/data \
|
||||||
&& cd ${QL_DIR} \
|
&& cd ${QL_DIR} \
|
||||||
&& wget https://github.com/huoxue1/qinglong/releases/download/v1.0.1/static.tar.gz \
|
&& wget https://huoxue.link:12300/api/packages/huoxue1/generic/front-qinglong-go/latest/front-qinglong-go.tar.gz \
|
||||||
&& tar -xzvf static.tar.gz
|
&& tar -xzvf front-qinglong-go.tar.gz
|
||||||
|
|
||||||
COPY ./dist/docker_linux_$TARGETARCH*/qinglong-go ${QL_DIR}/ql
|
COPY ./dist/docker_linux_$TARGETARCH*/qinglong-go ${QL_DIR}/ql
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue