From 30b28160aeeee305c1635dfc49a383df830e3a98 Mon Sep 17 00:00:00 2001 From: Hannah Stepanek Date: Tue, 17 Dec 2024 15:11:08 -0800 Subject: [PATCH] Convert to gh cli --- .github/scripts/releases.py | 70 ----------------------------- .github/workflows/deploy-python.yml | 13 +++--- 2 files changed, 8 insertions(+), 75 deletions(-) delete mode 100644 .github/scripts/releases.py diff --git a/.github/scripts/releases.py b/.github/scripts/releases.py deleted file mode 100644 index 0a507ce971..0000000000 --- a/.github/scripts/releases.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -# Copyright 2010 New Relic, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# 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. -import os - -from github import Github - -# How to use this script: -# Set the following env vars: -# * GH_RELEASE_TOKEN -# * LAMBDA_RUNTIME (optional) -# * INITCONTAINER_RUNTIME (optional) -# * AGENT_VERSION -# * DRY_RUN (optional) set to 1 to run the flow without creating the release tag. -# -# Lambda runtime options: -# nodejs -# python -# ruby -# dotnet -# -# Initcontainer runtime options: -# nodejs -# python -# ruby -# java -# dotnet - -DRY_RUN = os.environ.get("DRY_RUN", "").lower() in ("on", "true", "1") - - -def run_container_releases(): - gh = Github(os.environ["GH_RELEASE_TOKEN"]) - lambda_runtime = os.environ.get("LAMBDA_RUNTIME") - initcontainer_runtime = os.environ.get("INITCONTAINER_RUNTIME") - latest_version = os.environ["AGENT_VERSION"] - - lambda_repo = gh.get_repo("newrelic/newrelic-lambda-layers") - initcontainer_repo = gh.get_repo("newrelic/newrelic-agent-init-container") - - if lambda_runtime: - create_release(lambda_repo, lambda_runtime, latest_version) - if initcontainer_runtime: - create_release(initcontainer_repo, initcontainer_runtime, latest_version) - - -def create_release(repo, runtime, latest_version): - tag_name = f"{latest_version}.0_{runtime}" - release_name = f"New Relic {runtime} Agent {latest_version}.0" - - print(f'{repo.full_name} - Releasing "{release_name}" with tag "{tag_name}"') - - if not DRY_RUN: - git_release = repo.create_git_release(tag_name, release_name, "") - print(git_release.__repr__()) - - -if __name__ == "__main__": - run_container_releases() diff --git a/.github/workflows/deploy-python.yml b/.github/workflows/deploy-python.yml index 0016cdc8e0..74355969ee 100644 --- a/.github/workflows/deploy-python.yml +++ b/.github/workflows/deploy-python.yml @@ -184,11 +184,14 @@ jobs: TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} - name: Create release tags for Lambda and K8s Init Containers + uses: dev-hanz-ops/install-gh-cli-action@c78dbed4be2f8d6133a14a9a597ee12fd4ed5c93 #v3 + with: + gh-cli-version: 2.24.3 run: | - pip install PyGitHub - python .github/scripts/release.py + gh auth login --with-token <<< $GH_RELEASE_TOKEN + echo "newrelic/newrelic-lambda-layers - Releasing New Relic Python Agent ${GITHUB_REF}.0 with tag ${GITHUB_REF}.0_python" + gh create release "${GITHUB_REF}.0_python" -t "New Relic Python Agent ${GITHUB_REF}.0" --repo=newrelic/newrelic-lambda-layers + echo "newrelic/newrelic-agent-init-container - Releasing New Relic Python Agent ${GITHUB_REF}.0 with tag ${GITHUB_REF}.0_python" + gh create release "${GITHUB_REF}.0_python" -t "New Relic Python Agent ${GITHUB_REF}.0" --repo=newrelic/newrelic-agent-init-container env: GH_RELEASE_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }} - LAMBDA_RUNTIME: python - INITCONTAINER_RUNTIME: python - AGENT_VERSION: ${{ github.ref }}