Skip to content

Commit

Permalink
Create GitHub action to publish npm package (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
lym953 authored Nov 7, 2024
1 parent acb24fe commit be89d98
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish packages on NPM
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "18.x"
- run: yarn config set npmAuthToken $NPM_PUBLISH_TOKEN
env:
NPM_PUBLISH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
- run: yarn
- run: yarn build
- run: yarn publish

notify:
runs-on: ubuntu-latest
needs: build
steps:
- name: Send success message to Slack
env:
SLACK_CHANNEL: "#serverless-onboarding-and-enablement-ops"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
if: success()
run: |
set -x
OPS_MESSAGE=":gh-check-passed: serverless-plugin-datadog NPM publish succeeded!"
curl -H "Content-type: application/json" -X POST "$SLACK_WEBHOOK" -d '{
"channel": "'"$SLACK_CHANNEL"'",
"text": "'"$OPS_MESSAGE"'"
}'
- name: Send failure message to Slack
env:
SLACK_CHANNEL: "#serverless-onboarding-and-enablement-ops"
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
if: failure()
run: |
set -x
OPS_MESSAGE=":gh-check-passed: serverless-plugin-datadog NPM publish failed!
Please check GitHub Action log: https://github.com/DataDog/serverless-plugin-datadog/actions/workflows/publish.yml"
curl -H "Content-type: application/json" -X POST "$SLACK_WEBHOOK" -d '{
"channel": "'"$SLACK_CHANNEL"'",
"text": "'"$OPS_MESSAGE"'"
9 changes: 1 addition & 8 deletions scripts/publish_prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ if [ "$UPDATE_LAYERS" != "false" ]; then
fi
fi

# Verify NPM access before updating layer arns (slow)
yarn login

if [ "$UPDATE_LAYERS" != "false" ]; then
aws-vault exec sso-govcloud-us1-fed-engineering -- aws sts get-caller-identity
aws-vault exec sso-prod-engineering -- aws sts get-caller-identity
Expand All @@ -92,17 +89,13 @@ echo
echo "Bumping the version number and committing the changes"
yarn version --new-version "$VERSION"

echo
echo 'Publishing to npm'
yarn
yarn build
yarn publish --new-version "$VERSION"

echo
echo 'Pushing updates to GitHub'
git push origin main
git push origin "refs/tags/v$VERSION"

echo
echo "DONE! Please create a new release using the link below."
echo "DONE! Please create a new release using the link below. It will trigger a GitHub action to publish to npm."
echo "https://github.com/DataDog/serverless-plugin-datadog/releases/new?tag=v$VERSION&title=v$VERSION"

0 comments on commit be89d98

Please sign in to comment.