release-me-sh 0.11.12 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-me-sh",
3
- "version": "0.11.12",
3
+ "version": "0.12.0",
4
4
  "description": "Fast minimal release workflow script written in Bash with plugins and presets support",
5
5
  "keywords": [
6
6
  "bash",
@@ -23,9 +23,17 @@
23
23
  "release-me": "release.sh",
24
24
  "release-me-sh": "release.sh"
25
25
  },
26
- "files": ["presets", "plugins", "release.sh"],
26
+ "files": [
27
+ "presets",
28
+ "plugins",
29
+ "release.sh"
30
+ ],
27
31
  "browserslist": {
28
- "production": [">0.5%", "not dead", "not op_mini all"],
32
+ "production": [
33
+ ">0.5%",
34
+ "not dead",
35
+ "not op_mini all"
36
+ ],
29
37
  "development": [
30
38
  "last 3 chrome version",
31
39
  "last 3 firefox version",
@@ -44,19 +52,19 @@
44
52
  "docs:write-heading-ids": "docusaurus write-heading-ids"
45
53
  },
46
54
  "devDependencies": {
47
- "@biomejs/biome": "^1.8.3",
48
- "@docusaurus/core": "3.5.1",
49
- "@docusaurus/module-type-aliases": "^3.5.1",
50
- "@docusaurus/preset-classic": "3.5.1",
51
- "@docusaurus/types": "^3.5.1",
52
- "@evilmartians/lefthook": "^1.7.12",
53
- "@ls-lint/ls-lint": "^2.2.3",
54
- "@swc/core": "^1.7.10",
55
+ "@biomejs/biome": "^2.5.15",
56
+ "@docusaurus/core": "3.10.2",
57
+ "@docusaurus/module-type-aliases": "^3.10.2",
58
+ "@docusaurus/preset-classic": "3.10.2",
59
+ "@docusaurus/types": "^3.10.2",
60
+ "@evilmartians/lefthook": "^2.1.15",
61
+ "@ls-lint/ls-lint": "^2.3.1",
62
+ "@swc/core": "^1.16.13",
55
63
  "commitlint-rs-npm": "dalisoft/commitlint-rs-npm#v0.1.11",
56
- "dprint": "^0.47.2",
57
- "prism-react-renderer": "^2.3.1",
58
- "prismjs": "^1.29.0",
59
- "swc-loader": "^0.2.6"
64
+ "dprint": "^0.58.0",
65
+ "prism-react-renderer": "^2.4.1",
66
+ "prismjs": "^1.30.0",
67
+ "swc-loader": "^0.2.7"
60
68
  },
61
69
  "engines": {
62
70
  "node": ">=18.19.1"
@@ -106,62 +106,54 @@ release() {
106
106
  # Committing a `npm` tag
107
107
  log "Committing npm tag..."
108
108
  log_verbose "Git hash: ${CHECKOUT_SHA}!"
109
- if [ -n "${NPM_TOKEN-}" ]; then
110
-
111
- # Don't load this plugin if
112
- # - `--dry-run` used
113
- # - `package.json` is missing
114
- # - `package.json` is not changed on `Git` tracking
115
- if ! ${IS_DRY_RUN-}; then
116
- if [ ! -f package.json ] || [ -z "$(git diff --name-only package.json 2>/dev/null)" ]; then
117
- log "Project does not have package.json or package.json not changed"
109
+
110
+ # Don't load this plugin if
111
+ # - `--dry-run` used
112
+ # - `package.json` is missing
113
+ # - `package.json` is not changed on `Git` tracking
114
+ if ! ${IS_DRY_RUN-}; then
115
+ if [ ! -f package.json ] || [ -z "$(git diff --name-only package.json 2>/dev/null)" ]; then
116
+ log "Project does not have package.json or package.json not changed"
117
+ return 1
118
+ fi
119
+ prepare
120
+ git add package.json
121
+
122
+ if ${IS_WORKSPACE-}; then
123
+ if [ -z "${PKG_NAME}" ]; then
124
+ log_verbose "[npm-post] Workspace defined but no package name defined"
118
125
  return 1
119
126
  fi
120
- prepare
121
- git add package.json
122
-
123
- if ${IS_WORKSPACE-}; then
124
- if [ -z "${PKG_NAME}" ]; then
125
- log_verbose "[npm-post] Workspace defined but no package name defined"
126
- return 1
127
- fi
128
-
129
- if [ -z "${GPG_NO_SIGN-}" ] && [ -n "${GPG_KEY-}" ] && [ -n "${GPG_KEY_ID-}" ]; then
130
- git commit --sign -m "chore(${PKG_NAME}): update \`package.json\` version to ${NEXT_RELEASE_VERSION-} [skip ci]" --no-verify
131
- elif [ -z "${SSH_NO_SIGN-}" ] && [ -n "${SSH_PUBLIC_KEY-}" ]; then
132
- git commit --sign -m "chore(${PKG_NAME}): update \`package.json\` version to ${NEXT_RELEASE_VERSION} [skip ci]" --no-verify
133
- else
134
- git commit --no-gpg-sign -m "chore(${PKG_NAME}): update \`package.json\` version to ${NEXT_RELEASE_VERSION} [skip ci]" --no-verify
135
- fi
127
+
128
+ if [ -z "${GPG_NO_SIGN-}" ] && [ -n "${GPG_KEY-}" ] && [ -n "${GPG_KEY_ID-}" ]; then
129
+ git commit --sign -m "chore(${PKG_NAME}): update \`package.json\` version to ${NEXT_RELEASE_VERSION-} [skip ci]" --no-verify
130
+ elif [ -z "${SSH_NO_SIGN-}" ] && [ -n "${SSH_PUBLIC_KEY-}" ]; then
131
+ git commit --sign -m "chore(${PKG_NAME}): update \`package.json\` version to ${NEXT_RELEASE_VERSION} [skip ci]" --no-verify
136
132
  else
137
- if [ -z "${GPG_NO_SIGN-}" ] && [ -n "${GPG_KEY-}" ] && [ -n "${GPG_KEY_ID-}" ]; then
138
- git commit --sign -m "chore(ci): update \`package.json\` version to ${NEXT_RELEASE_VERSION} [skip ci]" --no-verify
139
- elif [ -z "${SSH_NO_SIGN-}" ] && [ -n "${SSH_PUBLIC_KEY-}" ]; then
140
- git commit --sign -m "chore(ci): update \`package.json\` version to ${NEXT_RELEASE_VERSION} [skip ci]" --no-verify
141
- else
142
- git commit --no-gpg-sign -m "chore(ci): update \`package.json\` version to ${NEXT_RELEASE_VERSION} [skip ci]" --no-verify
143
- fi
133
+ git commit --no-gpg-sign -m "chore(${PKG_NAME}): update \`package.json\` version to ${NEXT_RELEASE_VERSION} [skip ci]" --no-verify
144
134
  fi
145
-
146
- if [ -n "${GIT_REMOTE_ORIGIN}" ]; then
147
- # GitHub workflow re-trigger hack to make it work properly
148
- git pull
149
- git push --no-verify
150
- CHECKOUT_SHA=$(git rev-parse HEAD)
151
- log "Committed npm [${NEXT_RELEASE_TAG-}] tag"
135
+ else
136
+ if [ -z "${GPG_NO_SIGN-}" ] && [ -n "${GPG_KEY-}" ] && [ -n "${GPG_KEY_ID-}" ]; then
137
+ git commit --sign -m "chore(ci): update \`package.json\` version to ${NEXT_RELEASE_VERSION-} [skip ci]" --no-verify
138
+ elif [ -z "${SSH_NO_SIGN-}" ] && [ -n "${SSH_PUBLIC_KEY-}" ]; then
139
+ git commit --sign -m "chore(ci): update \`package.json\` version to ${NEXT_RELEASE_VERSION} [skip ci]" --no-verify
152
140
  else
153
- log "Committing npm [${NEXT_RELEASE_TAG}] tag failed"
141
+ git commit --no-gpg-sign -m "chore(ci): update \`package.json\` version to ${NEXT_RELEASE_VERSION} [skip ci]" --no-verify
154
142
  fi
143
+ fi
155
144
 
156
- cleanup
145
+ if [ -n "${GIT_REMOTE_ORIGIN}" ]; then
146
+ # GitHub workflow re-trigger hack to make it work properly
147
+ git pull
148
+ git push --no-verify
149
+ CHECKOUT_SHA=$(git rev-parse HEAD)
150
+ log "Committed npm [${NEXT_RELEASE_TAG-}] tag"
157
151
  else
158
- log "Skipped committing npm [${NEXT_RELEASE_TAG}] tag in DRY-RUN mode."
152
+ log "Committing npm [${NEXT_RELEASE_TAG}] tag failed"
159
153
  fi
154
+
155
+ cleanup
160
156
  else
161
- echo "
162
- npm Token is not found
163
- Please export npm Token so this plugin can be used
164
- "
165
- exit 1
157
+ log "Skipped committing npm [${NEXT_RELEASE_TAG}] tag in DRY-RUN mode."
166
158
  fi
167
159
  }
package/plugins/npm.sh CHANGED
@@ -2,40 +2,43 @@
2
2
  set -eu
3
3
 
4
4
  release() {
5
- # Publish a `npm` tag
6
- if [ -n "${NPM_TOKEN-}" ]; then
7
- log "Publishing npm tag..."
8
- log_verbose "npm tag: ${NEXT_RELEASE_TAG-} and version: ${NEXT_RELEASE_VERSION-}!"
5
+ # Publish a `npm` tag with token or Trusted publishing (OIDC)
6
+ log "Publishing npm tag..."
7
+ log_verbose "npm tag: ${NEXT_RELEASE_TAG-} and version: ${NEXT_RELEASE_VERSION-}!"
9
8
 
10
- # Don't load this plugin if
11
- # - `--dry-run` used
12
- # - `package.json` is missing
13
- if ! ${IS_DRY_RUN-}; then
14
- if [ ! -f package.json ]; then
15
- log "Project does not have package.json"
16
- return 1
17
- fi
9
+ # Don't load this plugin if
10
+ # - `--dry-run` used
11
+ # - `package.json` is missing
12
+ if ! ${IS_DRY_RUN-}; then
13
+ if [ ! -f package.json ]; then
14
+ log "Project does not have package.json"
15
+ return 1
16
+ fi
18
17
 
18
+ if [ -n "${NPM_TOKEN-}" ]; then
19
19
  TEMP_FILE=$(mktemp)
20
20
  printf "%s\n" "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >>"${TEMP_FILE}"
21
+ export NODE_AUTH_TOKEN="${NPM_TOKEN}"
22
+ fi
21
23
 
22
- # Bump `package.json` `version` for properly publishing
23
- sed -i.bak "s/\"version\": \"[^\"]*\",/\"version\": \"${NEXT_BUILD_VERSION-}\",/" "package.json"
24
- rm -rf package.json.bak
24
+ # Bump `package.json` `version` for properly publishing
25
+ sed -i.bak "s/\"version\": \"[^\"]*\",/\"version\": \"${NEXT_BUILD_VERSION-}\",/" "package.json"
26
+ rm -rf package.json.bak
25
27
 
26
- export NODE_AUTH_TOKEN="${NPM_TOKEN}"
28
+ # without a token npm >= 11.5.1 exchanges the CI's OIDC token
29
+ # (Trusted publishing) for a short-lived publish token
30
+ if [ -n "${TEMP_FILE-}" ]; then
27
31
  npm publish --provenance --userconfig "${TEMP_FILE}"
32
+ else
33
+ npm publish --provenance
34
+ fi
28
35
 
29
- log "Published [${NEXT_RELEASE_TAG}]!"
36
+ log "Published [${NEXT_RELEASE_TAG}]!"
37
+
38
+ if [ -n "${TEMP_FILE-}" ]; then
30
39
  rm -rf "${TEMP_FILE}"
31
- else
32
- log "Skipped npm tag [${NEXT_RELEASE_TAG}] in DRY-RUN mode."
33
40
  fi
34
41
  else
35
- echo "
36
- npm Token is not found
37
- Please export npm Token so this plugin can be used
38
- "
39
- exit 1
42
+ log "Skipped npm tag [${NEXT_RELEASE_TAG}] in DRY-RUN mode."
40
43
  fi
41
44
  }
@@ -4,7 +4,7 @@ set -eu
4
4
  # RegExp as variable
5
5
  regexp_commit_primary="^([a-z]+)(\(([^\)]+)\))?:\ (.+)$"
6
6
  regexp_commit_major="^([a-z]+)(\(([^\)]+)\))?!?:\ (.+)$"
7
- string_commit_major="^BREAKING CHANGE(: )?(.+)"
7
+ string_commit_major="BREAKING[ -]CHANGE:"
8
8
 
9
9
  # Release types
10
10
  RELEASE_SKIP_TYPES=("build" "chore" "style" "ci" "skip ci")
@@ -4,7 +4,7 @@ set -eu
4
4
  # RegExp as variable
5
5
  regexp_commit_primary="^([a-z]+)(\(([^\)]+)\))?:\ (.+)$"
6
6
  regexp_commit_major="^([a-z]+)(\(([^\)]+)\))?!?:\ (.+)$"
7
- string_commit_major="^BREAKING CHANGE(: )?(.+)"
7
+ string_commit_major="BREAKING[ -]CHANGE:"
8
8
 
9
9
  # Release types
10
10
  RELEASE_SKIP_TYPES=("build" "chore" "style" "ci" "skip ci")
package/release.sh CHANGED
@@ -262,9 +262,9 @@ get_git_variables() {
262
262
  GIT_TAGS_LIST=$(git for-each-ref --sort=creatordate --format '%(refname)' refs/tags)
263
263
 
264
264
  if ${IS_WORKSPACE}; then
265
- GIT_LAST_PROJECT_TAG=$(printf "%b" "${GIT_TAGS_LIST}" | grep "${PKG_NAME}" | tail -1 | cut -d '/' -f 3)
265
+ GIT_LAST_PROJECT_TAG=$(printf "%b" "${GIT_TAGS_LIST}" | grep "${PKG_NAME}" | tail -1 | cut -d '/' -f 3-)
266
266
  else
267
- GIT_LAST_PROJECT_TAG=$(printf "%s" "${GIT_TAGS_LIST}" | tail -1 | cut -d '/' -f 3)
267
+ GIT_LAST_PROJECT_TAG=$(printf "%s" "${GIT_TAGS_LIST}" | tail -1 | cut -d '/' -f 3-)
268
268
  fi
269
269
 
270
270
  if [[ ${GIT_LAST_PROJECT_TAG} != "" ]]; then
@@ -346,24 +346,55 @@ PATCH_UPGRADED=false
346
346
  MINOR_UPGRADED=false
347
347
  MAJOR_UPGRADED=false
348
348
 
349
+ process_commit_entry() {
350
+ local commit="$1"
351
+ local commit_body_extra="$2"
352
+
353
+ if [[ "${commit}" =~ ${GIT_LOG_PARSE_REGEX} ]]; then
354
+ if [[ -n "${commit_body_extra}" ]]; then
355
+ if [[ -n "${BASH_REMATCH[5]-}" ]]; then
356
+ BASH_REMATCH[5]="${BASH_REMATCH[5]}"$'\n'"${commit_body_extra}"
357
+ else
358
+ BASH_REMATCH[5]="${commit_body_extra}"
359
+ fi
360
+ fi
361
+ log_verbose "${BASH_REMATCH[3]}" "-q"
362
+ CHECKOUT_SHA=${BASH_REMATCH[1]}
363
+
364
+ preset_command=$(command -v parse_commit)
365
+ if [[ -n "${preset_command}" ]]; then
366
+ parse_commit BASH_REMATCH
367
+ fi
368
+ fi
369
+ }
370
+
349
371
  handle_git_commits() {
350
372
  log_verbose "Analyzing commits...\n"
373
+
351
374
  local IFS=
352
- while read -r line; do
375
+ local commit=""
376
+ local commit_body_extra=""
377
+ while read -r line || [[ -n "${line}" ]]; do
353
378
  if [[ "${line}" == "${GIT_LOG_COMMIT_SEPARATOR}" ]]; then
354
- read -r commit
355
-
356
- if [[ "${commit}" =~ ${GIT_LOG_PARSE_REGEX} ]]; then
357
- log_verbose "${BASH_REMATCH[3]}" "-q"
358
- CHECKOUT_SHA=${BASH_REMATCH[1]}
359
-
360
- preset_command=$(command -v parse_commit)
361
- if [[ -n "${preset_command}" ]]; then
362
- parse_commit BASH_REMATCH
379
+ if [[ -n "${commit}" ]]; then
380
+ process_commit_entry "${commit}" "${commit_body_extra}"
381
+ fi
382
+ commit=""
383
+ commit_body_extra=""
384
+ read -r commit || commit=""
385
+ else
386
+ if [[ -n "${commit}" ]]; then
387
+ if [[ -z "${commit_body_extra}" ]]; then
388
+ commit_body_extra="${line}"
389
+ else
390
+ commit_body_extra+=$'\n'"${line}"
363
391
  fi
364
392
  fi
365
393
  fi
366
394
  done <<<"${GIT_LOGS}"
395
+ if [[ -n "${commit}" ]]; then
396
+ process_commit_entry "${commit}" "${commit_body_extra}"
397
+ fi
367
398
  log_verbose "" "-q"
368
399
  log_verbose "Analyzed commits!"
369
400