Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Scripts for npm standard version updates w/ node repositories

License

Notifications You must be signed in to change notification settings

ibm-developer/standard-npm-devops

Repository files navigation

standard-npm-devops

Scripts for npm standard version updates w/ node repositories.

Setting Up Github Bot User

Create Personal Access Token

  1. Skip this step if a github token is already available.
  2. Go to https://github.com/settings/tokens/new while logged in to the Bot User.
  3. Set a reasonable and recognizable Token description.
  4. Check public_repo under Select scopes.
  5. Generate token.
  6. Copy the token highlighted with green background before it disappears.
  7. Paste the token somewhere safe but readable.

Make Bot User Admin

  1. Navigate to the repository for the npm package requiring devOps.
  2. Add Bot User as an Admin.

Setting Up NPM Bot User

Create Access Token

  1. Skip if NPM token is already available.
  2. Log into NPM registry as bot user.
  3. Click profile avatar, then click Tokens
  4. Click Create New Token
  5. Select Read and Publish then Create Token
  6. Copy the token in box before it disappears.
  7. Paste the token somewhere safe but readable.

Setting Up Travis Application

Migrate Travis Integration to Github Application

  1. Follow instructions on Travis

First-time Travis Application

  1. Login to Org owner account
  2. Go to https://github.com/marketplace/travis-ci#pricing-and-setup
  3. Choose Open Source
  4. Click Install it for free
  5. Click Complete order and begin installation
  6. Decide whether to pick and choose or include all repositories.

Setting Up Coveralls Application

Repository Setup

Setting Up Repository in Travis

  1. Go to Settings
  2. Add GITHUB_TOKEN and NPM_TOKEN as environment variables
  3. Turn on Auto cancel pull request builds
  4. For Github Enterprise, Add ssh key for bot user

Setting Up Merge Style

  1. Navigate to Settings/Options
  2. DO NOT check Allow squash merging
  3. DO NOT check Allow rebase merging

Setting Up Branch Protection

  1. Default Branch: develop
  2. Branch protection rules: master
    • Require pull request reviews before merging
    • Require status checks to pass before merging
    • Status checks found in the last week for this repository: list shows up after first run
    • Require branches to be up to date before merging
    • Include administrators
  3. Branch protection rules: develop
    • Require pull request reviews before merging
    • Require status checks to pass before merging
    • Status checks found in the last week for this repository: list shows up after first run
      • DO NOT require Travis CI - Branch
    • Require branches to be up to date before merging
    • DO NOT: Include administrators

Setting Up Repository for Travis

  1. Add a .travis.yml with following information
    language: node_js
    node_js:
    - '8'
    before_install:
    - npm i -g makeshift && makeshift -r https://registry.npmjs.org
    - npm i -g standard-version
    before_script:
    - cd /tmp
    - wget https://github.com/github/hub/releases/download/v2.5.1/hub-linux-386-2.5.1.tgz
    - tar -xvzf hub-linux-386-2.5.1.tgz
    - mv hub-linux-386-2.5.1 hub
    - export PATH=${PATH}:/tmp/hub/bin
    - git clone -b master https://github.com/ibm-developer/standard-npm-devops.git
    - cd -
    script: npm test && npm run coveralls && /tmp/standard-npm-devops/do_devops.sh
    branches:
      only:
      - master
      - develop
    env:
      - DEV_BRANCH=develop PROD_BRANCH=master DEVOPS_SCRIPT_DIR="/tmp/standard-npm-devops"
    

Slack Notification Setup

Travis CI Notification

  1. Log into a Bot Account on Slack
  2. Select Customize Slack under the desired workspace
  3. Select Configure Apps
  4. Add a Travis CI configuration
  5. Follow the instructions for Encrypting your credentials

Changelog Notification

  1. Find Incoming Hooks under Custom Integrations
  2. Copy Webhook URL and add a environment variable in Travis called SLACK_WEBHOOK
  3. Add the following in .travis.yml
    • Under before_install
      - npm i -g markdown-to-html
      
    • Under before_script
      - git clone -b master https://github.com/ibm-developer/changelog-generator-slack-notification.git
      - npm install changelog-generator-slack-notification
      
    • Under env: add to first entry SLACK_NOTIFICATION_PATH="/tmp/changelog-generator-slack-notification" so it becomes:
      - DEV_BRANCH=develop PROD_BRANCH=master DEVOPS_SCRIPT_DIR="/tmp/standard-npm-devops" SLACK_NOTIFICATION_PATH="/tmp/changelog-generator-slack-notification"
      

Operations

Pull Request to develop

  1. Make sure commits follows conventional commits standards. Merge commits are ok.
  2. Make sure merging branch is in sync with develop
  3. Make sure there are no open Pull Request from develop to master

Pull Request to master

  1. Make sure to Pull Request from develop
  2. Pull Request from other branches are tolerable in emergencies, but will result in develop branch needing admin intervention to sync.
  3. Make sure there is at least one new commit that follows conventional commits standards.
  4. Build will attempt to sync master and create a version release commit.

Publishing

  1. master branch build will push new version tag to Github
  2. master branch build will publish new version to NPM

About

Scripts for npm standard version updates w/ node repositories

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published