mirror of
https://github.com/eiblog/eiblog.git
synced 2026-03-01 00:34:58 +08:00
chore: renew github flow
This commit is contained in:
@@ -25,6 +25,8 @@ jobs:
|
|||||||
- name: Docker tag
|
- name: Docker tag
|
||||||
id: vars
|
id: vars
|
||||||
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
|
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
- name: Docker Buildx
|
- name: Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
- name: Docker login
|
- name: Docker login
|
||||||
@@ -33,54 +35,17 @@ jobs:
|
|||||||
registry: registry.cn-hangzhou.aliyuncs.com
|
registry: registry.cn-hangzhou.aliyuncs.com
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
- name: Build binary
|
- name: Build image
|
||||||
run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build
|
run: scripts/run_build.sh deepzz0 ${{ steps.vars.outputs.tag }}
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v2
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: ./Dockerfile
|
|
||||||
push: true
|
|
||||||
tags: |
|
|
||||||
registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog:latest
|
|
||||||
registry.cn-hangzhou.aliyuncs.com/deepzz/eiblog:${{ steps.vars.outputs.tag }}
|
|
||||||
|
|
||||||
- name: Package tar
|
- name: Package tar
|
||||||
run: ./dist.sh
|
run: scripts/dist_tar.sh ${{ steps.vars.outputs.tag }}
|
||||||
- name: Create release
|
- name: Release push
|
||||||
id: create_release
|
uses: softprops/action-gh-release@v1
|
||||||
uses: actions/create-release@v1
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.vars.outputs.tag }}
|
files: |
|
||||||
|
*.tar.gz
|
||||||
release_name: Release ${{ steps.vars.outputs.tag }}
|
release_name: Release ${{ steps.vars.outputs.tag }}
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
- name: Upload asset darwin
|
|
||||||
uses: actions/upload-release-asset@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: eiblog-${{ steps.vars.outputs.tag }}.darwin-amd64.tar.gz
|
|
||||||
asset_name: eiblog-${{ steps.vars.outputs.tag }}.darwin-amd64.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
- name: Upload asset linux
|
|
||||||
uses: actions/upload-release-asset@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: eiblog-${{ steps.vars.outputs.tag }}.linux-amd64.tar.gz
|
|
||||||
asset_name: eiblog-${{ steps.vars.outputs.tag }}.linux-amd64.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
- name: Upload asset windows
|
|
||||||
uses: actions/upload-release-asset@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: eiblog-${{ steps.vars.outputs.tag }}.windows-amd64.tar.gz
|
|
||||||
asset_name: eiblog-${{ steps.vars.outputs.tag }}.windows-amd64.tar.gz
|
|
||||||
asset_content_type: application/gzip
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
*.so
|
*.so
|
||||||
*.dylib
|
*.dylib
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
|
*.tar.gz
|
||||||
|
|
||||||
# Test binary, built with `go test -c`
|
# Test binary, built with `go test -c`
|
||||||
*.test
|
*.test
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
.PHONY: demo build swag
|
.PHONY: demo build swag
|
||||||
|
|
||||||
REGISTRY=localhost
|
tag=`git describe --abbrev=0 --tags`
|
||||||
IMAGE_TAG=`git describe --tags`
|
|
||||||
|
|
||||||
swag:
|
swag:
|
||||||
@scripts/swag_init.sh
|
@scripts/swag_init.sh
|
||||||
@@ -19,9 +18,9 @@ blog:
|
|||||||
backup:
|
backup:
|
||||||
@scripts/run_app.sh backup
|
@scripts/run_app.sh backup
|
||||||
|
|
||||||
# build docker
|
# dist tar
|
||||||
build:
|
dist:
|
||||||
@scripts/run_build.sh $(REGISTRY) $(IMAGE_TAG)
|
@scripts/dist_tar.sh $(tag)
|
||||||
|
|
||||||
# protoc
|
# protoc
|
||||||
protoc:
|
protoc:
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ COPY LICENSE /app/LICENSE
|
|||||||
COPY bin/backend /app/backend
|
COPY bin/backend /app/backend
|
||||||
COPY conf /app/conf
|
COPY conf /app/conf
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9001
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
CMD ["backend"]
|
CMD ["backend"]
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ COPY LICENSE /app/LICENSE
|
|||||||
|
|
||||||
COPY bin/backend /app/backend
|
COPY bin/backend /app/backend
|
||||||
COPY conf /app/conf
|
COPY conf /app/conf
|
||||||
|
COPY website /app/website
|
||||||
|
COPY assets /app/assets
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// Package main provides ...
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("hello world!")
|
||||||
|
}
|
||||||
Executable
+27
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
_tag="$1"
|
||||||
|
_arch=$(go env GOARCH)
|
||||||
|
|
||||||
|
# prepare dir ./bin
|
||||||
|
mkdir -p ./bin
|
||||||
|
|
||||||
|
for file in pkg/core/*; do
|
||||||
|
app="$(basename $file)";
|
||||||
|
# tar platform
|
||||||
|
for os in linux darwin windows; do
|
||||||
|
_target="$app-$_tag.$os-$_arch.tar.gz"
|
||||||
|
CGO_ENABLED=0 GOOS=$os GOARCH=$_arch \
|
||||||
|
go build -o bin/backend "./cmd/$app"
|
||||||
|
if [ "$app" == "blog" ]; then
|
||||||
|
tar czf $_target conf website assets bin/backend
|
||||||
|
else
|
||||||
|
tar czf $_target conf bin/backend
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
# clean dir ./bin
|
||||||
|
rm -rf ./bin
|
||||||
@@ -4,6 +4,7 @@ set -e
|
|||||||
|
|
||||||
_registry="$1"
|
_registry="$1"
|
||||||
_tag="$2"
|
_tag="$2"
|
||||||
|
_platform="linux/amd64,linux/arm64,linux/386"
|
||||||
|
|
||||||
if [ -z "$_registry" ] || [ -z "$_tag" ]; then
|
if [ -z "$_registry" ] || [ -z "$_tag" ]; then
|
||||||
echo "Please specify image repository and tag."
|
echo "Please specify image repository and tag."
|
||||||
@@ -12,12 +13,18 @@ fi
|
|||||||
|
|
||||||
# prepare dir ./bin
|
# prepare dir ./bin
|
||||||
mkdir -p ./bin
|
mkdir -p ./bin
|
||||||
|
# create builder
|
||||||
|
docker buildx create --use --name builder
|
||||||
|
|
||||||
# build demo app
|
# build demo app
|
||||||
for file in pkg/core/*; do
|
for file in pkg/core/*; do
|
||||||
app="$(basename $file)";
|
app="$(basename $file)";
|
||||||
GOOS=linux GOARCH=amd64 go build -o bin/backend "./cmd/$app"
|
CGO_ENABLED=0 go build -o bin/backend "./cmd/$app"
|
||||||
docker build -f "build/package/$app.Dockerfile" -t "$_registry/$app:$_tag" .
|
# docker image
|
||||||
|
docker buildx build --platform "$_platform" \
|
||||||
|
-t "$_registry/$app:latest" \
|
||||||
|
-t "$_registry/$app:$_tag" \
|
||||||
|
--push .
|
||||||
done
|
done
|
||||||
|
|
||||||
# clean dir ./bin
|
# clean dir ./bin
|
||||||
|
|||||||
Reference in New Issue
Block a user