diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..da994f4f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,63 @@ +name: "Bug Report" +description: Report a bug to help improve the project. +title: "bug: " +body: + - type: markdown + attributes: + value: | + Thank you for taking the time to report this bug! + + _The more information you share, the faster we can identify and fix the bug._ + + Prior to opening the issue, please make sure that you: + + - Use English to communicate. + - Search the [open issues](https://github.com/APIParkLab/APIPark/issues) and [discussion forum](https://github.com/APIParkLab/APIPark/discussions) to avoid duplicating the issue. + + - type: textarea + id: current-behavior + attributes: + label: Current Behavior + description: Describe the issue you are facing. + placeholder: | + What is the issue with the current behavior? + validations: + required: true + - type: textarea + id: expected-behavior + attributes: + label: Expected Behavior + description: Describe what you expected to happen. + placeholder: | + What did you expect to happen instead? + validations: + required: false + - type: textarea + id: error + attributes: + label: Error Logs + description: Paste the error logs if any. + validations: + required: false + - type: textarea + id: steps + attributes: + label: Steps to Reproduce + description: Share the steps you took so that we can reproduce the issue. Reports without proper steps details will likely be closed. + placeholder: | + 1. Run apinto via the Docker image. + 2. Create a Route with the Admin API. + 3. Try configuring ... + 4. ... + validations: + required: true + - type: textarea + id: environment + attributes: + label: Environment + description: Share your environment details. Reports without proper environment details will likely be closed. + value: | + - APINTO Dashboard version (run `apinto dashboard version`): + - Operating system (run `uname -a`): + validations: + required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..05531c1e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: APIPark Discussion Forum + url: https://github.com/APIParkLab/APIPark/discussions + about: Please ask and answer questions here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/docs_issue.yml b/.github/ISSUE_TEMPLATE/docs_issue.yml new file mode 100644 index 00000000..e14c4876 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/docs_issue.yml @@ -0,0 +1,33 @@ +name: "Documentation Issue" +description: Issues related to documentation. +title: "docs: " +labels: [doc] +body: + - type: markdown + attributes: + value: | + _The more information you share, the faster we can help you._ + + Prior to opening the issue, please make sure that you: + + - Use English to communicate. + - Search the [open issues](https://github.com/APIParkLab/APIPark/issues) and [discussion forum](https://github.com/APIParkLab/APIPark/discussions) to avoid duplicating the issue. + + - type: textarea + id: current-state + attributes: + label: Current State + description: Describe the current state of the documentation. + placeholder: | + The documentation for the API in this page (url) is missing ... + validations: + required: true + - type: textarea + id: desired-state + attributes: + label: Desired State + description: Describe the desired state the documentation should be in. + placeholder: | + There should be line mentioning how the API behaves when ... + validations: + required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 00000000..d08cecf9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,23 @@ +name: "Feature Request" +description: Suggest an enhancement to APINTO. +title: "feat: As a user, I want to ..., so that ..." +body: + - type: markdown + attributes: + value: | + _The more information you share, the faster we can help you._ + + Prior to opening the issue, please make sure that you: + + - Use English to communicate. + - Search the [open issues](https://github.com/APIParkLab/APIPark/issues) and [discussion forum](https://github.com/APIParkLab/APIPark/discussions) to avoid duplicating the issue. + + - type: textarea + id: description + attributes: + label: Description + description: Describe the feature you would like to see. + placeholder: | + As a user, I want to ..., so that... + validations: + required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/request_help.yml b/.github/ISSUE_TEMPLATE/request_help.yml new file mode 100644 index 00000000..076cbb92 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/request_help.yml @@ -0,0 +1,31 @@ +name: "Request Help" +description: Stuck? Ask for help! +title: "help request: " +body: + - type: markdown + attributes: + value: | + _The more information you share, the faster we can help you._ + + Prior to opening the issue, please make sure that you: + + - Use English to communicate. + - Search the [open issues](https://github.com/APIParkLab/APIPark/issues) and [discussion forum](https://github.com/APIParkLab/APIPark/discussions) to avoid duplicating the issue. + + - type: textarea + id: description + attributes: + label: Description + description: Describe the issue you are facing and what you need help with. + validations: + required: true + - type: textarea + id: environment + attributes: + label: Environment + description: Share your environment details. Reports without proper environment details will likely be closed. + value: | + - APIPark version (run `apinto dashboard version`): + - Operating system (run `uname -a`): + validations: + required: true \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..9766a8d5 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,86 @@ +name: release +#触发机制,当创建tag时 +on: + release: + types: + - published +jobs: + frontend-builder: + name: frontend-builder + runs-on: ubuntu-latest + steps: + - name: SetOutput + id: vars + run: echo "tag=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT + - name: Checkout #Checkout代码 + uses: actions/checkout@v3 + - name: Set up Node + uses: actions/setup-node@v3.0.0 + with: + node-version: '18.12' + - name: Pnpm install and build + run: | + npm install -g pnpm + pnpm install --registry https://registry.npmmirror.com --dir ./frontend + echo "Build frontend..." + cd ./frontend && pnpm run build + - name: upload frontend release + uses: actions/upload-artifact@v2 + with: + name: frontend-package + path: frontend/dist + release: + needs: [frontend-builder] + name: release + runs-on: ubuntu-latest + steps: + - name: SetOutput #处理Tag字符串并存进outputs + id: vars + run: | + echo "tag=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT + - name: Checkout #Checkout代码 + uses: actions/checkout@v3 + - name: download frontend release + uses: actions/download-artifact@v2 + with: + name: frontend-package + path: frontend/dist + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '1.21.1' + - name: Go tidy + run: | + go mod tidy + echo "GOVERSION=$(go version)" >> $GITHUB_ENV + - name: Create archives on Release #创建各种系统架构下的二进制包并上传至release assets + uses: goreleaser/goreleaser-action@v3.1.0 + with: + version: 1.9.2 + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + docker-push: + needs: [frontend-builder] + name: docker-push + runs-on: ubuntu-latest + steps: + - name: SetOutput + id: vars + run: echo "tag=${GITHUB_REF#refs/*/v}" >> $GITHUB_OUTPUT + - uses: actions/checkout@v3 + + - name: download frontend release + uses: actions/download-artifact@v2 + with: + name: frontend-package + path: frontend/dist + - name: Login Docker #登录docker + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: build + run: cd scripts && ./docker_publish.sh ${{ secrets.DOCKER_USERNAME }} "backend" + diff --git a/go.mod b/go.mod index b3116d8e..bb62573b 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 //toolchain go1.21.1 require ( - github.com/eolinker/ap-account v1.0.6 + github.com/eolinker/ap-account v1.0.7 github.com/eolinker/eosc v0.17.3 github.com/eolinker/go-common v1.0.1 github.com/gabriel-vasile/mimetype v1.4.4 diff --git a/go.sum b/go.sum index db6fbe6c..1c8ba4e8 100644 --- a/go.sum +++ b/go.sum @@ -23,7 +23,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/eolinker/ap-account v1.0.6/go.mod h1:MViCOvUaS2QrVift1Be3yGjjMywzICL9317eOxoixSI= +github.com/eolinker/ap-account v1.0.7 h1:gmltZ0v/0SFY4LElhLWRDQfNpr3Q74A9/T8m+upYiVM= +github.com/eolinker/ap-account v1.0.7/go.mod h1:MViCOvUaS2QrVift1Be3yGjjMywzICL9317eOxoixSI= github.com/eolinker/eosc v0.17.3 h1:sr2yT+v/AsqEdciRaaZZj0zL9pTufR5RvDW6+65hraQ= github.com/eolinker/eosc v0.17.3/go.mod h1:xgq816hpanlMXFtZw7Ztdctb1eEk9UPHchY4NfFO6Cw= github.com/eolinker/go-common v1.0.1 h1:Uan6QmXAlPiX6hc1ptSIHWvaWXNA+VlBjC4gCaDEiz0= diff --git a/scripts/docker_build.sh b/scripts/docker_build.sh new file mode 100755 index 00000000..2a43ba84 --- /dev/null +++ b/scripts/docker_build.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +set -e + +cd "$(dirname "$0")/../" +LOCAL_PATH=$(pwd) +ARCH=$1 +User=$2 +BuildMode=$3 +if [[ "${BuildMode}" == "" ]];then + BuildMode="all" +fi +# 编译可执行文件 +./scripts/build.sh "cmd" "" "${BuildMode}" ${ARCH} + +source ./scripts/common.sh +APP="apipark" + + +mkdir -p scripts/cmd/ && cp cmd/${APP} scripts/cmd/ + +VERSION=$(gen_version) + + +if [[ "${ARCH}" == "" ]];then + ARCH="amd64" +fi + +OPTIONS="" +if [[ "${ARCH}" == "arm" ]];then + OPTIONS="--platform=linux/arm64" +fi + +if [[ "${User}" == "" ]];then + User="eolinker" +fi + +imageName=${User}/${APP}:${VERSION}-${ARCH} +docker rmi -f ${imageName} + +echo "docker build ${OPTIONS} -t ${imageName} --build-arg VERSION=${VERSION} --build-arg APP=${APP} -f ./scripts/Dockerfile ./scripts/" +docker build ${OPTIONS} -t ${imageName} --build-arg VERSION=${VERSION} --build-arg APP=${APP} -f ./scripts/Dockerfile ./scripts/ + + diff --git a/scripts/docker_publish.sh b/scripts/docker_publish.sh new file mode 100755 index 00000000..c899b178 --- /dev/null +++ b/scripts/docker_publish.sh @@ -0,0 +1,48 @@ +#!/bin/bash + + + +cd "$(dirname "$0")/../" +LOCAL_PATH=$(pwd) + +source ./scripts/common.sh + +User=$1 +App="apipark" +if [[ "${User}" == "" ]];then + User="eolinker" +fi +BuildMode=$2 +if [[ "${BuildMode}" == "" ]];then + BuildMode="all" +fi +Version=$(gen_version) +ImageName="${User}/${App}" +echo "docker manifest rm \"${ImageName}:${Version}\"" +docker manifest rm "${ImageName}:${Version}" + +set -e +./scripts/docker_build.sh amd64 ${User} "${BuildMode}" + +./scripts/docker_build.sh arm64 ${User} "${BuildMode}" + + + +echo "docker push \"${ImageName}:${Version}-amd64\"" +docker push "${ImageName}:${Version}-amd64" +echo "docker push \"${ImageName}:${Version}-arm64\"" +docker push "${ImageName}:${Version}-arm64" + +echo "Create manifest ${ImageName}:${Version}" +docker manifest create "${ImageName}:${Version}" "${ImageName}:${Version}-amd64" "${ImageName}:${Version}-arm64" + +echo "Annotate manifest ${ImageName}:${Version} ${ImageName}:${Version}-amd64 --os linux --arch amd64" +docker manifest annotate "${ImageName}:${Version}" "${ImageName}:${Version}-amd64" --os linux --arch amd64 + +echo "Annotate manifest ${ImageName}:${Version} ${ImageName}:${Version}-arm64 --os linux --arch arm64" +docker manifest annotate "${ImageName}:${Version}" "${ImageName}:${Version}-arm64" --os linux --arch arm64 + +echo "Push manifest ${ImageName}:${Version}" +docker manifest push "${ImageName}:${Version}" + +