-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add auto-layer-releases flow to deploy flow #1274
base: main
Are you sure you want to change the base?
Conversation
🦙 MegaLinter status: ✅ SUCCESS
See detailed report in MegaLinter reports |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1274 +/- ##
==========================================
- Coverage 79.68% 79.61% -0.07%
==========================================
Files 201 201
Lines 22174 22174
Branches 3519 3519
==========================================
- Hits 17669 17654 -15
- Misses 3355 3363 +8
- Partials 1150 1157 +7 ☔ View full report in Codecov by Sentry. |
.github/scripts/releases.py
Outdated
@@ -0,0 +1,70 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#!/bin/bash | |
#!/usr/bin/env python3 |
.github/scripts/releases.py
Outdated
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you make those a constant, so we don't have to set those as env vars? Presumably each repo will have a separate copy of this script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well...I was still thinking of making it shared at this point (even though I realize I haven't done that in this PR). I guess TBD on that.
.github/scripts/releases.py
Outdated
tag_name = f"{latest_version}.0_{runtime}" | ||
release_name = f"New Relic {runtime} Agent {latest_version}.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This originally had logic to have release names and release tags as different strings. For Python the only difference was capitalization, but for Node and .NET it was Node -> nodejs
, and .NET -> dotnet
.
Why not make constants for TAG_SUFFIX="python"
and RUNTIME_NAME="Python"
. Then maybe use bool constants to toggle on/off the lambda and initcontainer releases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oooh you're totally right! I was trying to simplify those out but they were used for the release name-I'll put those back I guess. Instead of a boolean I was thinking each team could just set the value of those and that way the work flow could be shared across all teams-I need to look into that more though to see if we can do that.
As a general thought, is there a reason not to convert this to bash scripting and use the |
I was actually thinking about this after I pushed this up as a Python script. Since we seem to both have had that thought, I'll just go ahead and do that. I agree-it would be easier to maintain that way for each team in the long run. |
ad59deb
to
30b2816
Compare
Move auto-layer-releases flow from lambda to GHA.
690b061
to
9ac223d
Compare
.github/workflows/deploy-python.yml
Outdated
@@ -182,3 +182,16 @@ jobs: | |||
env: | |||
TWINE_USERNAME: __token__ | |||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gh
should be preinstalled on all runners, I think this 3rd party action is unnecessary.
- name: Create release tags for Lambda and K8s Init Containers | ||
run: | | ||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- name: Create release tags for Lambda and K8s Init Containers | |
run: | | |
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 | |
- name: Create release tags for Lambda and K8s Init Containers | |
run: | | |
RELEASE_TITLE="New Relic Python Agent ${GITHUB_REF}.0" | |
RELEASE_TAG="${GITHUB_REF}.0_python" | |
RELEASE_NOTES="Automated release for [Python Agent ${GITHUB_REF}](https://github.com/newrelic/newrelic-python-agent/releases/tag/${GITHUB_REF})" | |
gh auth login --with-token <<< $GH_RELEASE_TOKEN | |
echo "newrelic/newrelic-lambda-layers - Releasing ${RELEASE_TITLE} with tag ${RELEASE_TAG}" | |
gh release create "${RELEASE_TAG}" --title=${RELEASE_TITLE} --repo=newrelic/newrelic-lambda-layers --notes=${RELEASE_NOTES} | |
echo "newrelic/newrelic-agent-init-container - Releasing ${RELEASE_TITLE} with tag ${RELEASE_TAG}" | |
gh release create "${RELEASE_TAG}" --title=${RELEASE_TITLE} --repo=newrelic/newrelic-agent-init-container --notes=${RELEASE_NOTES} |
I have 3 suggestions here, going to lump them together but if you don't like one of them I can separate it.
- You have the subcommands backwards:
gh create release
->gh release create
- To make this slightly more DRY so it's easier to update for other agents, can we maybe pull these repeated expressions out into constants that are created once and then referenced?
- This would be a good opportunity to fix a random issue that annoys me, the release notes that are autogenerated by Github when none are supplied just ends up being the last commit message, which looks really strange and confusing when they have nothing to do with the agent being released. Can we provide a simple release note that just redirects to the original agent release on Github? That way it will always point to both the ref on Github and the actual release notes from that release are either there or linked on our docs site.
Overview
Move auto-layer-releases flow from lambda to GHA.