Skip to content

Commit 4ecad57

Browse files
committed
feat: Various fixes and features (See below)
- fix: Double 'https://' when using a custom registry URL, i.e. for GitHub packages - fix: Remove redundant `git push remote --tags` command in `entrypoint.sh` - docs: Update readme - feat: Add support for a custom list of tags that trigger a major version update - feat: Add support for a custom list of tags that trigger a minor version update - feat: Add an option to disable the git tagging feature - feat: Add a hidden debug option to enable more logging at runtime - feat: Add support for the GitHub Actions inputs (enable using `with` instead of `env`); while keeping backward-compatibility for `env` users - feat: Update node dependencies in `package.json` - feat: Update docker container to use node v20 - feat: Omit the dev dependencies in the docker image - feat: Drop unused `yargs` dependency - feat: Switch `merge-release-run.js` to an ESM module - chore: Put the license text into the `LICENSE` file - chore: Move `package.json` from src to the root of the repo - chore: Setup eslint and remove standard - chore: Added the `.prettierrc` config file - chore: Various cleanup in `entrypoint.sh` - chore: Various cleanup in `merge-release-run.js`
1 parent 22d66d3 commit 4ecad57

14 files changed

+1485
-3442
lines changed

.all-contributorsrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@
4242
"contributions": [
4343
"code"
4444
]
45+
},
46+
{
47+
"login": "glitch452",
48+
"name": "David Dearden",
49+
"avatar_url": "https://avatars.githubusercontent.com/u/894128?v=4",
50+
"profile": "https://github.com/glitch452",
51+
"contributions": [
52+
"code",
53+
"doc"
54+
]
4555
}
4656
],
4757
"contributorsPerLine": 7,

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@
44
!./README.md
55
!./entrypoint.sh
66
!./src
7-
!./src/*
7+
!./src/*
8+
!./package.json
9+
!./package-lock.json

.github/workflows/release.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: Build, Test and maybe Publish
2+
23
on:
34
push:
45
branches:
56
- main
67
pull_request:
8+
79
jobs:
810
test:
911
name: Build & Test
@@ -13,11 +15,12 @@ jobs:
1315
- uses: actions/setup-node@v3
1416
with:
1517
cache: npm
16-
cache-dependency-path: src/package-lock.json
18+
cache-dependency-path: package-lock.json
1719
- name: Build
18-
run: cd src && npm install
20+
run: npm install
1921
- name: Test
20-
run: cd src && npm test
22+
run: npm test
23+
2124
publish:
2225
name: Publish
2326
needs: test
@@ -28,15 +31,15 @@ jobs:
2831
- uses: actions/setup-node@v3
2932
with:
3033
cache: npm
31-
cache-dependency-path: src/package-lock.json
34+
cache-dependency-path: package-lock.json
3235
- name: Build
33-
run: cd src && npm install
36+
run: npm install
3437
- name: Test
35-
run: cd src && npm test
38+
run: npm test
3639
- name: Publish
3740
uses: github-actions-community/merge-release@main
3841
env:
39-
DEPLOY_DIR: src
40-
SRC_PACKAGE_DIR: src
42+
DEPLOY_DIR: .
43+
SRC_PACKAGE_DIR: .
4144
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4245
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"jsxSingleQuote": false,
5+
"printWidth": 120,
6+
"quoteProps": "as-needed",
7+
"semi": true,
8+
"singleQuote": true,
9+
"tabWidth": 2,
10+
"trailingComma": "all"
11+
}

Dockerfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18-slim
1+
FROM node:20-slim
22

33
LABEL version="1.0.0"
44
LABEL repository="http://github.com/Github-Actions-Community/merge-release"
@@ -10,12 +10,16 @@ LABEL com.github.actions.description="Release npm package based on commit metada
1010
LABEL com.github.actions.icon="package"
1111
LABEL com.github.actions.color="red"
1212

13-
RUN apt-get update && apt-get -y --no-install-recommends install git jq findutils curl ca-certificates && rm -rf /var/lib/apt/lists/*
13+
RUN apt-get -y update && \
14+
apt-get -y --no-install-recommends install git jq findutils curl ca-certificates && \
15+
rm -rf /var/lib/apt/lists/* && \
16+
npm update -g npm
1417

15-
COPY . .
18+
WORKDIR /usr/app
19+
COPY ./ ./
1620

1721
# Install dependencies here
18-
RUN cd src && npm i
22+
RUN npm ci --omit dev
1923

20-
ENTRYPOINT ["/entrypoint.sh"]
24+
ENTRYPOINT ["/usr/app/entrypoint.sh"]
2125
CMD ["help"]

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ISC License
2+
3+
Copyright 2024 Github-Actions-Community
4+
5+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

README.md

Lines changed: 55 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,84 @@
11
# ![LogoMakr-2ULBLV](https://github.com/Github-Actions-Community/merge-release/assets/3071208/bb7d9b4c-04bd-41c5-9c08-0ee5c91fa4a1)
22

33
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4+
45
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors-)
6+
57
<!-- ALL-CONTRIBUTORS-BADGE:END -->
68

79
GitHub Action for automated npm publishing.
810

9-
This Action publishes a package to npm. It is meant to be used on every successful merge to main but
11+
This Action publishes a package to npm. It is meant to be used on every successful merge to main but
1012
you'll need to configure that workflow yourself. You can look to the
1113
[`.github/workflows/push.yml`](./.github/workflows/release.yml) file in this project as an example.
1214

1315
### Workflow
1416

15-
* Check for the latest version number published to npm.
16-
* Lookup all commits between the git commit that triggered the action and the latest publish.
17-
* If the package hasn't been published or the prior publish does not include a git hash, we'll
18-
only pull the commit data that triggered the action.
19-
* Based on the commit messages, increment the version from the lastest release.
20-
* If the strings "BREAKING CHANGE" or "!:" are found anywhere in any of the commit messages or descriptions the major
21-
version will be incremented.
22-
* If a commit message begins with the string "feat" then the minor version will be increased. This works
23-
for most common commit metadata for feature additions: `"feat: new API"` and `"feature: new API"`.
24-
* All other changes will increment the patch version.
25-
* Publish to npm using the configured token.
26-
* Push a tag for the new version to GitHub.
27-
17+
- Check for the latest version number published to npm.
18+
- Lookup all commits between the git commit that triggered the action and the latest publish.
19+
- Note: The package needs to have an initial publish in order to pull the package details.
20+
- Based on the commit messages, increment the version from the latest release.
21+
- If the strings "BREAKING CHANGE" is found anywhere in any of the commit messages, or "!:" is found in the first line or a commit message starts with one of the provided major tags (optional), then the major version will be incremented.
22+
- If a commit message begins with the string "feat" (or a tag in the minor tags list) then the minor version will be increased. This works for most common commit metadata for feature additions: `"feat: new API"` and `"feature: new API"`.
23+
- All other changes will increment the patch version.
24+
- Publish to npm (or the provided registry url) using the configured token.
25+
- Push a tag for the new version to GitHub.
2826

2927
### Configuration
3028

3129
You can configure some aspects of merge-release action by passing some environmental variables.
3230

33-
* **GITHUB_TOKEN (required)**
34-
* Github token to allow tagging the version.
35-
* **NPM_AUTH_TOKEN (required)**
36-
* NPM Auth Token to publish to NPM, read [here](https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) how to setup it as a secret.
37-
* **DEPLOY_DIR**
38-
* The path where the dist `package.json` is to run npm publish. Defaults to the root dir.
39-
* **SRC_PACKAGE_DIR**
40-
* The path where the src package.json is found. Defaults to the root dir.
41-
* **NPM_REGISTRY_URL**
42-
* NPM Registry URL to use. defaults to: `https://registry.npmjs.org/`
43-
* **NPM_PRIVATE**
44-
* If you wish privately publish your package please ensure you have set this to `true`
45-
46-
`merge-release` will use `npm publish` unless you've defined a `publish` script in your `package.json`.
31+
- **GITHUB_TOKEN (required)**
32+
- Github token to allow tagging the version.
33+
- **NPM_AUTH_TOKEN (required)**
34+
- NPM Auth Token to publish to the registry, read [here](https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) how to setup it as a secret.
35+
- **DEPLOY_DIR**
36+
- The path where the dist `package.json` is to run npm publish. Defaults to the root dir. This is a relative file path, relative to the root of the repo.
37+
- **SRC_PACKAGE_DIR**
38+
- The path where the src `package.json` is found. Defaults to the root dir. This is a relative file path, relative to the root of the repo.
39+
- **NPM_REGISTRY_URL**
40+
- NPM Registry URL to use. defaults to: `https://registry.npmjs.org/`. Set it to `https://npm.pkg.github.com` for GitHub Packages.
41+
- **NPM_PRIVATE**
42+
- If you wish privately publish your package please ensure you have set this to `true`
43+
- **DISABLE_GIT_TAG**
44+
- If you wish skip setting the git tag, set this to `true`
45+
- **MAJOR_TAGS**
46+
- A list of tags to check for when considering whether to perform a major version update. The value is a list separated by the `|` character. i.e. `major|my-major-tag`
47+
- **MINOR_TAGS**
48+
- Override the list of tags to check for when considering whether to perform a minor version update. The value is a list separated by the `|` character. i.e. `feat|minor|my-minor-tag`
49+
50+
`merge-release` will use `npm publish` by default; but if you've defined a `publish` script in your `package.json` it will use that instead.
51+
52+
## Examples
53+
54+
```yaml
55+
- name: Publish to NPM
56+
uses: Github-Actions-Community/merge-release@main
57+
with:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
60+
DEPLOY_DIR: my/deploy/dir
61+
SRC_PACKAGE_DIR: my/src/package
62+
```
4763
4864
```yaml
49-
- uses: Github-Actions-Community/merge-release@main
50-
env:
51-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52-
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
53-
DEPLOY_DIR: my/deploy/dir
54-
SRC_PACKAGE_DIR: my/src/package
65+
- name: Publish to GitHub Packages
66+
uses: Github-Actions-Community/merge-release@main
67+
with:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
NPM_REGISTRY_URL: https://npm.pkg.github.com/
71+
MINOR_TAGS: feat|docs
5572
```
5673
5774
## Contributors ✨
5875
5976
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
6077
61-
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
6278
<!-- prettier-ignore-start -->
6379
<!-- markdownlint-disable -->
80+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
81+
6482
<table>
6583
<tbody>
6684
<tr>
@@ -72,11 +90,10 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
7290
</tbody>
7391
</table>
7492
93+
<!-- ALL-CONTRIBUTORS-LIST:END -->
7594
<!-- markdownlint-restore -->
7695
<!-- prettier-ignore-end -->
7796
78-
<!-- ALL-CONTRIBUTORS-LIST:END -->
79-
8097
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
8198
82-
##### Created my free [logo](https://logomakr.com/5sISSS) at [LogoMakr.com](LogoMakr.com)
99+
##### Created my free [logo](https://logomakr.com/5sISSS) at [LogoMakr.com](LogoMakr.com)

action.yaml

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,58 @@
1-
name: 'Merge Release'
2-
description: 'Deploy your package to NPM and Github using semantic versioning'
1+
name: Merge Release
2+
3+
description: Deploy your package to NPM and Github using semantic versioning
4+
35
branding:
4-
icon: 'upload-cloud'
5-
color: 'purple'
6-
runs:
7-
using: 'docker'
8-
image: 'Dockerfile'
6+
icon: upload-cloud
7+
color: purple
8+
9+
runs:
10+
using: docker
11+
image: Dockerfile
12+
913
inputs:
1014
GITHUB_TOKEN:
11-
description: 'GITHUB_TOKEN'
15+
description: Github token to allow tagging the version.
1216
required: true
1317
NPM_AUTH_TOKEN:
14-
description: 'NPM_AUTH_TOKEN'
18+
description: NPM Auth Token to publish to NPM
1519
required: true
1620
NPM_PRIVATE:
17-
description: 'NPM_PRIVATE'
21+
description: If you wish privately publish your package please ensure you have set this to `true`
22+
required: false
23+
SRC_PACKAGE_DIR:
24+
description: The path where the src package.json is found. Defaults to the root dir.
1825
required: false
1926
DEPLOY_DIR:
20-
description: 'DEPLOY_DIR'
27+
description: The path where the dist `package.json` is to run npm publish. Defaults to the root dir.
2128
required: false
2229
NPM_REGISTRY_URL:
23-
description: 'NPM_REGISTRY_URL'
30+
description: The url of the registry that the package should published to
2431
required: false
25-
GIT_TAG_SUFFIX:
26-
description: 'GIT_TAG_SUFFIX'
32+
DISABLE_GIT_TAG:
33+
description: Set to `true` to disable the git tag feature
2734
required: false
28-
SRC_PACKAGE_DIR:
29-
description: 'SRC_PACKAGE_DIR'
35+
MAJOR_TAGS:
36+
description: A list of commit tags to consider a release as a major release
37+
required: false
38+
MINOR_TAGS:
39+
description: A list of commit tags to consider a release as a minor release
40+
required: false
41+
DEBUG:
42+
description: Enable debug logging
43+
required: false
44+
NPM_CUSTOM_NPMRC:
45+
description: A fully-formed npmrc file
46+
required: false
47+
GIT_TAG_SUFFIX:
48+
description: GIT_TAG_SUFFIX
3049
required: false
3150
GITHUB_SHA:
32-
description: 'GITHUB_SHA'
51+
description: GITHUB_SHA
3352
required: false
3453
GITHUB_ACTOR:
35-
description: 'GITHUB_ACTOR'
54+
description: GITHUB_ACTOR
3655
required: false
3756
GITHUB_REPOSITORY:
38-
description: 'GITHUB_REPOSITORY'
57+
description: GITHUB_REPOSITORY
3958
required: false

0 commit comments

Comments
 (0)