Skip to content

Bump the versions

Bump the versions #45

Workflow file for this run

name: Bump the versions
on:
workflow_dispatch:
inputs:
version:
description: 'What to bump?'
required: true
default: 'patch'
type: choice
options:
- 'patch'
- 'minor'
- 'major'
jobs:
bump:
permissions:
id-token: write # Needed to federate tokens.
runs-on: ubuntu-latest
steps:
- uses: DataDog/dd-octo-sts-action@acaa02eee7e3bb0839e4272dacb37b8f3b58ba80
id: octo-sts
with:
scope: DataDog/build-plugins
audience: dd-octo-sts
policy: self.bump
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for "yarn version" to work.
token: ${{ steps.octo-sts.outputs.token }}
- uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- name: Install dependencies
run: yarn install
- name: Bump version
run: yarn version:all ${{ inputs.version }}
- name: Add files
run: git add .
- name: Variables
id: vars
run: |
VERSION=$(yarn info @datadog/build-plugins --json | jq -r '.children.Version')
echo "Version: $VERSION"
TAG_NAME="v$VERSION"
echo "Tag name: $TAG_NAME"
BRANCH_NAME="bump-version-$TAG_NAME"
echo "Branch name: $BRANCH_NAME"
# Outputs for the next steps.
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Configure git
run: |
# Set the git user.
git config --global user.name 'Bumper Bot'
git config --global user.email '200755185+dd-octo-sts[bot]@users.noreply.github.com'
- name: Create branch
run: |
echo "Checking out branch ${{ steps.vars.outputs.branch_name }}..."
git checkout -b ${{ steps.vars.outputs.branch_name }}
echo "Pushing branch ${{ steps.vars.outputs.branch_name }}..."
git push -u origin ${{ steps.vars.outputs.branch_name }}
env:
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
- name: Create commit
if: success()
run: |
echo "Committing..."
git commit -m ${{ steps.vars.outputs.tag_name }} --no-verify
echo "Tagging..."
git tag -a ${{ steps.vars.outputs.tag_name }} -m ${{ steps.vars.outputs.tag_name }}
env:
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
- name: Push commit
if: success()
uses: Asana/push-signed-commits@d615ca88d8e1a946734c24970d1e7a6c56f34897
with:
github-token: ${{ steps.octo-sts.outputs.token }}
local_branch_name: ${{ steps.vars.outputs.branch_name }}
remote_name: origin
remote_branch_name: ${{ steps.vars.outputs.branch_name }}
- name: Push tag
if: success()
run: |
git push origin ${{ steps.vars.outputs.tag_name }}
env:
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
- name: Create PR
if: success()
run: |
echo "Creating PR..."
PR_URL=$(gh pr create \
--title "[bot] Bump versions to ${{ steps.vars.outputs.tag_name }}" \
--body "This PR bumps the package versions to \`${{ steps.vars.outputs.tag_name }}\`" \
--base master \
--head "${{ steps.vars.outputs.branch_name }}")
echo "## [PR Created for bump to `${{ steps.vars.outputs.tag_name }}`](https://github.com/DataDog/build-plugins/pull/new/$PR_URL)" >> $GITHUB_STEP_SUMMARY
env:
GITHUB_TOKEN: ${{ steps.octo-sts.outputs.token }}
- name: Log bump
if: success()
run: |
HEADERS=(
-H "Content-Type: application/json"
-H "X-Datadog-Origin: build-plugins"
-H "DD-API-KEY: $DATADOG_API_KEY"
)
DATA="{
\"ddsource\": \"github\",
\"service\": \"build-plugins\",
\"message\": \"Version bumped: ${{ steps.vars.outputs.version }}\",
\"status\": \"success\",
\"env\": \"production\",
\"team\": \"language-foundations\",
\"version\": \"${{ steps.vars.outputs.version }}\"
}"
URL="https://http-intake.logs.datadoghq.com/api/v2/logs"
curl -X POST "${HEADERS[@]}" -d "$DATA" "$URL"
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}