From 36e6e36e59e0db759585353e339b155fe6d820b1 Mon Sep 17 00:00:00 2001 From: Wang Wei Date: Fri, 21 May 2021 14:51:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=91=E5=B8=83=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/check.yml | 6 ++-- .github/workflows/release.yml | 58 +++++++++++++++++++++++++++++++++++ getuploadurl.sh | 23 ++++++++++++++ 3 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 getuploadurl.sh diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e0482ef..1b4a2cb 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -1,4 +1,4 @@ -name: Build and Publish My GitBook +name: Build GitBook on: workflow_dispatch: @@ -7,8 +7,8 @@ on: - master jobs: - build-and-deploy: - name: Build and deploy + build: + name: Build runs-on: ubuntu-latest env: MY_SECRET : ${{secrets.GH_ACCESS_TOKEN}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..97ec9eb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Build & Release GitBook +on: + workflow_dispatch: + inputs: + version: + description: 'The release version of the gitbook, such as v1.1.1' + required: true + default: 'v1.1.0' + +env: + DEBIAN_FRONTEND: noninteractive + +jobs: + get-upload-url: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: sudo sh ./getuploadurl.sh ${{ github.event.inputs.version }} ${{ secrets.GITHUB_TOKEN }} + id: upload-url + outputs: + upload-url: ${{ steps.upload-url.outputs.upload-url }} + + build: + needs: get-upload-url + name: Build & Release + runs-on: ubuntu-latest + steps: + - name: Setup Node.js 10.x + uses: actions/setup-node@v2 + with: + node-version: "10.22.0" + - name: Setup gitbook + run: | + npm install -g npm + npm install -g gitbook-cli + - name: Checkout main source + uses: actions/checkout@v2 + - name: Build the book + working-directory: ${{ github.workspace }} + run: | + mkdir node_modules && cd node_modules && npm install gitbook-plugin-sitemap-general && cd .. + gitbook install + cp -r misc/gitbook-plugin-hints/* node_modules/gitbook-plugin-hints/ + cp misc/tbfed-pagefooter_index.js node_modules/gitbook-plugin-tbfed-pagefooter/index.js + gitbook build + - name: package the book + working-directory: ${{ github.workspace }} + run: | + mv _book monolith-to-microservices && tar czvf "${{ github.event.inputs.version }}.tar.gz" monolith-to-microservices/* + ls . + - uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.get-upload-url.outputs.upload-url }} + asset_path: ${{ github.event.inputs.version }}.tar.gz + asset_name: ${{ github.event.inputs.version }}.tar.gz + asset_content_type: application/octet-stream diff --git a/getuploadurl.sh b/getuploadurl.sh new file mode 100644 index 0000000..aa9cc59 --- /dev/null +++ b/getuploadurl.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ $# -ne 2 ] +then + echo "::error the parameters error, please check!!!" + exit 1 +fi + +URL_PREFIX="https://api.github.com/repos/wangwei1237/monolith-to-microservices/releases" + +version=$1 +token=$2 + +get_release_url="${URL_PREFIX}/tags/${version}" +upload_url=$(curl -H "Accept: application/vnd.github.v3+json" "${get_release_url}" | grep 'upload_url' | cut -d'"' -f4) + +create_release_url="${URL_PREFIX}" +if [ "$upload_url" = "" ] +then + upload_url=$(curl -X POST -H "Accept: application/vnd.github.v3+json" "${create_release_url}?access_token=${token}" -d "{\"tag_name\":\"${tag}\", \"name\":\"libvmaf Build for ${version}\"}" | grep 'upload_url' | cut -d'"' -f4) +fi + +echo "::set-output name=upload-url::$upload_url" \ No newline at end of file