This commit is contained in:
2024-04-17 21:52:03 +08:00
parent 7748407583
commit b687acb94c
12 changed files with 114 additions and 289 deletions

View File

@ -1,66 +0,0 @@
name: Build and Push Docker
on:
push:
branches:
- dev
tags:
- "*"
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_HUB_USERNAME }}/sub2clash
ghcr.io/${{ github.repository }}
- name: Prepare args
id: prep
run: |
if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then
VERSION="${{ github.sha }}"
fi
if [[ "$GITHUB_REF" == 'refs/heads/dev' ]]; then
VERSION="${{ github.sha }}"
fi
if [[ "$GITHUB_REF" == 'refs/tags/'* ]]; then
VERSION=$TAG_NAME
fi
echo "version=$VERSION" >> $GITHUB_ENV
- name: Set up Docker buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image to GHCR and Docker Hub
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
build-args: version=${{ env.version }}
push: true
platforms: linux/amd64,linux/arm,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -1,31 +0,0 @@
name: Build and Release
on:
push:
tags:
- "*"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.5
- name: Run goreleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --rm-dist --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}