From 40e21fde1d7cb028dca9b0362272fe85d2c9dc88 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Fri, 3 Jul 2020 00:34:15 +0800 Subject: [PATCH] Added Signing Request --- .github/workflows/sign.yml | 37 +++++++++++++++++++++++++++++++++++ release/requestsign.sh | 28 ++++++++++++++++++++++++++ release/requestsign_github.sh | 5 +++++ 3 files changed, 70 insertions(+) create mode 100644 .github/workflows/sign.yml create mode 100755 release/requestsign.sh create mode 100755 release/requestsign_github.sh diff --git a/.github/workflows/sign.yml b/.github/workflows/sign.yml new file mode 100644 index 000000000..24c32d677 --- /dev/null +++ b/.github/workflows/sign.yml @@ -0,0 +1,37 @@ +# This is a basic workflow to help you get started with Actions + +name: Sign + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + release: + types: [released] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Invoke release signing + - name: make it run + run: chmod +x $GITHUB_WORKSPACE/release/requestsign_github.sh + + # Invoke release signing + - name: make it run + run: chmod +x $GITHUB_WORKSPACE/release/requestsign.sh + + # Invoke release signing + - name: Invoke release signing + env: + SIGN_SERVICE_PASSWORD: ${{ secrets.SIGN_SERVICE_PASSWORD }} + SIGN_SERIVCE_URL: ${{ secrets.SIGN_SERIVCE_URL }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: $GITHUB_WORKSPACE/release/requestsign_github.sh \ No newline at end of file diff --git a/release/requestsign.sh b/release/requestsign.sh new file mode 100755 index 000000000..feb65f26d --- /dev/null +++ b/release/requestsign.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +RELEASE_DATA=$(curl --data "version=${SIGN_VERSION}" --data "password=${SIGN_SERVICE_PASSWORD}" -X POST "${SIGN_SERIVCE_URL}" ) +echo $RELEASE_DATA +RELEASE_ID=$(echo $RELEASE_DATA| jq -r ".id") + +function uploadfile() { + FILE=$1 + CTYPE=$(file -b --mime-type $FILE) + + sleep 1 + curl -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: ${CTYPE}" --data-binary @$FILE "https://uploads.github.com/repos/v2fly/v2ray-core/releases/${RELEASE_ID}/assets?name=$(basename $FILE)" + sleep 1 +} + +function upload() { + FILE=$1 + DGST=$1.dgst + openssl dgst -md5 $FILE | sed 's/([^)]*)//g' >> $DGST + openssl dgst -sha1 $FILE | sed 's/([^)]*)//g' >> $DGST + openssl dgst -sha256 $FILE | sed 's/([^)]*)//g' >> $DGST + openssl dgst -sha512 $FILE | sed 's/([^)]*)//g' >> $DGST + uploadfile $FILE + uploadfile $DGST +} + +curl "https://raw.githubusercontent.com/v2fly/Release/master/v2fly/${SIGN_VERSION}.Release" > Release +upload Release \ No newline at end of file diff --git a/release/requestsign_github.sh b/release/requestsign_github.sh new file mode 100755 index 000000000..931dce37d --- /dev/null +++ b/release/requestsign_github.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +export SIGN_VERSION=$(cat $GITHUB_EVENT_PATH| jq -r ".release.tag_name") + +echo $SIGN_VERSION \ No newline at end of file