From d51356a0ec2517fd58b376b9679681cea4dbd13b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=8F=E7=99=BD?= <296015668@qq.com> Date: Mon, 29 Apr 2024 14:43:57 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=20actions=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 36 ++++++++++----------------------- .github/workflows/sync.yml | 38 +++++++++++++++++------------------ 2 files changed, 30 insertions(+), 44 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2d6f19d..9e90960 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,6 +60,12 @@ jobs: outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true cache-from: type=gha cache-to: type=gha,mode=max + + - name: Get pip_package.zip + run: | + rm -rf opt/player || echo "" + applets_version=$(curl -s https://api.github.com/repos/jumpserver/applets/releases/latest | grep "tag_name" | awk '{print $2}' | sed 's/"//g' | sed 's/,//g') + wget -qO opt/download/applets/pip_packages.zip https://github.com/jumpserver/applets/releases/download/${applets_version}/pip_packages.zip - name: Create Tag run: | @@ -73,40 +79,20 @@ jobs: - name: Create Release run: | gh release create ${{ steps.get-version.outputs.version }} --notes "Release ${{ steps.get-version.outputs.version }}" || echo "Release already exists" + gh release upload ${{ steps.get-version.outputs.version }} opt/download/applets/* --clobber + gh release upload ${{ steps.get-version.outputs.version }} opt/download/public/* --clobber env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Setup Private Key - uses: webfactory/ssh-agent@v0.9.0 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - - name: Get pip_package.zip - run: | - applets_version=$(curl -s https://api.github.com/repos/jumpserver/applets/releases/latest | grep "tag_name" | awk '{print $2}' | sed 's/"//g' | sed 's/,//g') - wget -qO opt/download/applets/pip_packages.zip https://github.com/jumpserver/applets/releases/download/${applets_version}/pip_packages.zip - - - name: Sync to Repository - run: | - ssh -o StrictHostKeyChecking=no git@github.com || echo "" - rm -rf .git opt/player || echo "" - git clone --depth=1 git@github.com:jumpserver-dev/web-static.git - \cp -rf opt/* web-static/ - cd web-static - git add . - git commit -m "Release Version ${{ steps.get-version.outputs.version }}" - git tag -a ${{ steps.get-version.outputs.version }} -m "Release Version ${{ steps.get-version.outputs.version }}" - git push origin ${{ steps.get-version.outputs.version }} || echo "Tag already exists" - - name: Setup OSSUTIL uses: yizhoumo/setup-ossutil@v2 with: endpoint: ${{ secrets.OSS_ENDPOINT }} access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }} access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }} - ossutil-version: '1.7.14' + ossutil-version: 'latest' - name: Upload Assets to OSS run: | - ossutil mkdir oss://jms-pkg/jumpserver/web-static/raw/tag/${{ steps.get-version.outputs.version }}/ || echo "Path already exists" - ossutil cp -r opt/ oss://jms-pkg/jumpserver/web-static/raw/tag/${{ steps.get-version.outputs.version }}/ --update \ No newline at end of file + ossutil mkdir oss://jms-pkg/jumpserver/web-static/releases/download/${{ steps.get-version.outputs.version }}/ || echo "Path already exists" + ossutil cp -r opt/ oss://jms-pkg/jumpserver/web-static/releases/download/${{ steps.get-version.outputs.version }}/ --update \ No newline at end of file diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index e53b644..f217e7d 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -29,32 +29,32 @@ jobs: git config --global user.name "${GITHUB_ACTOR}" git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" - - name: Setup Private Key - uses: webfactory/ssh-agent@v0.9.0 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - - name: Sync to Repository + - name: Create Tag run: | - ssh -o StrictHostKeyChecking=no git@github.com || echo "" - rm -rf .git opt/player || echo "" - git clone --depth=1 git@github.com:jumpserver-dev/web-static.git - mv opt/* web-static/ - cd web-static - git add . - git commit -m "Release Version ${{ github.event.inputs.version }}" - git tag -a ${{ github.event.inputs.version }} -m "Release Version ${{ github.event.inputs.version }}" - git push origin ${{ github.event.inputs.version }} --force - + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git tag -a ${{ steps.get-version.outputs.version }} -m "Release Version ${{ steps.get-version.outputs.version }}" || echo "Tag already exists" + git push origin ${{ steps.get-version.outputs.version }} || echo "Tag already exists" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create Release + run: | + gh release create ${{ steps.get-version.outputs.version }} --notes "Release ${{ steps.get-version.outputs.version }}" || echo "Release already exists" + gh release upload ${{ steps.get-version.outputs.version }} opt/download/applets/* --clobber + gh release upload ${{ steps.get-version.outputs.version }} opt/download/public/* --clobber + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Setup OSSUTIL uses: yizhoumo/setup-ossutil@v2 with: endpoint: ${{ secrets.OSS_ENDPOINT }} access-key-id: ${{ secrets.OSS_ACCESS_KEY_ID }} access-key-secret: ${{ secrets.OSS_ACCESS_KEY_SECRET }} - ossutil-version: '1.7.14' + ossutil-version: 'latest' - name: Upload Assets to OSS run: | - ossutil mkdir oss://jms-pkg/jumpserver/web-static/raw/tag/${{ steps.get-version.outputs.version }}/ || echo "Path already exists" - ossutil cp -r opt/ oss://jms-pkg/jumpserver/web-static/raw/tag/${{ steps.get-version.outputs.version }}/ --update \ No newline at end of file + ossutil mkdir oss://jms-pkg/jumpserver/web-static/releases/download/${{ steps.get-version.outputs.version }}/ || echo "Path already exists" + ossutil cp -r opt/ oss://jms-pkg/jumpserver/web-static/releases/download/${{ steps.get-version.outputs.version }}/ --update \ No newline at end of file