1.0.9 • Published 6 months ago

pb-lib-deploy v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

PB Deploy Script

The PB Deploy Script (deploy.js) automates versioning and deployment across different environment stages: dev, test, accept, and live.

This script:

  • Generates semantic version numbers for each stage including a run number for the stages dev, test and accept.
  • Creates a Git tag with the new version number.
  • Commits and pushes the tag to Git.
  • Tracks version numbers in the version.js file, which is automatically created in your project's root.
  • Allows GitHub Actions to trigger workflows based on the pushed tag.

Note: This script assumes that the main branch is your development branch.


What the Deploy Script Does

  1. Creates version.js in the root of your project (if it doesn’t exist).
  2. Imports version.js and checks the current version number.
  3. Calculates a new version number (vX.Y.Z-env-XXX), e.g.,
    • v1.0.0-dev-001
    • v1.0.0-test-001
  4. Creates a new Git tag with the new version number.
  5. Commits and pushes the tag to Git.

Version bumps (patch, minor, major) can be applied at the test stage.
For major version bumps (breaking changes), it is recommended to use a new repository.


Installation

1. Local Installation (for use within a project)

npm install --save-dev pb-lib-deploy

Run it using:

npx deploy <environment>

2. Global Installation (for system-wide access)

npm install -g pb-lib-deploy

Run it using:

deploy <environment>

Setup

When first run, the script will generate a version.js file in your project's root with the following structure:

export default {
    "currentVersion": {
        "dev": "v0.0.0-dev-000",
        "test": "v0.0.0-test-000",
        "accept": "v0.0.0-accept-000",
        "live": "v0.0.0"
    },
    "history": []
};

Additionally, you should create Git branches for:

  • test
  • accept
  • live

Usage

To deploy, use the following format:

npx deploy <environment>

or (if installed globally):

deploy <environment>

Available Environments:

  • dev
  • test
  • accept
  • live

Example Commands

1. Deploy to dev

npx deploy dev

2. Deploy to test with a patch version bump

npx deploy test patch

3. Deploy to accept

npx deploy accept

4. Deploy to live

npx deploy live

Versioning Notes

  • dev stage: Always uses the latest commit.
  • test stage: Supports patch, minor, and major version bumps.
  • accept and live stages: Promote versions from test when they are stable.
  • Major version bumps: Consider creating a new repository.

Final Notes

  • Make sure you are on the main branch before running the script.
  • The script will fail if uncommitted changes exist.
  • Git tags created by this script can trigger GitHub Actions workflows.

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago