Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from nytimes/move-to-artifactory
Browse files Browse the repository at this point in the history
Add drone file for artifactory publish
  • Loading branch information
adamdabbracci committed May 28, 2024
2 parents 4982041 + 6f54c0c commit 25c8d11
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
kind: secret
name: artifactory_access_token
get:
path: artifactory-token?scope=artifactory-dv
---
kind: pipeline
type: docker
name: publish-packages

trigger:
event:
- push
branch:
- main

steps:
- name: setup-and-check
image: node:18-alpine
environment:
ACCESS_TOKEN:
from_secret: artifactory_access_token
commands:
- apk add -q --no-cache curl jq
- |
# retrieve artifactory's generated npm config
curl --location --silent --header "Authorization: Bearer $${ACCESS_TOKEN}" "https://nytimes.pe.jfrog.io/artifactory/api/npm/dv-backstage-plugins-npm-local/auth/nyt" > .npmrc
# this returns something like:
# @nyt:registry=https://nytimes.pe.jfrog.io/artifactory/api/npm/dv-backstage-plugins-npm-local/
# //nytimes.pe.jfrog.io/artifactory/api/npm/dv-backstage-plugins-npm-local/:_password=base64encoded($jwt)
# //nytimes.pe.jfrog.io/artifactory/api/npm/dv-backstage-plugins-npm-local/:username=vault-artifactory-internal-prd
# //nytimes.pe.jfrog.io/artifactory/api/npm/dv-backstage-plugins-npm-local/:email=ENTER_YOUR_EMAIL_HERE
# //nytimes.pe.jfrog.io/artifactory/api/npm/dv-backstage-plugins-npm-local/:always-auth=true
- |
for dir in ./plugins/*/; do
if [ -d "$dir" ]; then
cd "$dir"
PLUGIN_VERSION=$(cat package.json | jq '.version')
EXISTS=$(npm view "@nyt/$(basename "$dir")" versions --json | jq "any(.[]; select(. == $PLUGIN_VERSION))")
if [ "$EXISTS" = "false" ]; then
echo "need to publish version"
exit 0
fi
cd -
fi
done
echo "every package's version is already published"
exit 78
- name: install-dependencies
image: node:18-alpine
commands:
- mv yarn.lock.dist yarn.lock
- yarn -v
- node -v
- yarn cache clean
- yarn install --check-cache

- name: publish-release-artifact
image: node:18-alpine
commands:
- yarn tsc
- apk add -q --no-cache jq
- |
for dir in plugins/*/; do
if [ -d "$dir" ]; then
cd "$dir"
PLUGIN_VERSION=$(cat package.json | jq '.version')
EXISTS=$(npm view "@nyt/$(basename "$dir")" versions --json | jq "any(.[]; select(. == $PLUGIN_VERSION))")
if [ "$EXISTS" == "false" ]; then
npm run build
npm publish
fi
cd -
fi
done
- name: slack
image: plugins/slack
settings:
webhook:
from_secret: slack_webhook
channel: dv-reliability-engineering-alerts
username: nytimes/nebula-backstage-plugins (publish)
template: >
{{#success build.status}}
:rocket: <{{build.link}}{{build.number}}|> ({{truncate build.commit 8}}) ${DRONE_TAG} publish succeeded!
{{else}}
:mega: <{{build.link}}|{{build.number}}> ({{truncate build.commit 8}}) ${DRONE_TAG} publish failed!
{{/success}}
when:
status:
- success
- failure

0 comments on commit 25c8d11

Please sign in to comment.