From 73aaee04bb70a2a034fbf53ce46f927129302f9b Mon Sep 17 00:00:00 2001 From: Ruben Buniatyan Date: Tue, 30 Jan 2024 11:39:35 +0100 Subject: [PATCH] Revise release workflow (#6634) --- .github/workflows/publish-nuget.yml | 2 -- .github/workflows/publish-packages.yml | 14 ++------- scripts/deployment/build-cli.sh | 3 +- scripts/deployment/build-runner.sh | 3 +- scripts/deployment/publish-downloads.sh | 3 +- scripts/deployment/publish-github.sh | 40 ++++++++++++++----------- 6 files changed, 28 insertions(+), 37 deletions(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index bc8c6f32b58..bca4921d4b7 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -16,8 +16,6 @@ jobs: ref: ${{ github.event.release.tag_name }} - name: Set up .NET uses: actions/setup-dotnet@v4 - - name: Wait to ensure assets are uploaded - run: sleep 5m - name: Download Nethermind reference assemblies run: | json=$(curl -s ${{ github.event.release.assets_url }}) diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index 57b77171ceb..51ded1930f1 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -5,18 +5,10 @@ on: types: [published] jobs: - wait: - name: Wait for assets - runs-on: ubuntu-latest - if: ${{ !github.event.release.prerelease }} - steps: - - name: Wait to ensure assets are uploaded - run: sleep 5m - publish-ppa: name: Publish on PPA runs-on: ubuntu-latest - needs: wait + if: ${{ !github.event.release.prerelease }} steps: - name: Check out Nethermind repository uses: actions/checkout@v4 @@ -90,7 +82,7 @@ jobs: publish-winget: name: Publish on Windows Package Manager runs-on: windows-latest - needs: wait + if: ${{ !github.event.release.prerelease }} steps: - name: Submit package run: | @@ -102,7 +94,7 @@ jobs: publish-homebrew: name: Publish on Homebrew runs-on: ubuntu-latest - needs: wait + if: ${{ !github.event.release.prerelease }} env: FORMULA: nethermind.rb steps: diff --git a/scripts/deployment/build-cli.sh b/scripts/deployment/build-cli.sh index 136c43b365f..5dd7adaf317 100755 --- a/scripts/deployment/build-cli.sh +++ b/scripts/deployment/build-cli.sh @@ -10,8 +10,7 @@ cd $GITHUB_WORKSPACE/src/Nethermind/Nethermind.Cli echo "Building Nethermind CLI" -for rid in "linux-x64" "linux-arm64" "win-x64" "osx-x64" "osx-arm64" -do +for rid in "linux-x64" "linux-arm64" "win-x64" "osx-x64" "osx-arm64"; do echo " Publishing for $rid" dotnet publish -c release -r $rid -o $output_path/$rid --sc true \ diff --git a/scripts/deployment/build-runner.sh b/scripts/deployment/build-runner.sh index 558de445b7c..410d7af9bc9 100755 --- a/scripts/deployment/build-runner.sh +++ b/scripts/deployment/build-runner.sh @@ -11,8 +11,7 @@ cd $GITHUB_WORKSPACE/src/Nethermind/Nethermind.Runner echo "Building Nethermind" -for rid in "linux-x64" "linux-arm64" "win-x64" "osx-x64" "osx-arm64" -do +for rid in "linux-x64" "linux-arm64" "win-x64" "osx-x64" "osx-arm64"; do echo " Publishing for $rid" dotnet publish -c $build_config -r $rid -o $output_path/$rid --sc true \ diff --git a/scripts/deployment/publish-downloads.sh b/scripts/deployment/publish-downloads.sh index 8fc87909ffc..be0edd42184 100755 --- a/scripts/deployment/publish-downloads.sh +++ b/scripts/deployment/publish-downloads.sh @@ -10,8 +10,7 @@ echo "Publishing packages to Downloads page" cd $GITHUB_WORKSPACE/$PACKAGE_DIR -for rid in "linux-x64" "linux-arm64" "windows-x64" "macos-x64" "macos-arm64" -do +for rid in "linux-x64" "linux-arm64" "windows-x64" "macos-x64" "macos-arm64"; do file_name=$(basename *$rid*) echo "Signing $file_name" diff --git a/scripts/deployment/publish-github.sh b/scripts/deployment/publish-github.sh index 2c6eb72fa00..d1227404570 100755 --- a/scripts/deployment/publish-github.sh +++ b/scripts/deployment/publish-github.sh @@ -11,8 +11,9 @@ release_id=$(curl https://api.github.com/repos/$GITHUB_REPOSITORY/releases \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $GITHUB_TOKEN" | jq -r '.[] | select(.tag_name == "'$GIT_TAG'") | .id') -if [ "$release_id" == "" ] -then +should_publish=true + +if [ "$release_id" == "" ]; then echo "Drafting release $GIT_TAG" body=$(printf \ @@ -25,27 +26,13 @@ then -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ -d "$body" | jq -r '.id') -else - echo "Publishing release $GIT_TAG" - - make_latest=$([ $PRERELEASE = 'true' ] && echo "false" || echo "true") - - body=$(printf \ - '{"target_commitish": "%s", "name": "v%s", "draft": false, "make_latest": "%s", "prerelease": %s}' \ - $GITHUB_SHA $GIT_TAG $make_latest $PRERELEASE) - 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" + should_publish=false fi cd $GITHUB_WORKSPACE/$PACKAGE_DIR -for rid in "linux-x64" "linux-arm64" "windows-x64" "macos-x64" "macos-arm64" "ref-assemblies" -do +for rid in "linux-x64" "linux-arm64" "windows-x64" "macos-x64" "macos-arm64" "ref-assemblies"; do file_name=$(basename *$rid*) echo "Uploading $file_name" @@ -59,4 +46,21 @@ do --data-binary @"$file_name" done +if [ "$should_publish" == "true" ]; then + echo "Publishing release $GIT_TAG" + + make_latest=$([ $PRERELEASE = 'true' ] && echo "false" || echo "true") + + body=$(printf \ + '{"target_commitish": "%s", "name": "v%s", "draft": false, "make_latest": "%s", "prerelease": %s}' \ + $GITHUB_SHA $GIT_TAG $make_latest $PRERELEASE) + + 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 + echo "Publishing completed"