From 84d465cec95150ba5ae96be2bb6bf6458ff6aded Mon Sep 17 00:00:00 2001 From: Skylar Simoncelli Date: Thu, 19 Sep 2024 17:53:53 +0300 Subject: [PATCH] fix: releases --- .../workflows/modules/release-pc-artifact.yml | 126 ------------------ .../build-and-upload-draft-release.yml} | 0 2 files changed, 126 deletions(-) delete mode 100644 .github/workflows/modules/release-pc-artifact.yml rename .github/workflows/modules/{create-draft-release.yml => release/manual/build-and-upload-draft-release.yml} (100%) diff --git a/.github/workflows/modules/release-pc-artifact.yml b/.github/workflows/modules/release-pc-artifact.yml deleted file mode 100644 index 3dea972db..000000000 --- a/.github/workflows/modules/release-pc-artifact.yml +++ /dev/null @@ -1,126 +0,0 @@ -name: Create Draft PC Release - -on: - workflow_call: - inputs: - partner_chains_sha: - description: "partner-chains commit SHA or branch to build from" - partner-chains-tag: - description: "partner-chains release tag to append to artifact name" - required: true - create_draft_release_page: - description: "Create a draft release page" - required: false - default: "false" - workflow_dispatch: - inputs: - partner_chains_sha: - description: "partner-chains commit SHA or branch to build from" - partner-chains-tag: - description: "partner-chains release tag to append to artifact name" - required: true - create_draft_release_page: - description: "Create a draft release page" - required: false - default: "false" - -jobs: - release: - runs-on: ubuntu-latest - needs: [partner-chains-linux, partner-chains-macos-x86_64, partner-chains-macos-arm64] - if: ${{ github.event.inputs.create_draft_release_page == 'true' }} - steps: - - name: Set filename variables - id: set-filenames - run: | - echo "PARTNER_CHAINS_CLI_X86_64_LINUX=partner-chains-cli-${{ github.event.inputs.partner-chains-tag }}-x86_64-linux" >> $GITHUB_ENV - echo "PARTNER_CHAINS_NODE_X86_64_LINUX=partner-chains-node-${{ github.event.inputs.partner-chains-tag }}-x86_64-linux" >> $GITHUB_ENV - echo "PARTNER_CHAINS_CLI_X86_64_APPLE_DARWIN=partner-chains-cli-${{ github.event.inputs.partner-chains-tag }}-x86_64-apple-darwin" >> $GITHUB_ENV - echo "PARTNER_CHAINS_NODE_X86_64_APPLE_DARWIN=partner-chains-node-${{ github.event.inputs.partner-chains-tag }}-x86_64-apple-darwin" >> $GITHUB_ENV - echo "PARTNER_CHAINS_CLI_AARCH64_APPLE_DARWIN=partner-chains-cli-${{ github.event.inputs.partner-chains-tag }}-aarch64-apple-darwin" >> $GITHUB_ENV - echo "PARTNER_CHAINS_NODE_AARCH64_APPLE_DARWIN=partner-chains-node-${{ github.event.inputs.partner-chains-tag }}-aarch64-apple-darwin" >> $GITHUB_ENV - - - name: Download Linux CLI artifact - uses: actions/download-artifact@v4 - with: - name: partner-chains-cli-x86_64-linux-artifact-artifact - path: artifact-linux/ - - - name: Download Linux NODE artifact - uses: actions/download-artifact@v4 - with: - name: partner-chains-node-x86_64-linux-artifact-artifact - path: artifact-linux/ - - - name: Download macOS x86_64 CLI artifact - uses: actions/download-artifact@v4 - with: - name: partner-chains-cli-x86_64-apple-darwin-artifact - path: artifact-macos-x86_64/ - - - name: Download macOS x86_64 NODE artifact - uses: actions/download-artifact@v4 - with: - name: partner-chains-node-x86_64-apple-darwin-artifact - path: artifact-macos-x86_64/ - - - name: Download macOS ARM64 CLI artifact - uses: actions/download-artifact@v4 - with: - name: partner-chains-cli-aarch64-apple-darwin-artifact - path: artifact-macos-arm64/ - - - name: Download macOS ARM64 NODE artifact - uses: actions/download-artifact@v4 - with: - name: partner-chains-node-aarch64-apple-darwin-artifact - path: artifact-macos-arm64/ - - - name: Check if release already exists - id: check_release - run: | - tag="${{ github.event.inputs.partner-chains-tag }}" - release_response=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - "https://api.github.com/repos/${{ github.repository }}/releases/tags/$tag") - if echo "$release_response" | grep -q '"message": "Not Found"'; then - echo "release_exists=false" >> $GITHUB_ENV - echo "::set-output name=release_exists::false" - else - echo "release_exists=true" >> $GITHUB_ENV - echo "::set-output name=release_exists::true" - echo "release_id=$(echo $release_response | jq -r .id)" >> $GITHUB_ENV - echo "::set-output name=release_id::$(echo $release_response | jq -r .id)" - fi - - - name: Create draft release - id: create_release - if: ${{ steps.check_release.outputs.release_exists == 'false' }} - run: | - tag="${{ github.event.inputs.partner-chains-tag }}" - release_response=$(curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -d '{"tag_name": "'$tag'", "name": "'$tag'", "body": "Draft release for '$tag'", "draft": true}' \ - "https://api.github.com/repos/${{ github.repository }}/releases") - echo "release_id=$(echo $release_response | jq -r .id)" >> $GITHUB_ENV - echo "::set-output name=release_id::$(echo $release_response | jq -r .id)" - - - name: Upload artifacts to release - if: ${{ steps.check_release.outputs.release_exists == 'true' || steps.create_release.outputs.release_id != '' }} - run: | - release_id="${{ steps.create_release.outputs.release_id }}" - if [ -z "$release_id" ]; then - release_id="${{ steps.check_release.outputs.release_id }}" - fi - - for artifact in "artifact-linux/${{ env.PARTNER_CHAINS_CLI_X86_64_LINUX }}" \ - "artifact-linux/${{ env.PARTNER_CHAINS_NODE_X86_64_LINUX }}" \ - "artifact-macos-x86_64/${{ env.PARTNER_CHAINS_CLI_X86_64_APPLE_DARWIN }}" \ - "artifact-macos-x86_64/${{ env.PARTNER_CHAINS_NODE_X86_64_APPLE_DARWIN }}" \ - "artifact-macos-arm64/${{ env.PARTNER_CHAINS_CLI_AARCH64_APPLE_DARWIN }}" \ - "artifact-macos-arm64/${{ env.PARTNER_CHAINS_NODE_AARCH64_APPLE_DARWIN }}"; do - chmod +x "$artifact" - curl -s -X POST \ - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -H "Content-Type: application/octet-stream" \ - --data-binary @"$artifact" \ - "https://uploads.github.com/repos/${{ github.repository }}/releases/$release_id/assets?name=$(basename $artifact)" - done diff --git a/.github/workflows/modules/create-draft-release.yml b/.github/workflows/modules/release/manual/build-and-upload-draft-release.yml similarity index 100% rename from .github/workflows/modules/create-draft-release.yml rename to .github/workflows/modules/release/manual/build-and-upload-draft-release.yml