Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gcslaoli committed Aug 7, 2022
0 parents commit f1118db
Show file tree
Hide file tree
Showing 42 changed files with 872 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* linguist-language=GO
62 changes: 62 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: hjm-certcheck Build Release
on:
push:
tags:
- v*
env:
TZ: Asia/Shanghai

jobs:
build:
name: Build And Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: './go.mod'
- name: install dependencies and set env.BIN_NAME
run: |
go version
make cli
gf version
echo ${{github.ref}}
pwd
repository_array=(${GITHUB_REPOSITORY//\// })
binname=${repository_array[1]}
echo ${binname}
echo "BIN_NAME=${binname}" >> $GITHUB_ENV

- name: Build CLI Binary For All Platform
run: |
gf build main.go -n ${{env.BIN_NAME}} -a all -s linux
- name: Move Files Before Release
run: |
cd temp
for OS in *;do for FILE in $OS/*;\
do if [[ ${OS} =~ 'windows' ]];\
then mv $FILE ${{env.BIN_NAME}}_${OS}.exe && rm -rf $OS;\
else mv $FILE ${{env.BIN_NAME}}_$OS && rm -rf $OS;\
fi;done;done
pwd
ls

- name: Create Github Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{env.BIN_NAME}} Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release Asset
id: upload-release-asset
uses: alexellis/upload-assets@0.2.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
asset_paths: '["temp/${{env.BIN_NAME}}_*"]'

23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.buildpath
.hgignore.swp
.project
.orig
.swp
.idea/
.settings/
.vscode/
vendor/
composer.lock
gitpush.sh
pkg/
bin/
cbuild
**/.DS_Store
.test/
main
output/
manifest/output/
temp/
node_modules/
yarn.lock
docs/.vitepress/dist/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 李栋

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
89 changes: 89 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
ROOT_DIR = $(shell pwd)
NAMESPACE = "default"
DEPLOY_NAME = "template-single"
DOCKER_NAME = "hjm-certcheck"
DOCKER_PREFIX = "hjmcloud"
# Install/Update to the latest CLI tool.
.PHONY: cli
cli:
@set -e; \
wget -O gf https://github.com/gogf/gf/releases/latest/download/gf_$(shell go env GOOS)_$(shell go env GOARCH) && \
chmod +x gf && \
./gf install -y && \
rm ./gf


# Check and install CLI tool.
.PHONY: cli.install
cli.install:
@set -e; \
gf -v > /dev/null 2>&1 || if [[ "$?" -ne "0" ]]; then \
echo "GoFame CLI is not installed, start proceeding auto installation..."; \
make cli; \
fi;


# Generate Go files for DAO/DO/Entity.
.PHONY: dao
dao: cli.install
@gf gen dao

# Generate Go files for Service.
.PHONY: service
service: cli.install
@gf gen service

# Build image, deploy image and yaml to current kubectl environment and make port forward to local machine.
.PHONY: start
start:
@set -e; \
make image; \
make deploy; \
make port;

# Build docker image.
.PHONY: image
image: cli.install
$(eval _TAG = $(shell git log -1 --format="%cd.%h" --date=format:"%Y%m%d%H%M%S"))
ifneq (, $(shell git status --porcelain 2>/dev/null))
$(eval _TAG = $(_TAG).dirty)
endif
$(eval _TAG = $(if ${TAG}, ${TAG}, dev))
$(eval _PUSH = $(if ${PUSH}, ${PUSH}, ))
@gf docker $(PUSH) -b "-a amd64 -s linux -p temp" -tn $(DOCKER_NAME):${_TAG} -tp $(DOCKER_PREFIX);


# Build docker image and automatically push to docker repo.
.PHONY: image.push
image.push:
@make image PUSH=-p;


# Deploy image and yaml to current kubectl environment.
.PHONY: deploy
deploy:
$(eval _TAG = $(if ${TAG}, ${TAG}, develop))

@set -e; \
mkdir -p $(ROOT_DIR)/temp/kustomize;\
cd $(ROOT_DIR)/manifest/deploy/kustomize/overlays/${_TAG};\
kustomize build > $(ROOT_DIR)/temp/kustomize.yaml;\
kubectl apply -f $(ROOT_DIR)/temp/kustomize.yaml; \
kubectl patch -n $(NAMESPACE) deployment/$(DEPLOY_NAME) -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"$(shell date +%s)\"}}}}}";

# Build binary files and publish.
.PHONY: bin.publish
bin.publish:
@set -e; \
rm -rf $(ROOT_DIR)/temp; \
gf build -n $(DOCKER_NAME) -a 386,amd64,arm,arm64 -s linux,darwin,windows -p temp;\
cd $(ROOT_DIR)/temp;\
git init;\
git add -A;\
git commit -m "deploy | $(shell date +'%Y-%m-%d %H:%M:%S')";\
echo "$(shell date +'%Y-%m-%d %H:%M:%S')|开始到gitee部署";\
git push -f git@gitee.com:$(DOCKER_PREFIX)/$(DOCKER_NAME).git master:release;\
echo "$(shell date +'%Y-%m-%d %H:%M:%S')|完成到gitee部署";\
open https://gitee.com/$(DOCKER_PREFIX)/$(DOCKER_NAME)/pages;


9 changes: 9 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# GoFrame Template For SingleRepo

Project Makefile Commands:
- `make cli`: Install or Update to the latest GoFrame CLI tool.
- `make dao`: Generate go files for `Entity/DAO/DO` according to the configuration file from `hack` folder.
- `make service`: Parse `logic` folder to generate interface go files into `service` folder.
- `make image TAG=xxx`: Run `docker build` to build image according `manifest/docker`.
- `make image.push TAG=xxx`: Run `docker build` and `docker push` to build and push image according `manifest/docker`.
- `make deploy TAG=xxx`: Run `kustomize build` to build and deploy deployment to kubernetes server group according `manifest/deploy`.
12 changes: 12 additions & 0 deletions api/v1/hello.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package v1

import (
"github.com/gogf/gf/v2/frame/g"
)

type HelloReq struct {
g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"`
}
type HelloRes struct {
g.Meta `mime:"text/html" example:"string"`
}
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module hjm-certcheck

go 1.15

require (
github.com/JetBlink/dingtalk-notify-go-sdk v0.0.0-20191112085213-0dc836cea13e
github.com/gogf/gf/v2 v2.1.2
)
Loading

0 comments on commit f1118db

Please sign in to comment.