All Projects → technote-space → package-version-check-action

technote-space / package-version-check-action

Licence: MIT license
GitHub Actions to check package version before publish

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to package-version-check-action

k8s-create-secret
GitHub Action to create Kubernetes cluster secrets
Stars: ✭ 24 (-20%)
Mutual labels:  github-actions
git-tag-action
[GitHub Action] Get ${version} from package.json and git tag ${version} for the repository.
Stars: ✭ 26 (-13.33%)
Mutual labels:  github-actions
labeler
GitHub Action to assign labels to PRs based on configurable conditions
Stars: ✭ 47 (+56.67%)
Mutual labels:  github-actions
setup-action
▶️ GitHub Action using Coursier to install JVM and Scala tools
Stars: ✭ 30 (+0%)
Mutual labels:  github-actions
verify-changed-files
Github action to verify file changes that occur during the workflow execution.
Stars: ✭ 62 (+106.67%)
Mutual labels:  github-actions
github-action
CLA Assistant GitHub Action
Stars: ✭ 165 (+450%)
Mutual labels:  github-actions
googlejavaformat-action
GitHub Action that formats Java files following Google Style guidelines
Stars: ✭ 66 (+120%)
Mutual labels:  github-actions
Github-Android-Action
Android Github Action that builds Android project, runs unit tests and generates debug APK, builds for Github Actions hackathon
Stars: ✭ 29 (-3.33%)
Mutual labels:  github-actions
starter-reactnative-nestjs-mysql
Starter mobile ReactNative NestJS MySQL with continuous integration and AWS deployment
Stars: ✭ 16 (-46.67%)
Mutual labels:  github-actions
html5validator-action
GitHub Action that checks HTML5 syntax.
Stars: ✭ 27 (-10%)
Mutual labels:  github-actions
setup-unity
GitHub Action to download and install Unity on Ubuntu, macOS or Windows. Based on Unity Hub
Stars: ✭ 26 (-13.33%)
Mutual labels:  github-actions
shell-linter
A Github Action for ShellCheck
Stars: ✭ 58 (+93.33%)
Mutual labels:  github-actions
mysql-action
GitHub Action to setup a MySQL database
Stars: ✭ 105 (+250%)
Mutual labels:  github-actions
HelloActions-Qt
Qt use github-actions(Qt项目使用github的持续集成)
Stars: ✭ 103 (+243.33%)
Mutual labels:  github-actions
github-stats-box
📌 Update a gist to contain your GitHub stats
Stars: ✭ 72 (+140%)
Mutual labels:  github-actions
postcss-prefixwrap
A PostCSS plugin that is used to wrap css styles with a css selector to constrain their affect on parent elements in a page.
Stars: ✭ 54 (+80%)
Mutual labels:  github-actions
check-spelling
Spelling checker action
Stars: ✭ 139 (+363.33%)
Mutual labels:  github-actions
actions
GitHub Actions for R-hub
Stars: ✭ 18 (-40%)
Mutual labels:  github-actions
releasezri
Meaningful and minimalist release notes for developers
Stars: ✭ 25 (-16.67%)
Mutual labels:  github-actions
danger-action
Execute danger action for GitHub Actions.
Stars: ✭ 24 (-20%)
Mutual labels:  github-actions

Package Version Check Action

CI Status codecov CodeFactor License: MIT

Read this in other languages: English, 日本語.

This is a GitHub Actions to check package version before publish npm.

Table of Contents

Details

Screenshots

  1. Running GitHub Action

    Running

  2. Updated version of package.json and commit (if branch is not protected)

    Updated

Usage

Use when push

e.g. .github/workflows/check_version.yml

on: push
name: Check package version
jobs:
  checkVersion:
    name: Check package version
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      # Use this GitHub Action
      - name: Check package version
        uses: technote-space/package-version-check-action@v1
        with:
          BRANCH_PREFIX: release/

Use in the release process

e.g. .github/workflows/release.yml

on:
 push:
   tags:
     - 'v*'
name: Publish Package
jobs:
  release:
    name: Publish Package
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      # Use this GitHub Action
      - name: Check package version
        uses: technote-space/package-version-check-action@v1
        with:
          COMMIT_DISABLED: 1

      - name: Install Package dependencies
        run: yarn install
      - name: Build
        run: yarn build
      - name: Publish
        run: |
          npm config set //registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN
          npm publish
        env:
          NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

More details of target event

Options

BRANCH_PREFIX

Branch name prefix.
default: ''
e.g. release/

COMMIT_DISABLED

Whether commit is disabled.
default: ''

COMMIT_MESSAGE

Commit message of update package version commit.
default: 'feat: update package version'

PACKAGE_NAME

Package file name.
default: 'package.json'

PACKAGE_DIR

Package directory.
default: ''

TEST_TAG_PREFIX

Prefix for test tag.
default: ''
e.g. 'test/'

NEXT_VERSION

Specify next version.
default: ''
e.g. 'v1.2.3'

Action event details

Target events

eventName: action condition
push: * condition1
release: published condition1
pull_request, pull_request_target: opened, reopened, synchronize condition2
created: * condition3

Conditions

condition1

  • tags
    • semantic versioning tag (e.g. v1.2.3)
  • branches
    • ${BRANCH_PREFIX}${tag}
      • tag: semantic versioning tag (e.g. v1.2.3)
      • e.g. branch: release/v1.2.3

condition2

  • branches
    • ${BRANCH_PREFIX}${tag}
      • tag: semantic versioning tag (e.g. v1.2.3)
      • e.g. branch: release/v1.2.3

condition3

  • tags
    • semantic versioning tag (e.g. v1.2.3)

Motivation

If you forget to update the package.json version, publishing the npm package will fail.

Failed

If you are invoking an action by pushing a tag, you have to do following steps again.

  1. Delete pushed tag
  2. Update package.json version
  3. Commit and tag again
  4. Push

This is very troublesome.

This GitHub Action updates the version in package.json based on the tag name automatically.
So you don't have to worry about the version in package.json.

This action also commits the change if the branch is not protected.
If the branch is protected, this action just update the version in package.json.

Not commit

Addition

Commit

Commit is valid when pushing to default branch with tag or branch starting with ${BRANCH_PREFIX}.

The GITHUB_TOKEN that is provided as a part of GitHub Actions doesn't have authorization to create any successive events.
So it won't spawn actions which triggered by push.

GITHUB_TOKEN

This can be a problem if you have branch protection configured.

If you want to trigger actions, use a personal access token instead.

  1. Generate a personal access token with the public_repo or repo scope.
    (repo is required for private repositories).
  2. Save as ACCESS_TOKEN
  3. Add input to use ACCESS_TOKEN instead of GITHUB_TOKEN.
    e.g. .github/workflows/check_version.yml
    on: push
    name: Check package version
    jobs:
      checkVersion:
        name: Check package version
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v2
    
          # Use this GitHub Action
          - name: Check package version
            uses: technote-space/package-version-check-action@v1
            with:
              GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
              BRANCH_PREFIX: release/

ACCESS_TOKEN

Tags

Tag name format must be Semantic Versioning.

Example repositories using this Action

Author

GitHub (Technote)
Blog

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].