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
76 changes: 76 additions & 0 deletions .github/workflows/publish-core.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Publish ads-core to npm

on:
workflow_dispatch:
inputs:
environment:
description: "Environment (production or beta)"
required: false
default: production
type: choice
options:
- production
- beta
CA_TOKEN:
description: "CodeArtifact Token"
required: true
type: string
CA_OWNER:
description: "CodeArtifact Domain Owner"
required: true
type: string

permissions:
contents: read
id-token: write

env:
CODEARTIFACT_DOMAIN: main
CODEARTIFACT_REPOSITORY: internal-npm
AWS_REGION: us-east-1

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "24"

- name: Read package version
id: pkg
run: |
VERSION=$(node -p "require('./packages/core/package.json').version")
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Publishing @vtex/ads-core@${VERSION}"

- name: Configure npm for CodeArtifact
run: |
set -euo pipefail
CODEARTIFACT_URL="https://${CODEARTIFACT_DOMAIN}-${{ github.event.inputs.CA_OWNER }}.d.codeartifact.${AWS_REGION}.amazonaws.com/npm/${CODEARTIFACT_REPOSITORY}/"
npm config set registry "${CODEARTIFACT_URL}"
npm config set "//${CODEARTIFACT_DOMAIN}-${{ github.event.inputs.CA_OWNER }}.d.codeartifact.${AWS_REGION}.amazonaws.com/npm/${CODEARTIFACT_REPOSITORY}/:_authToken" "${{ github.event.inputs.CA_TOKEN }}"

- name: Download package from CodeArtifact
run: |
set -euo pipefail
npm pack "@vtex/ads-core@${{ steps.pkg.outputs.version }}"
echo "Downloaded:"
ls -1 *.tgz

- name: Set npm registry to npmjs
run: npm config set registry https://registry.npmjs.org

- name: Publish tarball to npmjs
run: |
set -euo pipefail
TARBALL=$(ls -1 *.tgz | head -n 1)
TAG_FLAG=""
if [ "${{ github.event.inputs.environment }}" = "beta" ]; then
TAG_FLAG="--tag beta"
fi
npm publish "${TARBALL}" --access public ${TAG_FLAG}
115 changes: 0 additions & 115 deletions .github/workflows/publish-npm.yml

This file was deleted.

76 changes: 76 additions & 0 deletions .github/workflows/publish-react.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Publish ads-react to npm

on:
workflow_dispatch:
inputs:
environment:
description: "Environment (production or beta)"
required: false
default: production
type: choice
options:
- production
- beta
CA_TOKEN:
description: "CodeArtifact Token"
required: true
type: string
CA_OWNER:
description: "CodeArtifact Domain Owner"
required: true
type: string

permissions:
contents: read
id-token: write

env:
CODEARTIFACT_DOMAIN: main
CODEARTIFACT_REPOSITORY: internal-npm
AWS_REGION: us-east-1

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "24"

- name: Read package version
id: pkg
run: |
VERSION=$(node -p "require('./packages/react/package.json').version")
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Publishing @vtex/ads-react@${VERSION}"

- name: Configure npm for CodeArtifact
run: |
set -euo pipefail
CODEARTIFACT_URL="https://${CODEARTIFACT_DOMAIN}-${{ github.event.inputs.CA_OWNER }}.d.codeartifact.${AWS_REGION}.amazonaws.com/npm/${CODEARTIFACT_REPOSITORY}/"
npm config set registry "${CODEARTIFACT_URL}"
npm config set "//${CODEARTIFACT_DOMAIN}-${{ github.event.inputs.CA_OWNER }}.d.codeartifact.${AWS_REGION}.amazonaws.com/npm/${CODEARTIFACT_REPOSITORY}/:_authToken" "${{ github.event.inputs.CA_TOKEN }}"

- name: Download package from CodeArtifact
run: |
set -euo pipefail
npm pack "@vtex/ads-react@${{ steps.pkg.outputs.version }}"
echo "Downloaded:"
ls -1 *.tgz

- name: Set npm registry to npmjs
run: npm config set registry https://registry.npmjs.org

