From e2d2afa22b7fd096c58ceb3d60e96fa3737840be Mon Sep 17 00:00:00 2001 From: Yoann Moinet Date: Fri, 16 Jan 2026 10:33:49 -0500 Subject: [PATCH 1/6] Allow to publish on the dev channel --- .github/workflows/publish.yaml | 83 ++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index e56ce31b..9ce0d58c 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -2,7 +2,20 @@ name: Publish packages on NPM on: release: types: [released] - workflow_dispatch: {} # Allow for manual trigger. + workflow_dispatch: + inputs: + channel: + description: 'Publish channel (latest or dev)' + required: true + default: 'dev' + type: choice + options: + - latest + - dev + version: + description: 'Version to publish (leave empty to use current version in package.json)' + required: false + type: string jobs: publish: @@ -17,10 +30,70 @@ jobs: node-version: '24' registry-url: 'https://registry.npmjs.org' + - name: Validate and set channel + id: channel + run: | + # Defaults to 'latest' for release events, otherwise uses dispatch input (which defaults to 'dev'). + CHANNEL="${{ github.event.inputs.channel || 'latest' }}" + BRANCH="${{ github.ref_name }}" + + # Restrict 'latest' channel to master branch only + if [ "$CHANNEL" = "latest" ] && [ "$BRANCH" != "master" ]; then + echo "Error: The 'latest' channel can only be published from the 'master' branch." + echo "Current branch: $BRANCH" + echo "Use the 'dev' channel for publishing from other branches." + exit 1 + fi + + echo "channel=$CHANNEL" >> $GITHUB_OUTPUT + echo "Publishing to channel: $CHANNEL from branch: $BRANCH" + + - name: Validate and set version + id: version + run: | + VERSION="${{ github.event.inputs.version }}" + CHANNEL="${{ steps.channel.outputs.channel }}" + + # If version is provided, validate it + if [ -n "$VERSION" ]; then + echo "Using provided version: $VERSION" + + # For dev channel, verify version ends with -dev. + if [ "$CHANNEL" = "dev" ]; then + if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+-dev\.[0-9]+$'; then + echo "Error: Dev channel versions must end with -dev. (e.g., 1.0.0-dev.0)" + exit 1 + fi + fi + + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "has_version=true" >> $GITHUB_OUTPUT + else + echo "No version provided, will use current package.json version" + echo "has_version=false" >> $GITHUB_OUTPUT + fi + - run: yarn + + - name: Set version if provided + if: steps.version.outputs.has_version == 'true' + run: | + VERSION="${{ steps.version.outputs.version }}" + echo "Setting version to: $VERSION" + yarn version:all "$VERSION" - run: yarn workspace @datadog/rollup-plugin buildBasic - run: export BUILD_PLUGINS_ENV=production - - run: yarn publish:all + + - name: Publish to NPM + run: | + CHANNEL="${{ steps.channel.outputs.channel }}" + if [ "$CHANNEL" = "dev" ]; then + echo "Publishing to dev channel with --tag dev" + yarn loop --no-private npm publish --tag dev + else + echo "Publishing to latest channel" + yarn loop --no-private npm publish + fi env: ADD_BUILD_PLUGINS: 1 DD_GITHUB_JOB_NAME: Publish to NPM # Needs to be the same as the job to have CI Vis link the spans. @@ -28,6 +101,7 @@ jobs: - name: Log version published run: | VERSION="$(yarn workspace @datadog/webpack-plugin info @datadog/webpack-plugin --json | jq -r '.children.Version')" + CHANNEL="${{ steps.channel.outputs.channel }}" HEADERS=( -H "Content-Type: application/json" -H "X-Datadog-Origin: build-plugins" @@ -36,11 +110,12 @@ jobs: DATA="{ \"ddsource\": \"github\", \"service\": \"build-plugins\", - \"message\": \"Latest version published: $VERSION\", + \"message\": \"Version published to $CHANNEL channel: $VERSION\", \"status\": \"success\", \"env\": \"production\", \"team\": \"language-foundations\", - \"version\": \"$VERSION\" + \"version\": \"$VERSION\", + \"channel\": \"$CHANNEL\" }" URL="https://http-intake.logs.datadoghq.com/api/v2/logs" curl -X POST "${HEADERS[@]}" -d "$DATA" "$URL" From eb63591624ef3b5216f198f3de4c7a254f9a0cd6 Mon Sep 17 00:00:00 2001 From: Yoann Moinet Date: Fri, 16 Jan 2026 10:37:49 -0500 Subject: [PATCH 2/6] Limit version overwrite for non `master` branches --- .github/workflows/publish.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 9ce0d58c..e3adbc49 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -53,11 +53,19 @@ jobs: run: | VERSION="${{ github.event.inputs.version }}" CHANNEL="${{ steps.channel.outputs.channel }}" + BRANCH="${{ github.ref_name }}" # If version is provided, validate it if [ -n "$VERSION" ]; then echo "Using provided version: $VERSION" + # Restrict version override to non-master branches only + if [ "$BRANCH" = "master" ]; then + echo "Error: Cannot provide a custom version when publishing from the 'master' branch." + echo "On master, the version from package.json must be used." + exit 1 + fi + # For dev channel, verify version ends with -dev. if [ "$CHANNEL" = "dev" ]; then if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+-dev\.[0-9]+$'; then From 49c380aa289bdebbb9b8bb02a2973ba53d3f9fd4 Mon Sep 17 00:00:00 2001 From: Yoann Moinet Date: Fri, 16 Jan 2026 10:41:41 -0500 Subject: [PATCH 3/6] Allow version overrides for `master` on `dev` channel only --- .github/workflows/publish.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index e3adbc49..59ebeb64 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -59,10 +59,10 @@ jobs: if [ -n "$VERSION" ]; then echo "Using provided version: $VERSION" - # Restrict version override to non-master branches only - if [ "$BRANCH" = "master" ]; then - echo "Error: Cannot provide a custom version when publishing from the 'master' branch." - echo "On master, the version from package.json must be used." + # Restrict version override on master branch to non-latest channels only + if [ "$BRANCH" = "master" ] && [ "$CHANNEL" = "latest" ]; then + echo "Error: Cannot provide a custom version when publishing to 'latest' channel from the 'master' branch." + echo "For 'latest' channel on master, the version from package.json must be used." exit 1 fi From efa8e6a5316334dc2625cc0b0240ce518f6936b9 Mon Sep 17 00:00:00 2001 From: Yoann Moinet Date: Fri, 16 Jan 2026 10:45:01 -0500 Subject: [PATCH 4/6] Update documentation --- CONTRIBUTING.md | 68 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 19 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8d2f003b..a4b64848 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -293,6 +293,8 @@ We try to keep the documentation as up to date as possible. ## Publish a new public version +### Recommended: Using GitHub Release (Automatic) + 1. Run [this action](https://github.com/DataDog/build-plugins/actions/workflows/bump.yaml) with the type of bump you need (`patch`, `minor`, `major`) and keep the `master` branch as target. ![Bump workflow](/packages/assets/src/publish/run-workflow.png) @@ -323,27 +325,44 @@ We try to keep the documentation as up to date as possible. Usually, after 4-5min, your version will be available from NPM. +### Alternative: Using Workflow Dispatch (Manual) -## Publish a new dev version +You can also manually trigger the [publish workflow](https://github.com/DataDog/build-plugins/actions/workflows/publish.yaml) from the `master` branch: -You can publish a version in the `dev` channel so you can easily test your changes in a different repository's CI: +1. Ensure you're on the `master` branch +2. Update the version in package.json if needed (via the bump workflow or manually) +3. Go to the [publish workflow](https://github.com/DataDog/build-plugins/actions/workflows/publish.yaml) +4. Click "Run workflow" +5. Select the `master` branch +6. Set `channel` to `latest` +7. Leave `version` empty (it will use the version from package.json) +8. Run the workflow -1. First you need to bump the version with a marker for the channel, ex: `0.4.2-dev.0` so we don't occupy a version of the `latest` channel. +> [!IMPORTANT] +> When publishing to the `latest` channel from `master`, you cannot provide a custom version, the workflow will use the version from package.json to ensure version integrity. -```bash -# Set your dev version locally (you may need to run it twice to circonvent a yarn bug) -yarn version:all 0.4.2-dev -``` -2. Then publish the packages (you'll need an NPM token for this): +## Publish a new dev version -```bash -# First add your write token -yarn config set npmAuthToken $NPM_WRITE_TOKEN +You can publish a version in the `dev` channel so you can easily test your changes in a different repository's CI. -# Publish everything to the dev channel -yarn publish:all --tag=dev -``` +### Using GitHub Actions Workflow + +The easiest way to publish a dev version is using the GitHub Actions workflow: + +1. Go to the [publish workflow](https://github.com/DataDog/build-plugins/actions/workflows/publish.yaml) +2. Click "Run workflow" +3. Select your feature branch (or `master` if publishing from there) +4. Set `channel` to `dev` +5. Set `version` to your dev version (e.g., `3.0.9-dev.0`) + - The version **must** follow the format `X.Y.Z-dev.N` + - For example: `3.0.9-dev.0`, `3.0.9-dev.1`, etc. +6. Run the workflow + +> [!NOTE] +> - Dev versions can be published from any branch +> - You can provide a custom version when publishing to the `dev` channel +> - The workflow will validate the version format and fail if it doesn't match `X.Y.Z-dev.N` Wait a few minutes, and you're good to go. @@ -398,21 +417,32 @@ This will update the versions of all the plugins we use in the monorepo (webpack ### Publish a dev/alpha/beta version of the plugins to consume in Datadog's Frontend monorepo -If you want to test your `build-plugins`'s changes in our monorepo's CI, you can publish a dev version of the plugins: +If you want to test your `build-plugins`'s changes in our monorepo's CI, you can publish a dev version of the plugins. + +**Option 1: Using GitHub Actions (Recommended)** + +1. Go to the [publish workflow](https://github.com/DataDog/build-plugins/actions/workflows/publish.yaml) +2. Click "Run workflow" +3. Select your feature branch +4. Set `channel` to `dev` +5. Set `version` to `2.5.1-dev.0` (or your desired dev version following the `X.Y.Z-dev.N` format) +6. Run the workflow + +**Option 2: Manual Publishing** ```bash -# Use a version with a marker for the channel, ex: 2.5.1-dev-0 -yarn version:all 2.5.1-dev-0 +# Use a version with a marker for the channel, ex: 2.5.1-dev.0 +yarn version:all 2.5.1-dev.0 # Publish everything to the dev channel # You will need $NPM_DD_WRITE_TOKEN set in your environment YARN_NPM_AUTH_TOKEN=$NPM_DD_WRITE_TOKEN yarn publish:all --tag=dev ``` -Once published, in the repository: +Once published, in the monorepo: ```bash -yarn update-build-plugins 2.5.1-dev-0 +yarn update-build-plugins 2.5.1-dev.0 ``` Commit and push the changes. From f0b51547c681f3d7681e7b9dd39bddedc0ca78c3 Mon Sep 17 00:00:00 2001 From: Yoann Moinet Date: Fri, 16 Jan 2026 10:47:57 -0500 Subject: [PATCH 5/6] Link instead of duplicate --- CONTRIBUTING.md | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a4b64848..bd676785 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -419,25 +419,7 @@ This will update the versions of all the plugins we use in the monorepo (webpack If you want to test your `build-plugins`'s changes in our monorepo's CI, you can publish a dev version of the plugins. -**Option 1: Using GitHub Actions (Recommended)** - -1. Go to the [publish workflow](https://github.com/DataDog/build-plugins/actions/workflows/publish.yaml) -2. Click "Run workflow" -3. Select your feature branch -4. Set `channel` to `dev` -5. Set `version` to `2.5.1-dev.0` (or your desired dev version following the `X.Y.Z-dev.N` format) -6. Run the workflow - -**Option 2: Manual Publishing** - -```bash -# Use a version with a marker for the channel, ex: 2.5.1-dev.0 -yarn version:all 2.5.1-dev.0 - -# Publish everything to the dev channel -# You will need $NPM_DD_WRITE_TOKEN set in your environment -YARN_NPM_AUTH_TOKEN=$NPM_DD_WRITE_TOKEN yarn publish:all --tag=dev -``` +Follow the instructions in [Publish a new dev version](#publish-a-new-dev-version) to publish your dev version (e.g., `2.5.1-dev.0`). Once published, in the monorepo: From b4f55dbba041eff1888cf5167e02d0663bcd5179 Mon Sep 17 00:00:00 2001 From: Yoann Moinet Date: Fri, 16 Jan 2026 10:49:58 -0500 Subject: [PATCH 6/6] Update TOC --- CONTRIBUTING.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bd676785..505b789d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,10 @@ - [Open Source compliance](#open-source-compliance) - [Documentation](#documentation) - [Publish a new public version](#publish-a-new-public-version) + - [Recommended: Using GitHub Release (Automatic)](#recommended-using-github-release-automatic) + - [Alternative: Using Workflow Dispatch (Manual)](#alternative-using-workflow-dispatch-manual) - [Publish a new dev version](#publish-a-new-dev-version) + - [Using GitHub Actions Workflow](#using-github-actions-workflow) - [Work with Datadog's Frontend monorepo](#work-with-datadogs-frontend-monorepo) - [Requirements](#requirements) - [Develop on both our monorepo and `build-plugins` locally](#develop-on-both-our-monorepo-and-build-plugins-locally)