From 198bb33782895a7423eea5c93988268597e7523f Mon Sep 17 00:00:00 2001 From: Sankalp Sanand Date: Tue, 30 Jan 2024 06:40:46 -0500 Subject: [PATCH] fixed release.yml --- ...elease.yml => man_2_create_prerelease.yml} | 10 +- .github/workflows/release.yml | 267 +++++------------- .../upload_to_codecov_with_retry.yml | 96 ------- 3 files changed, 65 insertions(+), 308 deletions(-) rename .github/workflows/{man_2_create_release.yml => man_2_create_prerelease.yml} (86%) delete mode 100644 .github/workflows/upload_to_codecov_with_retry.yml diff --git a/.github/workflows/man_2_create_release.yml b/.github/workflows/man_2_create_prerelease.yml similarity index 86% rename from .github/workflows/man_2_create_release.yml rename to .github/workflows/man_2_create_prerelease.yml index 50bf0b5cc..e982b8b37 100644 --- a/.github/workflows/man_2_create_release.yml +++ b/.github/workflows/man_2_create_prerelease.yml @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -name: man_2_create_release +name: man_2_create_prerelease on: workflow_dispatch: @@ -25,11 +25,6 @@ on: default: true description: "WARNING: Make sure the `man_1_push_to_master` workflow has passed successfully before running this workflow. Uncheck this box if it has." - branch_name: - type: string - required: true - default: "master" - description: "The name of the branch to create a release from, defaults to master." permissions: id-token: write @@ -43,7 +38,6 @@ jobs: !github.event.inputs.push_to_master_failed with: prerelease: true - prerelease_name: github.event.inputs.branch_name secrets: inherit # pragma: allowlist secret notify_slack: @@ -55,7 +49,7 @@ jobs: - name: Checkout master uses: actions/checkout@v4 with: - ref: "master" + ref: ${{ github.event.inputs.branch_name }} - name: Format Slack message run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0c4b1659d..a928b35d5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,36 +20,20 @@ on: workflow_dispatch: inputs: stable_version: - description: "Stable version number, e.g. 0.32.3" + description: "Stable version number, e.g. 0.32.3. Mandatory if a stable release is being created." type: string test_release: description: "Test the workflow but don't create the release. Uncheck this box to create a release." required: true type: boolean default: true - prerelease: - description: "true: Create a prerelease. false: Create a stable release" - required: true - type: boolean - default: true - prerelease_version: - description: "The prerelease version to release" - required: false - type: string - default: "develop" - workflow_call: inputs: prerelease: - description: "true: Create a prerelease. false: Create a stable release" + description: "true: Create a prerelease. false: Create a stable release." required: true type: boolean default: true - prerelease_version: - description: "The prerelease version to release" - required: false - type: string - default: "master" permissions: id-token: write @@ -61,16 +45,10 @@ env: '"AlejandroEsquivel",' '"FyzHsn",' '"wjcunningham7",' + '"kessler-frost",' '"santoshkumarradha"]' - EXECUTOR_BASE_DOCKERFILE_URL: "https://raw.githubusercontent.com/AgnostiqHQ/covalent-aws-plugins/develop/Dockerfile?token=${{ secrets.COVALENT_OPS_BOT_TOKEN }}" - AWS_PLUGINS_VERSION_URL: "https://raw.githubusercontent.com/AgnostiqHQ/covalent-aws-plugins/develop/VERSION?token=${{ secrets.COVALENT_OPS_BOT_TOKEN }}" jobs: - # version_assigner: - # name: Assign Version - # uses: AgnostiqHQ/covalent/.github/workflows/changelog.yml@develop - # secrets: inherit # pragma: allowlist secret - github: runs-on: ubuntu-latest outputs: @@ -83,33 +61,14 @@ jobs: persist-credentials: false fetch-depth: 0 ref: "v${{ github.event.inputs.stable_version }}" - - name: Format prerelease ref - if: inputs.prerelease - run: | - # re='^[0-9]+$' - # IFS='.' read -ra version <<< "${{ github.event.inputs.prerelease_version }}" - # if [[ ${version[0]} =~ $re ]] ; then - # echo "PRERELEASE=v$version" >> $GITHUB_ENV - # else - # echo "PRERELEASE=$version" >> $GITHUB_ENV - # fi - echo "PRERELEASE=${{ github.event.inputs.prerelease_version }}" >> $GITHUB_ENV - - name: Check out prerelease tag + + - name: Check out master branch for prerelease uses: actions/checkout@v4 if: inputs.prerelease with: persist-credentials: false fetch-depth: 0 - ref: "updating-nightly-workflow" - - name: Generate stable release message - if: > - github.event.inputs.stable_version - && contains(env.PAUL_BLART, github.actor) - id: stable-changelog - uses: AgnostiqHQ/covalent/.github/actions/stable-changelog@develop - with: - changelog-path: CHANGELOG.md - version-path: VERSION + ref: "master" - name: Read version run: | @@ -121,6 +80,27 @@ jobs: VERSION="$(cat ./VERSION)" echo "VERSION=$VERSION" >> $GITHUB_ENV echo "RELEASE=v$VERSION" >> $GITHUB_ENV + + - name: Tag commit for prerelease + if: inputs.prerelease + id: push + run: | + git config user.name "CovalentOpsBot" + git config user.email "covalentopsbot@users.noreply.github.com" + git tag -a $RELEASE -m "Release $RELEASE" + git remote set-url origin https://${{ secrets.COVALENT_OPS_BOT_TOKEN }}@github.com/AgnostiqHQ/covalent.git + git push origin $RELEASE + + - name: Generate stable release message + if: > + github.event.inputs.stable_version + && contains(env.PAUL_BLART, github.actor) + id: stable-changelog + uses: AgnostiqHQ/covalent/.github/actions/stable-changelog@develop + with: + changelog-path: CHANGELOG.md + version-path: VERSION + - name: Generate prerelease message if: inputs.prerelease id: message @@ -131,47 +111,42 @@ jobs: echo 'MESSAGE<> $GITHUB_ENV tail +$begin ./CHANGELOG.md | head -$end >> $GITHUB_ENV echo 'EOF' >> $GITHUB_ENV - - name: Tag commit - id: push - continue-on-error: true - run: | - git config user.name "CovalentOpsBot" - git config user.email "covalentopsbot@users.noreply.github.com" - git tag -a $RELEASE -m "Release $RELEASE" - git remote set-url origin https://${{ secrets.COVALENT_OPS_BOT_TOKEN }}@github.com/AgnostiqHQ/covalent.git - git push origin $RELEASE + - name: Create prerelease if: >- inputs.prerelease + && ${{ steps.push.outcome == 'success' && steps.message.outcome == 'success' - && (!github.event.inputs.test_release || github.event.inputs.test_release == 'false') + && (!github.event.inputs.test_release || github.event.inputs.test_release == 'false') }} uses: ncipollo/release-action@v1 with: body: ${{ env.MESSAGE }} token: ${{ secrets.COVALENT_OPS_BOT_TOKEN }} tag: ${{ env.RELEASE }} - prerelease: true - # - name: Create stable release - # if: >- - # github.event.inputs.stable_version - # && contains(env.PAUL_BLART, github.actor) - # && steps.stable-changelog.outcome == 'success' - # && (!github.event.inputs.test_release || github.event.inputs.test_release == 'false') - # uses: ncipollo/release-action@v1 - # with: - # body: ${{ steps.stable-changelog.outputs.message }} - # token: ${{ secrets.COVALENT_OPS_BOT_TOKEN }} - # tag: ${{ env.RELEASE }} - # - name: Alert Slack - # if: failure() - # uses: rtCamp/action-slack-notify@v2 - # env: - # SLACK_CHANNEL: "covalent-ci" - # SLACK_USERNAME: "CovalentOpsBot" - # SLACK_MESSAGE: "The release.yml workflow is failing in ${{ github.ref }}!" - # SLACK_COLOR: ${{ job.status }} - # SLACK_TITLE: ":warning: Attention Required :warning:" - # SLACK_WEBHOOK: ${{ secrets.SLACK_ALERT_WEBHOOK }} + prerelease: ${{ inputs.prerelease }} + + - name: Create stable release + if: >- + github.event.inputs.stable_version + && contains(env.PAUL_BLART, github.actor) + && steps.stable-changelog.outcome == 'success' + && (!github.event.inputs.test_release || github.event.inputs.test_release == 'false') + uses: ncipollo/release-action@v1 + with: + body: ${{ steps.stable-changelog.outputs.message }} + token: ${{ secrets.COVALENT_OPS_BOT_TOKEN }} + tag: ${{ env.RELEASE }} + + - name: Alert Slack + if: failure() + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_CHANNEL: "covalent-ci" + SLACK_USERNAME: "CovalentOpsBot" + SLACK_MESSAGE: "The release.yml workflow is failing in ${{ github.ref }}!" + SLACK_COLOR: ${{ job.status }} + SLACK_TITLE: ":warning: Attention Required :warning:" + SLACK_WEBHOOK: ${{ secrets.SLACK_ALERT_WEBHOOK }} pypi: runs-on: ubuntu-latest @@ -185,31 +160,38 @@ jobs: persist-credentials: false fetch-depth: 0 ref: ${{ needs.github.outputs.release }} + - name: Set up Python uses: actions/setup-python@v2 with: python-version: 3.8 + - name: Install Python dependencies run: | python -m pip install --upgrade pip pip install twine + - name: Set up Node uses: actions/setup-node@v2 with: node-version: 16 + - name: Build Webapp run: | cd ./covalent_ui/webapp yarn install yarn build + - name: Build Stable or Pre-Release Distribution id: pre-or-stable-build run: python setup.py sdist + - name: Transform semver version to pep440 id: version-transform uses: ./.github/actions/version-transform with: version-path: VERSION + - name: Validate Distribution id: validate run: | @@ -228,6 +210,7 @@ jobs: diff -r covalent-${VERSION}/covalent_ui/webapp/build ../covalent_ui/webapp/build rm -rf covalent-${VERSION}/ echo "::set-output name=version::$VERSION" + - name: Upload Distribution if: > steps.pre-or-stable-build.outcome == 'success' @@ -237,6 +220,7 @@ jobs: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: twine upload dist/* + - name: Alert Slack if: failure() uses: rtCamp/action-slack-notify@v2 @@ -247,128 +231,3 @@ jobs: SLACK_COLOR: ${{ job.status }} SLACK_TITLE: ":warning: Attention Required :warning:" SLACK_WEBHOOK: ${{ secrets.SLACK_ALERT_WEBHOOK }} - - # docker: - # runs-on: ubuntu-latest - # steps: - # - name: Check out release tag - # uses: actions/checkout@v4 - # if: inputs.stable_version - # with: - # persist-credentials: false - # fetch-depth: 0 - # ref: "v${{ github.event.inputs.stable_version }}" - - # - name: Check out master - # uses: actions/checkout@v4 - # if: inputs.prerelease - # with: - # persist-credentials: false - # fetch-depth: 0 - - # - name: Set up QEMU - # uses: docker/setup-qemu-action@master - # with: - # platforms: "linux/amd64,linux/arm64" - - # - name: Set up Docker Buildx - # uses: docker/setup-buildx-action@master - - # - name: Configure AWS credentials - # uses: aws-actions/configure-aws-credentials@v1 - # with: - # role-to-assume: ${{ secrets.ECR_PUBLIC_UPLOAD_ROLE }} - # aws-region: us-east-1 - - # - name: Generate metadata - # run: | - # aws --version - # docker info - # TAG="$(cat ./VERSION)" - # echo "TAG: $TAG" - # echo "TAG=$TAG" >> $GITHUB_ENV - # BUILD_DATE=`date -u +%Y-%m-%d` - # echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV - # BUILD_VERSION=${{ github.sha }} - # echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV - - # - name: Login to Public Registry - # run: | - # aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws - - # - name: Build and push pre-release - # if: > - # inputs.prerelease - # && !inputs.stable_version - # && github.event_name == 'schedule' - # uses: docker/build-push-action@v2 - # with: - # builder: ${{ steps.buildx.outputs.name }} - # context: . - # file: Dockerfile - # platforms: linux/amd64 - # cache-from: type=gha - # cache-to: type=gha,mode=max - # build-args: | - # BUILD_DATE=${{ env.BUILD_DATE }} - # BUILD_VERSION=${{ env.BUILD_VERSION }} - # push: true - # tags: | - # public.ecr.aws/covalent/covalent:latest - # public.ecr.aws/covalent/covalent:${{ env.TAG }} - - # - name: Build and push stable release - # if: > - # github.event_name == 'workflow_dispatch' - # && inputs.stable_version - # && !inputs.prerelease - # && !github.events.inputs.test_release - # && contains(env.PAUL_BLART, github.actor) - # uses: docker/build-push-action@v2 - # with: - # builder: ${{ steps.buildx.outputs.name }} - # context: . - # file: Dockerfile - # platforms: linux/amd64 - # cache-from: type=gha - # cache-to: type=gha,mode=max - # build-args: | - # BUILD_DATE=${{ env.BUILD_DATE }} - # BUILD_VERSION=${{ env.BUILD_VERSION }} - # push: true - # tags: | - # public.ecr.aws/covalent/covalent:${{ inputs.stable_version }} - # public.ecr.aws/covalent/covalent:stable - - # docker_aws_plugins: - # name: Trigger AWS Plugins Base Executor Image Pre-Release - # needs: pypi - # if: > - # inputs.prerelease - # && !inputs.stable_version - # && github.event_name == 'schedule' - # uses: AgnostiqHQ/covalent-aws-plugins/.github/workflows/docker.yml@develop - # with: - # prerelease: true - - # docker_aws_lambda: - # name: Trigger AWS Lambda Base Executor Image Pre-Release - # needs: pypi - # if: > - # inputs.prerelease - # && !inputs.stable_version - # && github.event_name == 'schedule' - # uses: AgnostiqHQ/covalent-awslambda-plugin/.github/workflows/docker.yml@develop - # with: - # prerelease: true - - # docker_aws_braket: - # name: Trigger AWS Braket Base Executor Image Pre-Release - # needs: pypi - # if: > - # inputs.prerelease - # && !inputs.stable_version - # && github.event_name == 'schedule' - # uses: AgnostiqHQ/covalent-braket-plugin/.github/workflows/docker.yml@develop - # with: - # prerelease: true diff --git a/.github/workflows/upload_to_codecov_with_retry.yml b/.github/workflows/upload_to_codecov_with_retry.yml deleted file mode 100644 index ea205265a..000000000 --- a/.github/workflows/upload_to_codecov_with_retry.yml +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright 2023 Agnostiq Inc. -# -# This file is part of Covalent. -# -# Licensed under the Apache License 2.0 (the "License"). A copy of the -# License may be obtained with this software package or at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Use of this file is prohibited except in compliance with the License. -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: upload-to-codecov-with-retry - -on: - workflow_call: - inputs: - files: - required: true - type: string - flags: - required: true - type: string - name: - required: true - type: string - - -jobs: - upload_to_codecov: - name: Upload coverage to Codecov - steps: - - name: Upload try 1 - id: upload-1 - uses: codecov/codecov-action@v3 - continue-on-error: true - with: - files: ${{ github.event.inputs.files }} - flags: ${{ github.event.inputs.flags }} - name: ${{ github.event.inputs.name }} - - - name: Wait 10 seconds - run: sleep 10 - - - name: Upload try 2 - id: upload-2 - if: steps.upload-1.outcome == 'failure' - uses: codecov/codecov-action@v3 - continue-on-error: true - with: - files: ${{ github.event.inputs.files }} - flags: ${{ github.event.inputs.flags }} - name: ${{ github.event.inputs.name }} - - - name: Wait 10 seconds - run: sleep 10 - - - name: Upload try 3 - id: upload-3 - if: steps.upload-2.outcome == 'failure' - uses: codecov/codecov-action@v3 - continue-on-error: true - with: - files: ${{ github.event.inputs.files }} - flags: ${{ github.event.inputs.flags }} - name: ${{ github.event.inputs.name }} - - - name: Wait 10 seconds - run: sleep 10 - - - name: Upload try 4 - id: upload-4 - if: steps.upload-3.outcome == 'failure' - uses: codecov/codecov-action@v3 - continue-on-error: true - with: - files: ${{ github.event.inputs.files }} - flags: ${{ github.event.inputs.flags }} - name: ${{ github.event.inputs.name }} - - - name: Wait 10 seconds - run: sleep 10 - - - name: Upload try 5 - id: upload-5 - if: steps.upload-4.outcome == 'failure' - uses: codecov/codecov-action@v3 - with: - files: ${{ github.event.inputs.files }} - flags: ${{ github.event.inputs.flags }} - name: ${{ github.event.inputs.name }} - fail_ci_if_error: true