diff --git a/.github/actions/upload-assets-action/README.md b/.github/actions/upload-assets-action/README.md index 15e125fad..62cc71def 100644 --- a/.github/actions/upload-assets-action/README.md +++ b/.github/actions/upload-assets-action/README.md @@ -8,7 +8,7 @@ Upload file to release assets **Required** tag name of release branch. Default `${{ github.ref }}`. -### `file-path` +### `asset-path` **Required** file path to be uploaded. Default `''`. @@ -17,6 +17,6 @@ Upload file to release assets ```yaml uses: ./.github/actions/upload-assets-action with: - file-path: ${{ steps.pkg.outputs.filepath }} + asset-path: build/cpack_output tag: ${{ steps.tag.outputs.tag }} ``` diff --git a/.github/actions/upload-assets-action/action.yml b/.github/actions/upload-assets-action/action.yml index 154450450..58f80e98b 100644 --- a/.github/actions/upload-assets-action/action.yml +++ b/.github/actions/upload-assets-action/action.yml @@ -5,7 +5,7 @@ inputs: description: 'git tag' required: true default: ${{ github.ref }} - file-path: + asset-path: description: 'file path to be uploaded' required: true default: '' @@ -15,13 +15,26 @@ runs: - run: | GH_RELEASE="https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ inputs.tag }}" upload_url=$(curl -s --request GET --url $GH_RELEASE | grep -oP '(?<="upload_url": ")[^"]*' | cut -d'{' -f1) - content_type=$(file -b --mime-type ${{ inputs.file-path }}) - filename=$(basename "${{ inputs.file-path }}") + j=0 + if [ -d ${{ inputs.asset-path }} ]; then + for filename in `ls ${{ inputs.asset-path }}`; + do + folder_list[j]=${{ inputs.asset-path }}/$filename + j=`expr $j + 1` + done + else + folder_list[0]=${{ inputs.asset-path }} + fi echo "Uploading asset... " - curl --silent \ - --request POST \ - --url "$upload_url?name=$filename" \ - --header "authorization: Bearer ${{ github.token }}" \ - --header "content-type: $content_type" \ - --data-binary @"${{ inputs.file-path }}" + for filepath in ${folder_list[@]}; + do + filename=$(basename "${filepath}") + content_type=$(file -b --mime-type ${filepath}) + curl --silent \ + --request POST \ + --url "$upload_url?name=$filename" \ + --header "authorization: Bearer ${{ github.token }}" \ + --header "content-type: $content_type" \ + --data-binary @"${filepath}" + done shell: bash diff --git a/.github/actions/upload-to-oss-action/README.md b/.github/actions/upload-to-oss-action/README.md new file mode 100644 index 000000000..9afc3082b --- /dev/null +++ b/.github/actions/upload-to-oss-action/README.md @@ -0,0 +1,42 @@ +# Upload file to oss + +Upload file to oss + +## Inputs + +### `key-id` + +**Required** access key ID of oss. Default `''`. + +### `key-secret` + +**Required** access key secret of oss. Default `''`. + +### `endpoint` + +**Required** endpoint of oss. Default `''`. + +### `bucket` + +**Required** bucket of oss. Default `''`. + +### `asset-path` + +**Required** file path to be uploaded. Default `''`. + +### `target-path` + +**Required** path where the oss object is stored. Default `''`. + +## Example usage + +```yaml +uses: ./.github/actions/upload-to-oss-action +with: + key-id: ${{ secrets.OSS_ID }} + key-secret: ${{ secrets.OSS_SECRET }} + endpoint: ${{ secrets.OSS_ENDPOINT }} + bucket: nebula-graph + asset-path: build/cpack_output + target-path: package/v2-nightly/${{ steps.vars.outputs.subdir }} +``` diff --git a/.github/actions/upload-to-oss-action/action.yml b/.github/actions/upload-to-oss-action/action.yml new file mode 100644 index 000000000..467acc2d5 --- /dev/null +++ b/.github/actions/upload-to-oss-action/action.yml @@ -0,0 +1,50 @@ +name: 'Upload to oss' +description: 'Upload files to oss' +inputs: + key-id: + description: 'access key ID' + required: true + default: '' + key-secret: + description: 'access key secret' + required: true + default: '' + endpoint: + description: 'endpooint' + required: true + default: '' + bucket: + description: 'bucket' + required: true + default: '' + asset-path: + description: 'file path to be uploaded' + required: true + default: '' + target-path: + description: 'file path stored on the OSS' + required: true + default: '' +runs: + using: "composite" + steps: + - run: | + j=0 + if [ -d ${{ inputs.asset-path }} ]; then + for filename in `ls ${{ inputs.asset-path }}`; + do + folder_list[j]=${{ inputs.asset-path }}/$filename + j=`expr $j + 1` + done + else + folder_list[0]=${{ inputs.asset-path }} + fi + echo "Uploading to oss... " + for filepath in ${folder_list[@]}; + do + ossutil64 -e ${{ inputs.endpoint}} \ + -i ${{ inputs.key-id }} \ + -k ${{ inputs.key-secret }} \ + -f cp $filepath oss://${{ inputs.bucket }}/${{ inputs.target-path }}/$(basename ${filepath}) + done + shell: bash diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index e8bddfd6d..4110c7211 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -18,7 +18,7 @@ jobs: - ubuntu1604 - ubuntu1804 - ubuntu2004 - # - centos6 + - centos6 - centos7 - centos8 container: @@ -35,19 +35,16 @@ jobs: filename=$(find build/cpack_output -type f \( -iname \*.deb -o -iname \*.rpm \)) sha256sum $filename > $filename.$SHA_EXT subdir=$(date -u +%Y.%m.%d) - echo "::set-output name=filepath::$filename" - echo "::set-output name=shafilepath::$filename.$SHA_EXT" echo "::set-output name=subdir::$subdir" - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v1 with: name: ${{ matrix.os }}-v2-nightly path: build/cpack_output - - name: upload package to oss - uses: tvrcgo/upload-to-oss@v0.3.0 + - uses: ./.github/actions/upload-to-oss-action with: key-id: ${{ secrets.OSS_ID }} key-secret: ${{ secrets.OSS_SECRET }} endpoint: ${{ secrets.OSS_ENDPOINT }} bucket: nebula-graph asset-path: build/cpack_output - target-path: /package/v2-nightly/${{ steps.vars.outputs.subdir }} + target-path: package/v2-nightly/${{ steps.vars.outputs.subdir }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b9331186..b64d65677 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,22 +40,19 @@ jobs: filename=$(find build/cpack_output -type f \( -iname \*.deb -o -iname \*.rpm \)) sha256sum $filename > $filename.$SHA_EXT subdir=$(echo $tag |sed 's/^v//') - echo "::set-output name=filepath::$filename" - echo "::set-output name=shafilepath::$filename.$SHA_EXT" echo "::set-output name=subdir::$subdir" - uses: ./.github/actions/upload-assets-action with: - file-path: ${{ steps.vars.outputs.filepath }} + asset-path: build/cpack_output tag: ${{ steps.tag.outputs.tag }} - - name: upload package to oss - uses: tvrcgo/upload-to-oss@v0.3.0 + - uses: ./.github/actions/upload-to-oss-action with: key-id: ${{ secrets.OSS_ID }} key-secret: ${{ secrets.OSS_SECRET }} endpoint: ${{ secrets.OSS_ENDPOINT }} bucket: nebula-graph asset-path: build/cpack_output - target-path: /package/${{ steps.vars.outputs.subdir }} + target-path: package/${{ steps.vars.outputs.subdir }} docker_build_graph: name: docker-graph