Skip to content

Add patch release script#9

Closed
axeldelafosse wants to merge 2 commits intomainfrom
chore/manual-update-apply-immediately
Closed

Add patch release script#9
axeldelafosse wants to merge 2 commits intomainfrom
chore/manual-update-apply-immediately

Conversation

@axeldelafosse
Copy link
Copy Markdown
Owner

@axeldelafosse axeldelafosse commented Feb 22, 2026

Summary

  • Added a release:patch script to package.json:
    • npm version patch && git push --follow-tags
  • Updated README.md to document patch release using the new script:
    • bun run release:patch

Why

  • Simplifies the release workflow by combining version bump and tag push into one command.

Files Changed

  • package.json
  • README.md

Testing

  • Not run (script + docs-only change).

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @axeldelafosse, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the developer experience by introducing an automated script for patch releases, simplifying the versioning and tagging process. Concurrently, it refines the application's self-update mechanism to immediately apply new versions, providing a more direct and efficient update experience. These changes are supported by updated documentation and adjusted test cases.

Highlights

  • Automated Patch Release Script: A new release:patch script has been added to package.json to automate the process of bumping the patch version and pushing the commit and tags to the repository.
  • Streamlined Update Mechanism: The loop update command now directly applies updates to the executable instead of staging them for the next startup. This change simplifies the update flow for users.
  • Documentation Updates: The README.md file has been updated to reflect the new bun run release:patch command for releases, and the usage text in src/loop/constants.ts has been adjusted to indicate that updates are 'applied' rather than 'staged'.
  • Refactored Update Logic and Tests: The internal update logic in src/loop/update.ts has been refactored to support direct application, including the introduction of a new applyBinary function. Corresponding tests in tests/loop/update.test.ts have been modified to validate this direct application behavior.
Changelog
  • README.md
    • Updated release instructions to utilize the new release:patch script.
  • package.json
    • Added a release:patch script that runs npm version patch and git push --follow-tags.
  • src/loop/constants.ts
    • Modified descriptions for loop update and auto-update to reflect direct application instead of staging.
  • src/loop/update.ts
    • Introduced applyBinary function to handle writing and renaming the new executable.
    • Refactored downloadAndStage into downloadBinary to return the binary buffer, separating download from application.
    • Updated applyStagedUpdateOnStartup to use the new applyBinary function.
    • Created checkAndApply function to directly download and apply updates, replacing the staging mechanism for manual updates.
  • tests/loop/update.test.ts
    • Updated test descriptions and assertions to verify direct application of updates to the executable.
    • Removed checks for STAGED_BINARY and METADATA_FILE existence in manual update tests, as updates are now applied directly.
    • Added cleanup for testExecPath in test finally blocks.
Activity
  • The pull request was created by axeldelafosse.
  • The author noted that testing was not run, as the changes primarily involve documentation and package scripts.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@axeldelafosse
Copy link
Copy Markdown
Owner Author

Superseded by clean PR #10, which contains only the release:patch and README changes (this PR had older unrelated commit).

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new release:patch script for easier version bumping and tag pushing. It also refactors the update mechanism to allow for direct application of updates, alongside the existing staging mechanism for auto-updates. The documentation and tests have been updated to reflect these changes. Overall, the changes improve the release process and provide more flexible update handling.

Comment thread src/loop/update.ts
Comment on lines +268 to +304
const checkAndApply = async (
assetName: string,
silent: boolean
): Promise<void> => {
const currentVersion = getCurrentVersion();
const release = await fetchLatestRelease();
const version = release.tag_name.replace(VERSION_PREFIX_RE, "");

if (!isNewerVersion(version, currentVersion)) {
if (!silent) {
console.log(`[loop] already up to date (v${currentVersion})`);
}
return;
}

const asset = release.assets.find((a) => a.name === assetName);
if (!asset) {
throw new Error(`No release asset for ${assetName}`);
}

if (!silent) {
console.log(`[loop] downloading v${version}...`);
}

const checksumAsset = release.assets.find(
(a) => a.name === `${assetName}.sha256`
);
const binary = await downloadBinary(
asset.browser_download_url,
checksumAsset?.browser_download_url
);
applyBinary(binary);

if (!silent) {
console.log(`[loop] v${version} applied`);
}
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The checkAndApply function duplicates a significant amount of logic already present in checkAndStage. To reduce redundancy and improve maintainability, consider extracting the common logic (fetching release, version comparison, asset finding, and initial logging) into a shared helper function. This suggestion refactors checkAndApply to use such a helper, which is included in the suggestion.

const getUpdateInfo = async (assetName: string, silent: boolean) => {
  const currentVersion = getCurrentVersion();
  const release = await fetchLatestRelease();
  const version = release.tag_name.replace(VERSION_PREFIX_RE, "");

  if (!isNewerVersion(version, currentVersion)) {
    if (!silent) {
      console.log(`[loop] already up to date (v${currentVersion})`);
    }
    return null;
  }

  const asset = release.assets.find((a) => a.name === assetName);
  if (!asset) {
    throw new Error(`No release asset for ${assetName}`);
  }

  if (!silent) {
    console.log(`[loop] downloading v${version}...`);
  }

  const checksumAsset = release.assets.find(
    (a) => a.name === `${assetName}.sha256`
  );

  return { version, asset, checksumAsset };
};

const checkAndApply = async (
  assetName: string,
  silent: boolean
): Promise<void> => {
  const updateInfo = await getUpdateInfo(assetName, silent);
  if (!updateInfo) {
    return;
  }
  const { version, asset, checksumAsset } = updateInfo;

  const binary = await downloadBinary(
    asset.browser_download_url,
    checksumAsset?.browser_download_url
  );
  applyBinary(binary);

  if (!silent) {
    console.log(`[loop] v${version} applied`);
  }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant