From 6b797aa769d5c3ea60890b8ea8c8ec0c3f1c19d0 Mon Sep 17 00:00:00 2001 From: Xabi Losada Date: Mon, 17 Jun 2024 19:19:36 +0200 Subject: [PATCH] fix: create release only if it doesn't exist --- .github/workflows/calimero_node_linux.yml | 26 +++++------------------ .github/workflows/calimero_node_macos.yml | 24 +++++---------------- 2 files changed, 10 insertions(+), 40 deletions(-) diff --git a/.github/workflows/calimero_node_linux.yml b/.github/workflows/calimero_node_linux.yml index 9e1f43926..6fd10d78a 100644 --- a/.github/workflows/calimero_node_linux.yml +++ b/.github/workflows/calimero_node_linux.yml @@ -131,33 +131,17 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Restore build artifact - uses: actions/cache@v4 - with: - path: calimero-node_${{ matrix.target }}.tar.gz - key: build-artifact-${{ matrix.target }}-${{ github.sha }} - restore-keys: | - build-artifact-${{ matrix.target }} - - name: Check if release exists id: check_release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - VERSION=${{ needs.build.outputs.version }} - echo "version=$VERSION" - RELEASE_URL=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/tags/v$VERSION" \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.v3+json" | jq -r '.url') - echo "RELEASE_URL=$RELEASE_URL" - if [[ "$RELEASE_URL" != "null" ]]; then - echo "exists=true" >> $GITHUB_OUTPUT + if gh release view "v${{ github.event.inputs.version }}" >/dev/null 2>&1; then + echo "release_exists=true" >> $GITHUB_ENV else - echo "exists=false" >> $GITHUB_OUTPUT + echo "release_exists=false" >> $GITHUB_ENV fi - - name: Create Release - if: steps.check_release.outputs.exists == 'false' + - name: Create release if it does not exist + if: env.release_exists == 'false' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | diff --git a/.github/workflows/calimero_node_macos.yml b/.github/workflows/calimero_node_macos.yml index 27e6ce146..cb83102fc 100644 --- a/.github/workflows/calimero_node_macos.yml +++ b/.github/workflows/calimero_node_macos.yml @@ -94,33 +94,19 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Restore build artifact - uses: actions/cache@v4 - with: - path: calimero-node_${{ matrix.target }}.tar.gz - key: build-artifact-${{ matrix.target }}-${{ github.sha }} - restore-keys: | - build-artifact-${{ matrix.target }} - - name: Check if release exists id: check_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - VERSION=${{ needs.build.outputs.version }} - echo "version=$VERSION" - RELEASE_URL=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/tags/v$VERSION" \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github.v3+json" | jq -r '.url') - echo "RELEASE_URL=$RELEASE_URL" - if [[ "$RELEASE_URL" != "null" ]]; then - echo "exists=true" >> $GITHUB_OUTPUT + if gh release view "v${{ github.event.inputs.version }}" >/dev/null 2>&1; then + echo "release_exists=true" >> $GITHUB_ENV else - echo "exists=false" >> $GITHUB_OUTPUT + echo "release_exists=false" >> $GITHUB_ENV fi - - name: Create Release - if: steps.check_release.outputs.exists == 'false' + - name: Create release if it does not exist + if: env.release_exists == 'false' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: |