Skip to content

Commit

Permalink
fix(npm): rename the NPM binary package for Windows
Browse files Browse the repository at this point in the history
Apparently, NPM doesn't like numbers in package names and recognizes them as spam.
  • Loading branch information
orhun committed Jan 9, 2023
1 parent e2e124e commit ce1d468
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,25 @@ jobs:
shell: bash
run: |
cd npm
bin="git-cliff"
node_os=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f1)
export node_os
node_arch=$(echo "${{ matrix.build.NAME }}" | cut -d '-' -f2)
export node_arch
export version="${{ env.RELEASE_VERSION }}"
bin="git-cliff"
mkdir -p "git-cliff-${node_os}-${node_arch}/bin"
envsubst < package.json.tmpl > "git-cliff-${node_os}-${node_arch}/package.json"
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
export node_pkg="${bin}-windows-${node_arch}"
else
export node_pkg="${bin}-${node_os}-${node_arch}"
fi
mkdir -p "${node_pkg}/bin"
envsubst < package.json.tmpl > "${node_pkg}/package.json"
if [ "${{ matrix.build.OS }}" = "windows-2022" ]; then
bin="${bin}.exe"
fi
cp "../target/${{ matrix.build.TARGET }}/release/${bin}" "git-cliff-${node_os}-${node_arch}/bin"
cp ../README.md "git-cliff-${node_os}-${node_arch}"
cd "git-cliff-${node_os}-${node_arch}"
cp "../target/${{ matrix.build.TARGET }}/release/${bin}" "${node_pkg}/bin"
cp ../README.md "${node_pkg}"
cd "${node_pkg}"
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions npm/git-cliff/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function getExePath() {

let extension = '';
if (['win32', 'cygwin'].includes(process.platform)) {
os = 'windows';
extension = '.exe';
}

Expand Down
2 changes: 1 addition & 1 deletion npm/package.json.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "git-cliff-${node_os}-${node_arch}",
"name": "${node_pkg}",
"version": "${version}",
"description": "A highly customizable Changelog Generator that follows Conventional Commit specifications ⛰️",
"repository": {
Expand Down

0 comments on commit ce1d468

Please sign in to comment.