diff --git a/.github/workflows/prepare_release.yml b/.github/workflows/prepare_release.yml
deleted file mode 100644
index c0106141168..00000000000
--- a/.github/workflows/prepare_release.yml
+++ /dev/null
@@ -1,113 +0,0 @@
-name: Prepare release
-
-env:
- GIT_AUTHOR_EMAIL: "packages@datadoghq.com"
- GIT_AUTHOR_NAME: "ci.datadog-api-spec"
-
-permissions:
- contents: write
- pull-requests: write
-
-on:
- workflow_dispatch:
- inputs:
- version:
- description: New version tag
-
-jobs:
- prepare_release:
- name: Create release PR
- runs-on: ubuntu-latest
- steps:
- - name: Get GitHub App token
- id: get_token
- uses: actions/create-github-app-token@v1
- with:
- app-id: ${{ secrets.PIPELINE_GITHUB_APP_ID }}
- private-key: ${{ secrets.PIPELINE_GITHUB_APP_PRIVATE_KEY }}
- - uses: actions/checkout@v3
- with:
- fetch-depth: 0
-
- - name: Setup Git
- run: |
- git config user.name "${GIT_AUTHOR_NAME}"
- git config user.email "${GIT_AUTHOR_EMAIL}"
-
- - name: Install Java
- uses: actions/setup-java@v3
- with:
- java-version: "8"
- distribution: "temurin"
- cache: "maven"
-
- - name: Calculate version
- id: get_version
- run: |
- if [ "${VERSION}" = "" ] ; then
- LATEST_TAG=$(git describe --tags --abbrev=0)
- NEXT_VERSION=$(echo ${LATEST_TAG#datadog-api-client-} | awk '{split($0, a, "."); print a[1] "." a[2] + 1 ".0"}')
- echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT
- else
- echo "version=$VERSION" >> $GITHUB_OUTPUT
- fi
- env:
- VERSION: ${{ github.event.inputs.version }}
-
- - name: Bump version
- run: |
- git switch -c "release/${RELEASE_VERSION}"
- mvn -DnewVersion=${RELEASE_VERSION} versions:set
- git commit -a -m "Version bump ${RELEASE_VERSION}"
- git push -f --set-upstream origin "release/${RELEASE_VERSION}"
- env:
- RELEASE_VERSION: ${{ steps.get_version.outputs.version }}
-
- - name: Create PR
- uses: actions/github-script@v6
- env:
- RELEASE_VERSION: ${{ steps.get_version.outputs.version }}
- BASE: ${{ github.event.ref }}
- with:
- github-token: ${{ steps.get_token.outputs.token }}
- script: |
- const { data: notes } = await github.rest.repos.generateReleaseNotes({
- owner: context.repo.owner,
- repo: context.repo.repo,
- tag_name: `datadog-api-client-${process.env.RELEASE_VERSION}`,
- });
- const today = new Date().toJSON().slice(0, 10);
- const header = [`# CHANGELOG\n\n## ${process.env.RELEASE_VERSION} / ${today}\n`];
- const changes = header.concat(notes.body.split("\n").slice(3));
- const { data: content } = await github.rest.repos.getContent({
- owner: context.repo.owner,
- repo: context.repo.repo,
- path: "CHANGELOG.md",
- });
- const rawContent = Buffer.from(content.content, "base64")
- .toString("utf-8")
- .split("\n");
- const newContent = changes.concat(rawContent.slice(1)).join("\n");
- await github.rest.repos.createOrUpdateFileContents({
- owner: context.repo.owner,
- repo: context.repo.repo,
- message: "Update CHANGELOG",
- content: Buffer.from(newContent).toString("base64"),
- path: "CHANGELOG.md",
- branch: `release/${process.env.RELEASE_VERSION}`,
- sha: content.sha,
- });
- const { data: pr } = await github.rest.pulls.create({
- owner: context.repo.owner,
- repo: context.repo.repo,
- head: `release/${process.env.RELEASE_VERSION}`,
- base: process.env.BASE,
- title: `Release ${process.env.RELEASE_VERSION}`,
- body: "Update CHANGELOG",
- });
- await github.rest.issues.addLabels({
- issue_number: pr.number,
- owner: context.repo.owner,
- repo: context.repo.repo,
- labels: ["changelog/no-changelog"],
- });
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 81fc67783c9..7351fe6f2e2 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -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 '.*' | head -n 1 | sed -E 's/.*(.*)<\/version>.*/\1/')
+ head_version=$(git show $HEAD_SHA:$package/pom.xml | grep -E '.*' | head -n 1 | sed -E 's/.*(.*)<\/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
diff --git a/RELEASING.md b/RELEASING.md
deleted file mode 100644
index 16a0f17f84e..00000000000
--- a/RELEASING.md
+++ /dev/null
@@ -1,40 +0,0 @@
-# Releasing
-
-This document summarizes the process of doing a new release of this project.
-Release can only be performed by Datadog maintainers of this repository.
-
-## Schedule
-This project does not have a strict release schedule. However, we would make a release at least every 2 months.
- - No release will be done if no changes got merged to the `master` branch during the above mentioned window.
- - Releases may be done more frequently than the above mentioned window.
-
-### Prerequisites
-- Ensure all CIs are passing on the master branch that we're about to release.
-
-## Release Process
-
-The release process is controlled and run by GitHub Actions.
-
-### Prerequisite
-
-1. Make sure you have `write_repo` access.
-1. Share your plan for the release with other maintainers to avoid conflicts during the release process.
-
-### Update Changelog
-
-1. Open [prepare release](https://github.com/DataDog/datadog-api-client-java/actions/workflows/prepare_release.yml) and click on `Run workflow` dropdown.
-1. If needed, enter new version identifier in the `New version number` input box (e.g. `1.10.0`). Leave it blank to increment the minor by default.
-1. Trigger the action by clicking on `Run workflow` button.
-
-### Review
-
-1. Review the generated pull-request for `release/` branch.
-1. If everything is fine, merge the pull-request.
-1. Check that the [release](https://github.com/DataDog/datadog-api-client-java/actions/workflows/release.yml) action created new release on GitHub.
- - This will kick off a GitLab pipeline that will build and upload the JAR to sonatype.
- - If this job fails due to an expired GPG key, refresh the key using the `create_key` job, which uses the [agent-key-management-tools](https://github.com/DataDog/agent-key-management-tools/blob/master/gpg/README.md) image.
- - Make sure to set `EXPORT_TO_KEYSERVER: true` when manually starting the job to upload the public keys to the relevant keyservers. Key propagation will take around 10 minutes.
- - Sign into sonatype and find the uploaded project [here](https://oss.sonatype.org/#stagingRepositories)
- - Check this project and click `Release`. Once confirmed this will start the sync and finalize the release.
- - Note the full sync may take some time but confirm the version is available [here](https://repo1.maven.org/maven2/com/datadoghq/datadog-api-client/)
-1. Review and merge generated `Post release` pull-request with `SNAPSHOT` version bump.