From e23b2be87b082d4bbe553b657a99d846b6c0966d Mon Sep 17 00:00:00 2001 From: aboyko Date: Tue, 16 Jul 2024 13:28:54 -0400 Subject: [PATCH] [GHA] GCP Backup upload working --- .github/scripts/copy-from-s3-to-gcp.sh | 14 -------- .../backup-eclipse-releases-to-gcp.yml | 33 +++++++++---------- .github/workflows/publish-eclipse-release.yml | 6 ++++ .../workflows/publish-vscode-extension.yml | 23 ++++++++----- 4 files changed, 35 insertions(+), 41 deletions(-) delete mode 100755 .github/scripts/copy-from-s3-to-gcp.sh diff --git a/.github/scripts/copy-from-s3-to-gcp.sh b/.github/scripts/copy-from-s3-to-gcp.sh deleted file mode 100755 index f6b52390e..000000000 --- a/.github/scripts/copy-from-s3-to-gcp.sh +++ /dev/null @@ -1,14 +0,0 @@ -s3_url=$1 -gcp_url=$2 - -# Process s3_url remove trailing / and get the last segment without the trailing / -file_name=${s3_url%/} -file_name=${file_name##*/} - -# Download from S3 then upload to GCP -aws s3 cp $s3_url . --recursive --no-progress -echo "-------" -ls -echo "-------" -gcp storage cp $gcp_url ./$file_name --recursive -rm -rf $file_name \ No newline at end of file diff --git a/.github/workflows/backup-eclipse-releases-to-gcp.yml b/.github/workflows/backup-eclipse-releases-to-gcp.yml index 9fcddb1d3..22dfc5569 100644 --- a/.github/workflows/backup-eclipse-releases-to-gcp.yml +++ b/.github/workflows/backup-eclipse-releases-to-gcp.yml @@ -8,7 +8,7 @@ on: required: true type: string release_version: - description: Release version (i.e. 4.20.1) + description: Release version (i.e. 4.20.1.RELEASE) required: true type: string @@ -19,6 +19,7 @@ env: AWS_ENDPOINT_URL_S3: ${{ secrets.CDN_S3_ENDPOINT }} AWS_S3_BUCKET: ${{ secrets.CDN_BUCKET }} DOWNLOAD_URL_ROOT: https://cdn.spring.io/spring-tools + GCP_BUCKET: gs://cdn-spring-io jobs: backup-eclipse-releases-to-gcp: @@ -27,23 +28,19 @@ jobs: steps: - name: Authenticate to GCP run: | - echo -e "${{ secrets.CDN_SPRING_IO_BACKUP_GCP_BUCKET_JSON }} " > ~/gcp.json - gcloud auth activate-service-account --key-file=~/gcp.json - - uses: actions/checkout@v4 - with: - sparse-checkout: | - .github/scripts - - name: Download from S3, Upload to GCP + echo '${{ secrets.CDN_SPRING_IO_BACKUP_GCP_BUCKET_JSON }}' > ./gcp.json + gcloud auth activate-service-account --key-file=./gcp.json + rm -f gcp.json + - name: Copy from S3 to GCP run: | + echo "Copying Eclipse LS extensions ${{ inputs.ls_version }} to GCP..." url_path=spring-tools/release/TOOLS/sts4-language-server-integrations/${{ inputs.ls_version }} - - echo "Copying Eclipse LS extensions ${{ inputs.ls_version }} to GCP..." - ${{ github.workspace }}/.github/scripts/copy-from-s3-to-gcp.sh s3://$AWS_S3_BUCKET/$url_path gs://gcp-test-spring-io/$url_path + gcloud storage cp s3://$AWS_S3_BUCKET/$url_path $GCP_BUCKET/$url_path --recursive - echo "Copying Eclipse Distro P2 repos ${{ inputs.ls_version }} to GCP..." - url_path=spring-tools/release/TOOLS/sts4/update/${{ inputs.release_version }}.RELEASE - ${{ github.workspace }}/.github/scripts/copy-from-s3-to-gcp.sh s3://$AWS_S3_BUCKET/$url_path gs://gcp-test-spring-io/$url_path - - echo "Copying Eclipse Distros ${{ inputs.release_version }} to GCP..." - url_path=spring-tools/release/STS4/${{ inputs.release_version }}.RELEASE/dist - ${{ github.workspace }}/.github/scripts/copy-from-s3-to-gcp.sh s3://$AWS_S3_BUCKET/$url_path gs://gcp-test-spring-io/$url_path + echo "Copying Eclipse Distro P2 repos ${{ inputs.release_version }} to GCP..." + url_path=spring-tools/release/TOOLS/sts4/update/${{ inputs.release_version }} + gcloud storage cp s3://$AWS_S3_BUCKET/$url_path $GCP_BUCKET/$url_path --recursive + + echo "Copying Eclipse Distros ${{ inputs.release_version }} to GCP..." + url_path=spring-tools/release/STS4/${{ inputs.release_version }}/dist + gcloud storage cp s3://$AWS_S3_BUCKET/$url_path $GCP_BUCKET/$url_path --recursive diff --git a/.github/workflows/publish-eclipse-release.yml b/.github/workflows/publish-eclipse-release.yml index e4cfe92ee..386f83687 100644 --- a/.github/workflows/publish-eclipse-release.yml +++ b/.github/workflows/publish-eclipse-release.yml @@ -38,6 +38,12 @@ jobs: latest: ${{ inputs.eclipse_latest }} secrets: inherit + backup-release-on-gcp: + uses: ./.github/workflows/backup-eclipse-releases-to-gcp.yml + with: + ls_version: ${{ inputs.ls_version }} + release_version: ${{ inputs.release_version }}.RELEASE + # create-github-release: # uses: ./.github/workflows/create-gh-release.yml # with: diff --git a/.github/workflows/publish-vscode-extension.yml b/.github/workflows/publish-vscode-extension.yml index 90fb70e75..f4311da18 100644 --- a/.github/workflows/publish-vscode-extension.yml +++ b/.github/workflows/publish-vscode-extension.yml @@ -17,10 +17,12 @@ on: type: string env: - DOWNLOAD_URL_ROOT: https://cdn.spring.io/spring-tools + DOWNLOAD_URL_ROOT: https://cdn.spring.io + VSIX_FILE: ${{ inputs.extension-name }}-${{ inputs.version }}-${{ inputs.postfix }}.vsix + URL_PATH: spring-tools/release/vscode-extensions/${{ inputs.extension-name }}/${{ inputs.version }} + GCP_BUCKET: gs://cdn-spring-io jobs: - publish-release: runs-on: ubuntu-latest name: Publish '${{ inputs.extension-name }}-${{ inputs.version }}-${{ inputs.postfix }}.vsix' @@ -28,20 +30,23 @@ jobs: - name: Download Release VSIX id: download-release run: | - vsix_file=${{ inputs.extension-name }}-${{ inputs.version }}-${{ inputs.postfix }}.vsix - wget $DOWNLOAD_URL_ROOT/release/vscode-extensions/${{ inputs.extension-name }}/${{ inputs.version }}/$vsix_file + wget $DOWNLOAD_URL_ROOT/$URL_PATH/$VSIX_FILE - name: Publish to VSCode Marketplace id: publish-vsce run: | npm install --global @vscode/vsce - vsix_file=${{ inputs.extension-name }}-${{ inputs.version }}-${{ inputs.postfix }}.vsix - vsce publish -p ${{ secrets.VSCE_PUBLISH_TOKEN }} --packagePath $vsix_file + vsce publish -p ${{ secrets.VSCE_PUBLISH_TOKEN }} --packagePath $VSIX_FILE - name: Publish to Eclipse Open VSX id: publish-ovsx run: | npm install --global ovsx - vsix_file=${{ inputs.extension-name }}-${{ inputs.version }}-${{ inputs.postfix }}.vsix - ovsx publish -p ${{ secrets.OVSX_PUBLISH_TOKEN }} $vsix_file + ovsx publish -p ${{ secrets.OVSX_PUBLISH_TOKEN }} $VSIX_FILE + - name: Upload to GCP + run: | + echo '${{ secrets.CDN_SPRING_IO_BACKUP_GCP_BUCKET_JSON }}' > ./gcp.json + gcloud auth activate-service-account --key-file=./gcp.json + rm -f gcp.json + gcloud storage cp $VSIX_FILE $GCP_BUCKET/$URL_PATH/$VSIX_FILE - id: tools-team-slack uses: slackapi/slack-github-action@v1.26 env: @@ -50,7 +55,7 @@ jobs: channel-id: "C0188MENU2J" payload: | { - "text": "Published release `${{ inputs.extension-name }}-${{ inputs.version }}-${{ inputs.postfix }}.vsix`", + "text": "Published release `$VSIX_FILE`", "blocks": [ { "type": "section",