Skip to content

Commit

Permalink
chore: update the gh release
Browse files Browse the repository at this point in the history
Signed-off-by: saltbo <saltbo@foxmail.com>
  • Loading branch information
saltbo committed Aug 5, 2023
1 parent e41a784 commit bb991ea
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 20 deletions.
72 changes: 55 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,30 @@ name: release
on:
push:
tags:
- '*'
- 'v*.*.*'

jobs:
goreleaser:
runs-on: ubuntu-latest
release:
strategy:
fail-fast: false
matrix:
build_target: [ macos-arm64, macos-x86_64, linux-arm64, linux-x86_64 ]
include:
- build_target: macos-arm64
os: macos-12
goarch: arm64
goarm: 7
- build_target: macos-x86_64
os: macos-12
- build_target: linux-arm64
os: ubuntu-latest
goarch: arm64
goarm: 7
- build_target: linux-x86_64
os: ubuntu-latest
# - build_target: windows-x86_64
# os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -17,18 +36,37 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: 1.20.x

- name: DockerHub Login
if: success() && startsWith(github.ref, 'refs/tags/')
env:
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
run: |
echo "${DOCKER_HUB_PASSWORD}" | docker login --username saltbo --password-stdin
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
- name: Build
run: GOARCH=${{ matrix.goarch }} GOARM=${{ matrix.goarm }} make build release
- uses: ksm2/archive-action@v1
id: archive
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
format: "tar.gz"
root-directory: "build/release"
name: "zpan-${{ matrix.build_target }}"
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
files: ${{ steps.archive.outputs.path }}

# docker:
# name: Publish to Docker Hub
# if: startsWith(github.ref, 'refs/tags/')
# runs-on: ubuntu-latest
# needs: release
# steps:
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1
# - name: Login to DockerHub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Build and push
# id: docker_build
# uses: docker/build-push-action@v2
# with:
# push: true
# tags: saltbo/rslocald:latest, saltbo/rslocald:${{ github.ref_name }}
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
.PHONY: all dep lint vet test test-coverage build clean

# custom define
PROJECT := zpan
MAINFILE := main.go
OS := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ARCH := $(shell uname -m)
RELEASE := $(shell git describe --tags | awk -F '-' '{print $$1}')
GIT_REPO_INFO := $(shell git config --get remote.origin.url)

ifndef COMMIT
COMMIT := git-$(shell git rev-parse --short HEAD)
endif

MODULE := "github.com/saltbo/zpan"
LDFLAGS := "-s -w -X ${MODULE}/cmd.release=${RELEASE} -X ${MODULE}/cmd.commit=${COMMIT} -X ${MODULE}/cmd.repo=${GIT_REPO_INFO}"
GO_BUILD=CGO_ENABLED=1 go build -ldflags ${LDFLAGS}
OUTPUT_FILE=build/bin/zpan
ARCHIVE_DIR=build/release/zpan-${OS}-${ARCH}

all: build

Expand All @@ -24,7 +36,16 @@ generate: ## generate the static assets
go generate ./...

build: mod ## Build the binary file
go build -v -o build/bin/$(PROJECT) $(MAINFILE)
$(GO_BUILD) -v -o $(OUTPUT_FILE) main.go

release: build
mkdir -p $(ARCHIVE_DIR)/bin
mv $(OUTPUT_FILE) $(ARCHIVE_DIR)/bin
cp LICENSE $(ARCHIVE_DIR)
cp README.md $(ARCHIVE_DIR)
cp CHANGELOG.md $(ARCHIVE_DIR)
cp deployments/zpan.service $(ARCHIVE_DIR)
cp install.sh $(ARCHIVE_DIR)

swag:
swag init -g internal/app/api/router.go --exclude client --parseDependency --parseDepth 1 --output internal/docs
Expand Down

0 comments on commit bb991ea

Please sign in to comment.