This commit is contained in:
WJQSERVER 2024-10-09 20:53:50 +08:00
parent f3a49b83f2
commit d3d9f78820
8 changed files with 24 additions and 137 deletions

View file

@ -1,96 +0,0 @@
name: Build Alpine Dev
on:
workflow_dispatch:
push:
branches:
- 'main'
paths:
- 'DEV-VERSION'
jobs:
build:
runs-on: ubuntu-latest
env:
OUTPUT_BINARY: ghproxy-alpine
OUTPUT_ARCHIVE: ghproxy-alpine.tar.gz
GO_VERSION: 1.23.2
steps:
- uses: actions/checkout@v3
- name: Load VERSION
run: |
if [ -f DEV-VERSION ]; then
echo "VERSION=$(cat DEV-VERSION)" >> $GITHUB_ENV
else
echo "DEV-VERSION file not found!" && exit 1
fi
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Build
run: |
CGO_ENABLED=0 go build -o ${{ env.OUTPUT_BINARY }} ./main.go
- name: Package
run: |
tar -czvf ${{ env.OUTPUT_ARCHIVE }} ./${{ env.OUTPUT_BINARY }}
- name: Upload to GitHub Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.OUTPUT_BINARY }}
path: |
./${{ env.OUTPUT_ARCHIVE }}
./${{ env.OUTPUT_BINARY }}
- name: 上传至Release
id: create_release
uses: ncipollo/release-action@v1
with:
name: ${{ env.VERSION }}
artifacts: ./${{ env.OUTPUT_ARCHIVE }}, ./${{ env.OUTPUT_BINARY }}
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.VERSION }}
allowUpdates: true
prerelease: true
env:
export PATH: $PATH:/usr/local/go/bin
docker:
runs-on: ubuntu-latest
needs: build
env:
IMAGE_NAME: wjqserver/ghproxy
DOCKERFILE: docker/dockerfile/alpine/Dockerfile
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load VERSION
run: |
if [ -f DEV-VERSION ]; then
echo "VERSION=$(cat DEV-VERSION)" >> $GITHUB_ENV
else
echo "DEV-VERSION file not found!" && exit 1
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 构建镜像
uses: docker/build-push-action@v5
with:
file: ./${{ env.DOCKERFILE }}
platforms: linux/amd64
push: true
tags: |
${{ env.IMAGE_NAME }}:alpine-${{ env.VERSION }}
${{ env.IMAGE_NAME }}:alpine-dev

View file

@ -31,7 +31,7 @@ jobs:
go-version: ${{ env.GO_VERSION }}
- name: Build
run: |
go build -o ${{ env.OUTPUT_BINARY }} ./main.go
CGO_ENABLED=0 go build -o ${{ env.OUTPUT_BINARY }} ./main.go
- name: Package
run: |
tar -czvf ${{ env.OUTPUT_ARCHIVE }} ./${{ env.OUTPUT_BINARY }}