Skip to content

Commit

Permalink
增加发布脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
wangwei1237 committed May 21, 2021
1 parent e516ea9 commit 36e6e36
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Publish My GitBook
name: Build GitBook

on:
workflow_dispatch:
Expand All @@ -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}}
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions getuploadurl.sh
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 36e6e36

Please sign in to comment.