From 9e8b3da2173510a502c68686c505149a1ec33d56 Mon Sep 17 00:00:00 2001 From: Ruben Buniatyan Date: Thu, 5 Jan 2023 10:36:56 +0100 Subject: [PATCH] Fix release approval handling (#5097) --- .github/workflows/release-nethermind.yml | 10 +++++----- scripts/deployment/publish-downloads.sh | 4 ++-- scripts/deployment/publish-github.sh | 25 ++++++++++++++++++++---- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release-nethermind.yml b/.github/workflows/release-nethermind.yml index 29381ad091b..52919f972ae 100644 --- a/.github/workflows/release-nethermind.yml +++ b/.github/workflows/release-nethermind.yml @@ -101,7 +101,7 @@ jobs: update-homebrew: name: Update Homebrew formula runs-on: ubuntu-latest - needs: approval + needs: [approval, build] if: needs.build.outputs.PRERELEASE == 'false' steps: - name: Restore packages from cache @@ -145,7 +145,7 @@ jobs: publish-github: name: Publish to GitHub runs-on: ubuntu-latest - needs: approval + needs: [approval, build] steps: - name: Restore packages from cache uses: actions/cache@v3 @@ -166,7 +166,7 @@ jobs: publish-downloads: name: Publish to Downloads page runs-on: ubuntu-latest - needs: approval + needs: [approval, build] if: needs.build.outputs.PRERELEASE == 'false' steps: - name: Restore packages from cache @@ -191,7 +191,7 @@ jobs: publish-dockers: name: Publish to Docker Hub runs-on: ubuntu-latest - needs: approval + needs: [approval, build] env: DOCKER_IMAGE: nethermind/nethermind steps: @@ -225,7 +225,7 @@ jobs: publish-ppa: name: Publish to PPA runs-on: ubuntu-latest - needs: approval + needs: [approval, build] if: needs.build.outputs.PRERELEASE == 'false' env: PPA_GPG_KEYID: ${{ secrets.PPA_GPG_KEYID }} diff --git a/scripts/deployment/publish-downloads.sh b/scripts/deployment/publish-downloads.sh index b5c0876066a..c0f11ec38f8 100755 --- a/scripts/deployment/publish-downloads.sh +++ b/scripts/deployment/publish-downloads.sh @@ -22,10 +22,10 @@ do curl https://downloads.nethermind.io/files?apikey=$DOWNLOADS_PAGE \ -X POST \ + --fail-with-body \ -# \ -F "files=@$PWD/$FILE_NAME" \ - -F "files=@$PWD/$FILE_NAME.asc" \ - --fail + -F "files=@$PWD/$FILE_NAME.asc" done echo "Publishing completed" diff --git a/scripts/deployment/publish-github.sh b/scripts/deployment/publish-github.sh index 0ccc759f48c..0a03726fd85 100755 --- a/scripts/deployment/publish-github.sh +++ b/scripts/deployment/publish-github.sh @@ -14,11 +14,27 @@ BODY=$(printf \ echo "Drafting release $GIT_TAG" -RELEASE_ID=$(curl https://api.github.com/repos/$GITHUB_REPOSITORY/releases \ - -X POST \ +RELEASE_ID=$(curl https://api.github.com/repos/$GITHUB_REPOSITORY/releases/tags/$GIT_TAG \ + -X GET \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -d "$BODY" | jq -r '.id') + -H "Authorization: Bearer $GITHUB_TOKEN" | jq -r '.id') + +if [ "$RELEASE_ID" == "null" ] +then + RELEASE_ID=$(curl https://api.github.com/repos/$GITHUB_REPOSITORY/releases \ + -X POST \ + --fail-with-body \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -d "$BODY" | jq -r '.id') +else + curl https://api.github.com/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID \ + -X PATCH \ + --fail-with-body \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -d "$BODY" +fi cd $PACKAGE_PATH @@ -30,6 +46,7 @@ do curl https://uploads.github.com/repos/$GITHUB_REPOSITORY/releases/$RELEASE_ID/assets?name=$FILE_NAME \ -X POST \ + --fail-with-body \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ -H "Content-Type: application/octet-stream" \