From ef17ff44af1ba67fc40e209c61fd4fc05faca998 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sun, 10 Dec 2023 15:51:53 -0500 Subject: [PATCH] Update signing script --- docs/RELEASING.md | 2 +- tools/sign-released-package.js | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 621a65e1..6d7c8792 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -42,7 +42,7 @@ These are mostly the steps when releasing a new version: For releasing to the store (when needed), this is done following a Playlet lib release: -- Switch to main branch and pull changes - **match commit corresponding to the release.** +- Switch to main branch and pull changes, **including tags** - **match commit corresponding to the release.** - `npm run build:release:ci` - This makes sure to have a valid app in the staging folder - `npm run sign-released-package` diff --git a/tools/sign-released-package.js b/tools/sign-released-package.js index dfea0204..d2c7ed91 100644 --- a/tools/sign-released-package.js +++ b/tools/sign-released-package.js @@ -13,16 +13,22 @@ shell.exec('git fetch --tags --force'); const gitCommitHash = shell.exec('git rev-parse HEAD').stdout.trim(); // get current tag -const gitTag = shell.exec(`git describe --tags ${gitCommitHash} --abbrev=0`).stdout.trim(); +const gitTags = shell.exec(`git tag --contains ${gitCommitHash}`) + .stdout.trim() + .split('\n') + .map(tag => tag.trim()); const expectedGitTag = `v${require('../package.json').version}`; -if (gitTag !== expectedGitTag) { - console.error(`Expected git tag ${expectedGitTag} but found ${gitTag}. Signing anyway...`); +if (gitTags.length === 0) { + console.error(`No git tag found. Signing anyway...`); +} +if (!gitTags.includes(expectedGitTag)) { + console.error(`Expected git tag ${expectedGitTag} but found [${gitTags.join(",")}]. Signing anyway...`); } // download playlet.zip from github -const zipUrl = `https://github.com/iBicha/playlet/releases/download/${gitTag}/playlet.zip` -shell.exec(`curl -L -o release/playlet.zip "${zipUrl}"`); +const zipUrl = `https://github.com/iBicha/playlet/releases/download/${expectedGitTag}/playlet.zip` +shell.exec(`curl --fail -L -o release/playlet.zip "${zipUrl}"`); // sign the package shell.exec('node tools/sign-package.js');