GitHub Action
Autobump version and publish
This GitHub Action intends to manage the versioning of npm packages via auto-bumping, auto-alpha-publishing & auto-releasing.
This GA allows to easily install and test npm packages as they’ll be automatically published to npm as an alpha release at the moment of creating a Pull Request on GitHub.
All consecutive commits pushed will be published aswell, handling automatically the versioning of each.
-
On open PR (poiting to
/master
), the GA will make sure to bump the package.json to the required version based on the label set on the PR [major, minor, patch]. In addition, the package will be published to NPM as an alpha release (-alpha.X).* -
On push commit (poiting to
/master
), the GA will make sure to bump the alpha release & publish a new version to NPM.* ** -
On post-merge (poiting to
/master
), the GA will publish the package as the @latest release.
* Steps require to setup actions/checkout@v2
using own PAT in order to re-trigger workflows. If using the default ${{secrets.GITHUB_TOKEN}
, workflows will be omitted.
The package.json
version is always bumped accordingly to the latest published version on NPM, and for instance, it will auto-bump in the case of multiple PR's opened at the same time with the same version release type.
#!/bin/bash
on:
pull_request:
branches:
- master
types: [opened]
...
...
...
- name: Autobump & Publish
uses: hedia-team/autobump-and-publish@master
with:
label: ${{ toJson(github.event.pull_request.labels.*.name) }}
npm-token: ${{ env.NPM_TOKEN }}
issue-number: ${{ github.event.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}
#!/bin/bash
on:
pull_request:
branches:
- master
types: [synchronize]
...
...
...
- uses: mstachniuk/ci-skip@v1
with:
commit-filter: "autobump"
- name: Autobump & Publish
if: ${{ env.CI_SKIP == 'false' }}
uses: hedia-team/autobump-and-publish@master
with:
label: ${{ toJson(github.event.pull_request.labels.*.name) }}
npm-token: ${{ env.NPM_TOKEN }}
issue-number: ${{ github.event.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}
#!/bin/bash
on:
pull_request:
branches:
- master
types: [closed]
...
...
...
- name: Autobump & Publish
uses: hedia-team/autobump-and-publish@master
with:
npm-token: ${{ env.NPM_TOKEN }}
issue-number: ${{ github.event.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}
is-post-merge: true
Name | Type | Required? | Default | Description |
---|---|---|---|---|
github-token | string | true | GitHub token required by izhangzhihao/delete-comment to remove comment from PR | |
npm-token | string | true | NPM token required to publish package to npm | |
issue-number | number/string | true | Issue number required by peter-evans/create-or-update-comment & izhangzhihao/delete-comment in order to write/remove comments on the current PR | |
label | GitHub PR label (string) | On open / On push | Type of version bump [major, minor, patch] (required on Open PR / On Push) | |
is-post-merge | boolean | false | false | Boolean used to publish package as release on NPM if action is being triggered by post-merging the PR |
run-ci | boolean | false | false | Value used to determine if npm run ci shall run |
run-lint | boolean | false | false | Value used to determine if npm run lint shall run |
run-lint-pkg | boolean | false | false | Value used to determine if npm run lint-pkg shall run |
run-test | boolean | false | false | Value used to determine if npm run test shall run |
run-test-coverage | boolean | false | false | Value used to determine if npm run test-coverage shall run |
run-tsc | boolean | false | false | Value used to determine if npm run tsc shall run |
The associated scripts and documentation in this project are released under the MIT License.
GitHub are registered trademarks of GitHub, Inc. GitHub name used in this project are for identification purposes only. The project is not associated in any way with GitHub Inc. and is not an official solution of GitHub Inc. It was made available in order to facilitate the use of the site GitHub.
-
izhangzhihao/delete-comment, published by MIT License
-
peter-evans/create-or-update-comment, published by MIT License
-
mstachniuk/ci-ski, published by MIT License