- name: Publish tarball to npmjs
run: |
set -euo pipefail
TARBALL=$(ls -1 *.tgz | head -n 1)
TAG_FLAG=""
if [ "${{ github.event.inputs.environment }}" = "beta" ]; then
TAG_FLAG="--tag beta"
fi
npm publish "${TARBALL}" --access public ${TAG_FLAG}
32 changes: 30 additions & 2 deletions .vtex/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,45 @@
build:
provider: dkcicd
pipelines:
- name: node-ci-v2
parameters:
nodeVersion: "24-bookworm"
packageManager: pnpm
skipInstall: false
nodeCommands:
- build
when:
- event: pull_request
source: branch

- name: npm-publish-v1
parameters:
nodeVersion: "24-bookworm"
packageManager: pnpm
skipInstall: false
contextPath: packages/core
nodeCommands:
- build
publishViaGithubWorkflow: true
workflowFile: publish-core.yml
workflowVersion: "{{ ref_name }}"
when:
- event: push
source: tag
regex: ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?$

- name: npm-publish-v1
parameters:
nodeVersion: "24-bookworm"
packageManager: pnpm
skipInstall: false
contextPath: packages/react
nodeCommands:
- build
publishViaGithubWorkflow: true
workflowFile: publish-npm.yml
workflowFile: publish-react.yml
workflowVersion: "{{ ref_name }}"
when:
- event: push
source: tag
regex: ^(ads-core|ads-react)-v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?$
regex: ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?$
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,29 @@ Open a single PR with everything: code changes, updated `package.json`, updated

### 2. Tag and trigger the pipeline

After the PR is merged, pull `main` and push a Git tag for each bumped package:
After the PR is merged, pull `main` and push a single Git tag for both packages (they are always kept at the same version):

```bash
git checkout main && git pull

# Production release
git tag @vtex/ads-core@1.2.3
git push origin @vtex/ads-core@1.2.3
git tag v1.2.3
git push origin v1.2.3

# Beta release
git tag @vtex/ads-core@1.2.3-beta.0
git push origin @vtex/ads-core@1.2.3-beta.0
git tag v1.2.3-beta.0
git push origin v1.2.3-beta.0
```

Pushing the tag triggers the `npm-publish-v1` pipeline, which builds the package and publishes it to AWS CodeArtifact.
Pushing the tag triggers two `npm-publish-v1` pipelines in parallel — one for `ads-core` and one for `ads-react` — which build each package and publish them to AWS CodeArtifact.

### 3. Publish to npm

After the pipeline completes, go to **Actions → Publish from CodeArtifact to npm** and trigger it manually with:
After both pipelines complete, the DK automatically triggers the corresponding GitHub Actions workflows:

- **version**: the full tag name (e.g. `@vtex/ads-core@0.5.2`)
- **CA_TOKEN** and **CA_OWNER**: provided by the pipeline run output
- **environment**: `production` (default) or `beta`
- **Actions → Publish ads-core to npm** (`publish-core.yml`)
- **Actions → Publish ads-react to npm** (`publish-react.yml`)

> **Prerequisite:** each package must have a [NPM Trusted Publisher](https://docs.npmjs.com/trusted-publishers) configured on npmjs.com pointing to this repo and the `publish-npm.yml` workflow. This is a one-time setup per package.
Each workflow reads the version from its own `package.json`, downloads the tarball from CodeArtifact, and publishes it to npmjs. The `CA_TOKEN` and `CA_OWNER` inputs are filled automatically by DK. You can also trigger them manually if needed.

> **Prerequisite:** each package must have a [NPM Trusted Publisher](https://docs.npmjs.com/trusted-publishers) configured on npmjs.com pointing to this repo — `publish-core.yml` for `@vtex/ads-core` and `publish-react.yml` for `@vtex/ads-react`. This is a one-time setup per package.
6 changes: 6 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @vtex/ads-react

## 0.5.2

### Patch Changes

- Version bump to sync with @vtex/ads-core@0.5.2

## 0.5.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@vtex/ads-react",
"type": "module",
"version": "0.5.1",
"version": "0.5.2",
"main": "dist/cjs/index.cjs.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
Expand Down
Loading