Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 0 additions & 113 deletions .github/workflows/prepare_release.yml

This file was deleted.

118 changes: 56 additions & 62 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,76 +22,70 @@ jobs:
steps:
- name: Get GitHub App token
id: get_token
uses: actions/create-github-app-token@v1
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 #v1.11.1
with:
app-id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
private-key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}

- name: Create release
uses: actions/github-script@v6
env:
RELEASE_BRANCH: ${{ github.head_ref }}
with:
github-token: ${{ steps.get_token.outputs.token }}
script: |
const tagName = `datadog-api-client-${process.env.RELEASE_BRANCH.split("/")[1]}`;
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: `refs/tags/${tagName}`,
sha: context.payload.pull_request.merge_commit_sha,
});
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
generate_release_notes: true,
tag_name: tagName,
});

- uses: actions/checkout@v3
- name: Checkout ${{ github.event.pull_request.base.ref }}
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
token: ${{ steps.get_token.outputs.token }}
ref: ${{ github.event.pull_request.base.ref }}
fetch-depth: 0

- name: Setup Git
- name: Release packages
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
GH_TOKEN: ${{ steps.get_token.outputs.token }}
shell: bash
run: |
git config user.name "${GIT_AUTHOR_NAME}"
git config user.email "${GIT_AUTHOR_EMAIL}"
CHANGED_POM_XML_FILES=$(git diff --diff-filter=MACR --name-only $BASE_SHA...$HEAD_SHA \
| grep -E 'pom\.xml$' \
| xargs dirname \
| sort \
| uniq)

- name: Install Java
uses: actions/setup-java@v3
with:
java-version: "8"
distribution: "temurin"
cache: "maven"
declare -A versions
for package in $CHANGED_POM_XML_FILES; do
base_version=$(git show $BASE_SHA:$package/pom.xml | grep -E '<version>.*</version>' | head -n 1 | sed -E 's/.*<version>(.*)<\/version>.*/\1/')
head_version=$(git show $HEAD_SHA:$package/pom.xml | grep -E '<version>.*</version>' | head -n 1 | sed -E 's/.*<version>(.*)<\/version>.*/\1/')

- name: Bump version
run: |
git switch -c "${POST_RELEASE_BRANCH}"
mvn --batch-mode release:update-versions
git commit -a -m "Post release bump"
git push -f --set-upstream origin "${POST_RELEASE_BRANCH}"
env:
POST_RELEASE_BRANCH: post-${{ github.head_ref }}
if [ "$base_version" != "$head_version" ]; then
versions[$package]=$head_version
fi
done

- name: Create PR
uses: actions/github-script@v6
env:
POST_RELEASE_BRANCH: post-${{ github.head_ref }}
BASE: master
with:
github-token: ${{ steps.get_token.outputs.token }}
script: |
const { data: pr } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
head: process.env.POST_RELEASE_BRANCH,
base: process.env.BASE,
title: "Post release",
body: "Bump to dev version",
});
await github.rest.issues.addLabels({
issue_number: pr.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["changelog/no-changelog"],
});
for package in "${!versions[@]}"; do
echo "Releasing $package at version ${versions[$package]}"

# Build the tag name
if [[ "$package" == "." ]]; then
# If the package is the root, use the version as the tag name
tag_name="datadog-api-client-${versions[$package]}"
else
# If the package is not the root, use the package name and version as the tag name
tag_name="$package/${versions[$package]}"
fi

# Get the changelog entries since last release
# TODO: Implement this
# changelog_content=$(git diff $BASE_REF...$HEAD_REF -- $package/CHANGELOG.md | grep -A 1000 "^+##" | grep -v "^+++" | sed 's/^+//')

is_prerelease=$(echo $package | grep -q "beta" && echo true || echo false)
# Create the tag
gh api repos/{owner}/{repo}/git/refs \
-f ref="refs/tags/$tag_name" \
-f sha=$HEAD_SHA

# Create the release
gh api repos/{owner}/{repo}/releases --input - << EOF
{
"tag_name": "$tag_name",
"name": "$tag_name",
"body": "See $package/CHANGELOG.md for details",
"prerelease": $is_prerelease
}
EOF
done
40 changes: 0 additions & 40 deletions RELEASING.md

This file was deleted.