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