Update Versions for Node Extension #220
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Versions for Node Extension | |
on: | |
schedule: | |
- cron: "0 14 * * *" # cron schedule uses UTC timezone. Run tests at the beginning of the day in US-East | |
jobs: | |
bump_version: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # Creates a branch | |
pull-requests: write # Creates a PR | |
actions: read # read secrets | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Modify build-packages | |
id: version | |
run: | | |
CURRENT_AGENT_VERSION=$(awk '/AGENT_VERSION=/{print}' node/scripts/build-packages.sh | awk -F '=' '{print $2}' | tr -d '"') | |
AGENT_RESPONSE=$(curl -s "https://api.github.com/repos/datadog/datadog-agent/releases") | |
AGENT_VERSION=$(echo "$AGENT_RESPONSE" | jq -r --arg pattern "7\.[0-9]*\.[0-9]*" '.[] | select(.tag_name | test($pattern)) | .tag_name' | sort -V | tail -n 1) | |
if [ "$CURRENT_AGENT_VERSION" != "$AGENT_VERSION" ]; then | |
echo "Updating agent to version: $AGENT_VERSION" | |
sed -i -e "s/AGENT_VERSION=\"[0-9]*\.[0-9]*\.[0-9]*\"/AGENT_VERSION=\"$AGENT_VERSION\"/" node/scripts/build-packages.sh | |
PR_BODY="Bumps the agent version to $AGENT_VERSION for the Node Extension." | |
PR_TITLE="[Node Extension] Bump agent to $AGENT_VERSION" | |
fi | |
CURRENT_TRACER_VERSION=$(awk '/TRACER_VERSION=/{print}' node/scripts/build-packages.sh | awk -F '=' '{print $2}' | tr -d '"') | |
TRACER_RESPONSE=$(curl -s "https://api.github.com/repos/datadog/dd-trace-js/releases") | |
TRACER_VERSION=$(echo "$TRACER_RESPONSE" | jq -r --arg pattern "v4\.[0-9]*\.[0-9]*" '.[] | select(.tag_name | test($pattern)) | .tag_name | ltrimstr("v")' | sort -V | tail -n 1) | |
if [ "$CURRENT_TRACER_VERSION" != "$TRACER_VERSION" ]; then | |
echo "Updating tracer to version: $TRACER_VERSION" | |
sed -i -e "s/TRACER_VERSION=\"[0-9]*\.[0-9]*\.[0-9]*\"/TRACER_VERSION=\"$TRACER_VERSION\"/" node/scripts/build-packages.sh | |
PR_BODY="Bumps the tracer version to $TRACER_VERSION for the Node Extension." | |
PR_TITLE="[Node Extension] Bump tracer to $TRACER_VERSION" | |
fi | |
if [ "$CURRENT_AGENT_VERSION" != "$AGENT_VERSION" ] && [ "$CURRENT_TRACER_VERSION" != "$TRACER_VERSION" ]; then | |
PR_BODY="Bumps the agent version to $AGENT_VERSION and the tracer version to $TRACER_VERSION for the Node Extension." | |
PR_TITLE="[Node Extension] Bump agent to $AGENT_VERSION and tracer to $TRACER_VERSION" | |
fi | |
echo "pr_body=$PR_BODY" >> "$GITHUB_OUTPUT" | |
echo "pr_title=$PR_TITLE" >> "$GITHUB_OUTPUT" | |
- name: Create Pull Request | |
id: pr | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: "node-extension-version-bump" | |
commit-message: "${{steps.version.outputs.pr_title}}" | |
delete-branch: true | |
title: "${{steps.version.outputs.pr_title}}" | |
body: "${{steps.version.outputs.pr_body}}" | |
- name: Display output | |
run: | | |
echo "Pull Request Number - ${{ steps.pr.outputs.pull-request-number }}" | |
echo "Pull Request URL - ${{ steps.pr.outputs.pull-request-url }}" |