Skip to content

Commit b103d2f

Browse files
authored
fix(publish-npm): add RELEASE_TAG support for version determination (#50)
* fix(publish-npm): add RELEASE_TAG support for version determination - Introduced `RELEASE_TAG` environment variable to allow direct version extraction, enhancing flexibility in version handling. - Updated `getVersionFromTag` function to prioritize `RELEASE_TAG` over `GITHUB_REF`, improving error messaging for missing tags. Signed-off-by: Alessandro De Blasis <alex@deblasis.net> * fix(workflow): update branch naming to use APP_VERSION_NO_V - Changed branch name from `pull-watch-${TARGET_TAG}` to `pull-watch-${APP_VERSION_NO_V}` in the release workflow to ensure consistency with versioning. - Updated manifest path to reflect the new versioning scheme. Signed-off-by: Alessandro De Blasis <alex@deblasis.net> --------- Signed-off-by: Alessandro De Blasis <alex@deblasis.net>
1 parent d546dec commit b103d2f

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

.github/workflows/release-please.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ jobs:
201201
set -eo pipefail
202202
retries=5
203203
delay=15
204-
branch_name="pull-watch-${TARGET_TAG}"
204+
branch_name="pull-watch-${APP_VERSION_NO_V}"
205205
manifest_path="manifests/s/${WINGET_PUBLISHER}/${WINGET_PACKAGE}/${APP_VERSION_NO_V}/${WINGET_PUBLISHER}.${WINGET_PACKAGE}.installer.yaml"
206206
repo_url="https://github.com/${WINGET_REPO_OWNER}/${WINGET_REPO_NAME}.git"
207207
@@ -365,7 +365,7 @@ jobs:
365365
COMMIT_MSG="ci(winget): update manifests for ${TAG_NAME}"
366366
git commit -m "$COMMIT_MSG" -m "$SIGNOFF_LINE"
367367
368-
BRANCH_NAME="pull-watch-${TAG_NAME}"
368+
BRANCH_NAME="pull-watch-${APP_VERSION_NO_V}"
369369
echo "Pushing manifest updates commit to branch ${BRANCH_NAME} in ${WINGET_REPO_OWNER}/${WINGET_REPO_NAME}..."
370370
# Use the GITHUB_TOKEN provided by the workflow runner for authentication
371371
# Ensure the token has permissions to write to the fork.

scripts/publish-npm.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const TEMP_WORK_DIR = path.resolve(
1111
"npm-postinstall-temp-work"
1212
); // Dir for temporary package building
1313
const GITHUB_REF = process.env.GITHUB_REF; // e.g., refs/tags/v1.2.3
14+
const RELEASE_TAG = process.env.RELEASE_TAG; // e.g., v1.2.3 - directly from workflow
1415
const NPM_TOKEN = process.env.NODE_AUTH_TOKEN;
1516
const NPM_PROVENANCE = process.env.NPM_CONFIG_PROVENANCE === "true";
1617
// --- End Configuration ---
@@ -27,9 +28,18 @@ function error(message) {
2728
}
2829

2930
function getVersionFromTag(ref) {
31+
// First try to use RELEASE_TAG if available
32+
if (RELEASE_TAG) {
33+
if (RELEASE_TAG.startsWith("v")) {
34+
return RELEASE_TAG.substring(1); // Remove 'v' prefix
35+
}
36+
return RELEASE_TAG; // Use as-is if no 'v' prefix
37+
}
38+
39+
// Fall back to GITHUB_REF
3040
if (!ref || !ref.startsWith("refs/tags/v")) {
3141
error(
32-
`Invalid or missing GITHUB_REF tag: ${ref}. Must start with 'refs/tags/v'.`
42+
`Invalid or missing GITHUB_REF tag: ${ref}. Must start with 'refs/tags/v' or set RELEASE_TAG env variable.`
3343
);
3444
}
3545
return ref.substring("refs/tags/v".length);

0 commit comments

Comments
 (0)