-
Notifications
You must be signed in to change notification settings - Fork 66
[chores] Add process for first-time package publishing #2055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
bcb6367
3a0e179
af0ad1d
ef19812
0f96c7e
59955fe
1b58d6f
b5b1f58
0d10074
4880c9c
d91da28
f77411e
67e4e19
918c36f
d02698b
ea53ee5
aefdd28
cb9e936
251d8d4
9c59805
4b54a3a
b3158ff
c2adc0d
1dfd4e4
ada3efa
7ad9a71
1256623
573c719
48d387f
af78369
55cc372
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ on: | |
| - v* # Any version tag | ||
|
|
||
| permissions: | ||
| id-token: write # To publish on NPM with provenance and to federate tokens | ||
| id-token: write # For OIDC publishing with provenance and to federate tokens | ||
| contents: write # Required for the draft release | ||
|
|
||
| jobs: | ||
|
|
@@ -258,11 +258,11 @@ jobs: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | ||
| - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 | ||
| with: | ||
| node-version: 24.11.1 # Version supporting OIDC | ||
| registry-url: "https://registry.npmjs.org" | ||
| node-version: '24' # Needed for OIDC publishing | ||
| registry-url: 'https://registry.npmjs.org' | ||
|
Comment on lines
+280
to
+281
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just cosmetic changes to follow https://docs.npmjs.com/trusted-publishers#automatic-provenance-generation more closely. |
||
| - run: yarn install --immutable | ||
| - run: yarn build | ||
| - run: yarn publish:all | ||
| - run: yarn publish:all --provenance | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reintroduced
|
||
|
|
||
| bump-ci-integrations: | ||
| name: Bump datadog-ci in integration | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| DRY_RUN=false | ||
| SCOPE="" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| --dry-run) | ||
| DRY_RUN=true | ||
| shift | ||
| ;; | ||
| -*) | ||
| echo "Unknown option: $1" | ||
| echo "Usage: $0 [--dry-run] <scope>" | ||
| exit 1 | ||
| ;; | ||
| *) | ||
| SCOPE="$1" | ||
| shift | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [ -z "$SCOPE" ]; then | ||
| echo "Usage: $0 [--dry-run] <scope>" | ||
| exit 1 | ||
| fi | ||
| PLUGIN_PKG="@datadog/datadog-ci-plugin-$SCOPE" | ||
| PLUGIN_DIR="packages/plugin-$SCOPE" | ||
|
|
||
| if [ -d "$PLUGIN_DIR" ]; then | ||
| echo "Plugin directory $PLUGIN_DIR already exists!" | ||
| echo "This script should only be run once per scope, before migrate.sh" | ||
| exit 1 | ||
| fi | ||
|
|
||
| BOLD='\033[1m' | ||
| GREEN='\033[0;32m' | ||
| BLUE='\033[0;34m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| echo -e "This script will initialize and publish an empty package for ${BLUE}${BOLD}$PLUGIN_PKG${NC}" | ||
| echo | ||
| echo -e "${BOLD}Please follow the instructions${NC} at ${BLUE}https://datadoghq.atlassian.net/wiki/x/QYDRaQE${NC} before running this script." | ||
| echo | ||
|
|
||
| read -rsp "Enter your NPM auth token: " INIT_NPM_AUTH_TOKEN | ||
| echo | ||
| if [ -z "$INIT_NPM_AUTH_TOKEN" ]; then | ||
| echo "Error: NPM auth token cannot be empty" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Export this for subsequent yarn commands in the script | ||
| export INIT_NPM_AUTH_TOKEN | ||
|
|
||
| # Do not hardcode the token in .yarnrc.yml, it will be read from the environment variable | ||
| yarn config set npmAuthToken '${INIT_NPM_AUTH_TOKEN}' | ||
| echo | ||
|
|
||
| echo "1. Creating plugin directory structure" | ||
| mkdir -p "$PLUGIN_DIR" | ||
| env cp LICENSE "$PLUGIN_DIR" | ||
| echo "Empty package" > "$PLUGIN_DIR/README.md" | ||
| cat > "$PLUGIN_DIR/package.json" <<EOF | ||
| { | ||
| "name": "$PLUGIN_PKG", | ||
| "version": "0.0.1", | ||
| "description": "Datadog CI plugin for \`$SCOPE\` commands", | ||
| "license": "Apache-2.0", | ||
| "keywords": [ | ||
| "datadog", | ||
| "datadog-ci", | ||
| "plugin" | ||
| ], | ||
| "homepage": "https://github.com/DataDog/datadog-ci/tree/master/$PLUGIN_DIR", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/DataDog/datadog-ci.git", | ||
| "directory": "$PLUGIN_DIR" | ||
| }, | ||
| "exports": { | ||
| "./package.json": "./package.json", | ||
| "./commands/*": { | ||
| "development": "./src/commands/*.ts", | ||
| "default": "./dist/commands/*.js" | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist/**/*", | ||
| "README", | ||
| "LICENSE" | ||
| ], | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "scripts": { | ||
| "build": "yarn package:clean; yarn package:build", | ||
| "lint": "yarn package:lint", | ||
| "prepack": "yarn package:clean-dist" | ||
| }, | ||
| "peerDependencies": { | ||
| "@datadog/datadog-ci-base": "workspace:*" | ||
| } | ||
| } | ||
| EOF | ||
|
|
||
| echo "2. Publishing empty package to npm" | ||
| echo | ||
| yarn | ||
| if [ "$DRY_RUN" = true ]; then | ||
| yarn workspace "$PLUGIN_PKG" npm publish --dry-run | ||
| else | ||
| yarn workspace "$PLUGIN_PKG" npm publish | ||
| fi | ||
|
|
||
| echo | ||
| echo "3. Cleaning up" | ||
| yarn config unset npmAuthToken | ||
|
|
||
| echo | ||
| if [ "$DRY_RUN" = true ]; then | ||
| echo -e "${GREEN}[DRY-RUN] Would have published ${BOLD}$PLUGIN_PKG@0.0.1${NC}${NC}" | ||
| else | ||
| echo -e "${GREEN}Successfully published ${BOLD}$PLUGIN_PKG@0.0.1${NC}${NC}" | ||
| fi | ||
|
|
||
| echo | ||
| echo -e "If needed, you can now run: ${BLUE}bin/migrate.sh $SCOPE${NC}" |

Uh oh!
There was an error while loading. Please reload this page.