Skip to content

Commit

Permalink
feat(ci): auto release
Browse files Browse the repository at this point in the history
  • Loading branch information
NX-Official committed Jul 30, 2024
1 parent 5d8f2bf commit de6608e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ jobs:
steps:
- name: Check out the code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# 记得在 GitHub 仓库的 Secrets 中添加 DOCKER_USERNAME DOCKER_PASSWORD DOCKER_REPOSITORY 三个环境变量
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
Expand All @@ -33,8 +34,7 @@ jobs:
context: .
file: ./Dockerfile
push: true
# 使用 commit hash 作为镜像 tag
tags: |
${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:latest
${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ env.SHORT_SHA }}
platforms: linux/amd64,linux/arm64 # 为多个架构编译,如果你确定只需要其中一种,可以仅保留一种
platforms: linux/amd64,linux/arm64
7 changes: 6 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ jobs:
build-and-push:
needs: [ run-makefile ]
uses: ./.github/workflows/docker-publish.yaml
secrets: inherit
secrets: inherit

release:
needs: [ run-makefile ]
uses: ./.github/workflows/run-goreleaser.yaml
secrets: inherit
29 changes: 29 additions & 0 deletions .github/workflows/run-goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release

on:
workflow_call:

jobs:
release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Check out the code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: 2.1.0
args: release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}

0 comments on commit de6608e

Please sign in to comment.