From da75e4b910842fe1c6701fc6d10f12c5d740aff9 Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Mon, 13 Dec 2021 09:50:19 +0100 Subject: [PATCH] Build: Publish canary packages to NPM registry (#42922) * ci(packages): replace canary github publishing with npm registry * chore(drone): refresh yaml config * docs(packages): remove github package publish explanation --- .drone.yml | 6 +++--- packages/README.md | 24 ----------------------- scripts/circle-release-canary-packages.sh | 7 +++---- scripts/drone/steps/lib.star | 2 +- 4 files changed, 7 insertions(+), 32 deletions(-) diff --git a/.drone.yml b/.drone.yml index 2b432381a58..025afc78891 100644 --- a/.drone.yml +++ b/.drone.yml @@ -765,8 +765,8 @@ steps: - end-to-end-tests-smoke-tests-suite - end-to-end-tests-various-suite environment: - GITHUB_PACKAGE_TOKEN: - from_secret: github_package_token + NPM_TOKEN: + from_secret: npm_token image: grafana/build-container:1.4.8 name: release-canary-npm-packages - commands: @@ -4109,6 +4109,6 @@ kind: secret name: prerelease_bucket --- kind: signature -hmac: b431c3bbdb4778dbed741bb5cd9840f106b4704280751dac4e145754f300a6ea +hmac: e84ccb068a1b18aa34aaee36b44d2372d6c97bac8becd42261661952ca847b0c ... diff --git a/packages/README.md b/packages/README.md index 8fe4b89b63e..2e0375ae6af 100644 --- a/packages/README.md +++ b/packages/README.md @@ -32,30 +32,6 @@ Every commit to main that has changes within the `packages` directory is a subje - ``` -Automatic prereleases are published under the `canary` dist tag to the [github package registry](https://docs.github.com/en/free-pro-team@latest/packages/publishing-and-managing-packages/about-github-packages). - -#### Consuming prereleases - -As mentioned above the `canary` releases are published to the Github package registry rather than the NPM registry. If you wish to make use of these prereleases please follow these steps: - -1. You must use a personal access token to install packages from Github. To create an access token [click here](https://github.com/settings/tokens) and create a token with the `read:packages` scope. Make a copy of the token. -2. Create / modify your `~/.npmrc` file with the following: - -``` -@grafana:registry=https://npm.pkg.github.com -//npm.pkg.github.com/:_authToken={INSERT_GH_TOKEN_HERE} -``` - -3. Update the package.json of your project to use either the `canary` channel or a version of the `canary` channel - -```json -// plugin's package.json -{ - ... - "@grafana/data": "canary" -} -``` - ### Manual release > All of the steps below must be performed on a release branch, according to Grafana Release Guide. diff --git a/scripts/circle-release-canary-packages.sh b/scripts/circle-release-canary-packages.sh index 882549d03f0..a0e739ff018 100755 --- a/scripts/circle-release-canary-packages.sh +++ b/scripts/circle-release-canary-packages.sh @@ -13,15 +13,14 @@ function prepare_version_commit () { # check if there were any changes to packages between current and previous commit count=$(git diff HEAD~1..HEAD --name-only -- packages | awk '{c++} END {print c}') -count="1" + if [ -z "$count" ]; then echo "No changes in packages, skipping packages publishing" else echo "Changes detected in ${count} packages" echo "Starting to release latest canary version" - echo "@grafana:registry=https://npm.pkg.github.com" >> ~/.npmrc - echo "//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGE_TOKEN}" >> ~/.npmrc + echo "//registry.npmjs.org/:_authToken=$${NPM_TOKEN}" >> ~/.npmrc # For some reason the --no-git-reset is not working as described so # to get lerna to publish the packages we need to do a commit to the @@ -29,6 +28,6 @@ else prepare_version_commit echo $'\nPublishing packages' - yarn packages:publishCanary --registry https://npm.pkg.github.com + yarn packages:publishCanary fi diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star index 6ede295f3bf..4af976ffd4d 100644 --- a/scripts/drone/steps/lib.star +++ b/scripts/drone/steps/lib.star @@ -909,7 +909,7 @@ def release_canary_npm_packages_step(edition): 'end-to-end-tests-various-suite', ], 'environment': { - 'GITHUB_PACKAGE_TOKEN': from_secret('github_package_token'), + 'NPM_TOKEN': from_secret('npm_token'), }, 'commands': [ './scripts/circle-release-canary-packages.sh',