Repository: gitbutlerapp/gitbutler
File: scripts/release.sh (Shell)

Code before:
	# Build with specified target
	# Note: passing --target is necessary to let tauri find the binaries,
	# it ignores CARGO_BUILD_TARGET and is more of a hack.
	tauri build \
		--verbose \
		--features "$FEATURES" \
		--config "$TMP_DIR/tauri.conf.json" \
		--target "$TARGET"

  BUNDLE_DIR=$(readlink -f "$PWD/../target/$TARGET/release/bundle")
else
	# Build with default target
	tauri build \
		--verbose \
		--features "$FEATURES" \
		--config "$TMP_DIR/tauri.conf.json"

	BUNDLE_DIR=$(readlink -f "$PWD/../target/release/bundle")
fi

# The release dir determines a (significant portion of) the final S3 object key.
RELEASE_DIR="$DIST/$OS/$ARCH"
if [ "$OS" = "linux" ]; then
  # We build for multiple linux distros and need distinct keys for them.
  RELEASE_DIR="$DIST/$OS/$(lsb_release -cs)/$ARCH"
fi

echo "Resolved RELEASE_DIR=$RELEASE_DIR"

mkdir -p "$RELEASE_DIR"

if [ "$OS" = "macos" ]; then
	MACOS_DMG="$(find "$BUNDLE_DIR/dmg" -depth 1 -type f -name "*.dmg")"
	MACOS_UPDATER="$(find "$BUNDLE_DIR/macos" -depth 1 -type f -name "*.tar.gz")"
	MACOS_UPDATER_SIG="$(find "$BUNDLE_DIR/macos" -depth 1 -type f -name "*.tar.gz.sig")"

	cp "$MACOS_DMG" "$RELEASE_DIR"
	cp "$MACOS_UPDATER" "$RELEASE_DIR"
	cp "$MACOS_UPDATER_SIG" "$RELEASE_DIR"

	info "built:"
	info "	- $RELEASE_DIR/$(basename "$MACOS_DMG")"
	info "	- $RELEASE_DIR/$(basename "$MACOS_UPDATER")"
	info "	- $RELEASE_DIR/$(basename "$MACOS_UPDATER_SIG")"
elif [ "$OS" = "linux" ]; then
	APPIMAGE="$(find "$BUNDLE_DIR/appimage" -name \*.AppImage)"
	APPIMAGE_UPDATER="$(find "$BUNDLE_DIR/appimage" -name \*.AppImage.tar.gz)"
	APPIMAGE_UPDATER_SIG="$(find "$BUNDLE_DIR/appimage" -name \*.AppImage.tar.gz.sig)"
	DEB="$(find "$BUNDLE_DIR/deb" -name \*.deb)"
	RPM="$(find "$BUNDLE_DIR/rpm" -name \*.rpm)"


Review comment (bug):
@Byron As you thought, there was probably a last-write-wins situation going on with the S3 uploads for the Linux releases. This should address that (if I've finally actually understood how the S3 keys are determined), BUT it is not enough. There's a part of the `publish.yaml` workflow that notifies the GB API of the new version https://github.com/gitbutlerapp/gitbutler/blob/0e8b4cc233ce8fbe6826efaba9d6c76830489559/.github/workflows/publish.yaml#L398-L406

A quick peek into that API shows this:

```bash
$ curl -s https://app.gitbutler.com/releases/ | jq
{
  "version": "0.18.2",
  "notes": "- Improved UX of branch reordering, making creating / splitting stacks of branches more intuitive\n- Fixes a bug with commit message / PR description inputs preventing creating new lines (paragraphs)\n- Codegen - fixes a bug with full commands not being shown in permission requests",
  "pub_date": "2025-11-29T14:53:27+00:00",
  "platforms": {
    <snip>
    "linux-aarch64": {
      "signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVUck9FSStpbTFYWUxuWGxGNEdyRDhKRHMzdGpQamhacEhOcVJRYTJNYzJHdVl5RDJ0OG9jbytlUXBUYVphWkNBbkw1RWxSYVFPQ1ZMUHZkMWVGV1J3cjRENmZXOTQ4S1FFPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzY0NDI0NTg3CWZpbGU6R2l0QnV0bGVyXzAuMTguMl9hYXJjaDY0LkFwcEltYWdlLnRhci5negpXSEhmOVhIUHcwVi9mSS9PWkJHOUxwVmxGbmhxY1ZlMjZPQ25LRWYzQXBEc2plVnM5Qms3N0hUV0wrVDNvZjh5bGYrVGIzZEdJWnRzaURYUkFmYUdCQT09Cg==",
      "url": "https://releases.gitbutler.com/releases/release/0.18.2-2660/linux/aarch64/GitButler_0.18.2_aarch64.AppImage.tar.gz"
    },
    "linux-x86_64": {
      "signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVUck9FSStpbTFYWUQ0cnVYQ3VEYzhKUWhlUHMwdmovamtwTnlMWE1jY2Y2MGlIUms4c21BSWNUK3RUNzNYbDNDT0E2TU1EN2VnQmg0aUZkQnlYS2hqbGRjUUNRY2t1S1FVPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzY0NDI0NTIwCWZpbGU6R2l0QnV0bGVyXzAuMTguMl9hbWQ2NC5BcHBJbWFnZS50YXIuZ3oKbnc2SFNoc2dqcDRReDUzTDZxdEhuWEhxMVUwSy9EQkZYU2ZSNHJjVzRPL2o4TFA0aytRbXR4Z0hOWUhpd2tXUVVaeXE0UG1NVGZNU0xIU2tyd3ZSQ2c9PQo=",
      "url": "https://releases.gitbutler.com/releases/release/0.18.2-2660/linux/x86_64/GitButler_0.18.2_amd64.AppImage.tar.gz"
    }
  }
}
```

That API needs to be updated, along with the website page that shows downloads: https://gitbutler.com/downloads

And potentially also the Tauri updater plugin URLs, I don't really know how those work.

This super easy, barely an inconvenience little thing turned out to be all kinds of inconvenient :)

Code after:
export VERSION
export CHANNEL

# Build the app with release config
if [ -n "$TARGET" ]; then
	# Export TARGET for cargo to use
	export CARGO_BUILD_TARGET="$TARGET"

	# Build with specified target
	# Note: passing --target is necessary to let tauri find the binaries,
	# it ignores CARGO_BUILD_TARGET and is more of a hack.
	tauri build \
		--verbose \
		--features "$FEATURES" \
		--config "$TMP_DIR/tauri.conf.json" \
		--target "$TARGET"

  BUNDLE_DIR=$(readlink -f "$PWD/../target/$TARGET/release/bundle")
else
	# Build with default target
	tauri build \
		--verbose \
		--features "$FEATURES" \
		--config "$TMP_DIR/tauri.conf.json"

	BUNDLE_DIR=$(readlink -f "$PWD/../target/release/bundle")
fi

RELEASE_DIR="$DIST/$OS/$ARCH"
mkdir -p "$RELEASE_DIR"

if [ "$OS" = "macos" ]; then
	MACOS_DMG="$(find "$BUNDLE_DIR/dmg" -depth 1 -type f -name "*.dmg")"
	MACOS_UPDATER="$(find "$BUNDLE_DIR/macos" -depth 1 -type f -name "*.tar.gz")"
	MACOS_UPDATER_SIG="$(find "$BUNDLE_DIR/macos" -depth 1 -type f -name "*.tar.gz.sig")"

	cp "$MACOS_DMG" "$RELEASE_DIR"
	cp "$MACOS_UPDATER" "$RELEASE_DIR"
	cp "$MACOS_UPDATER_SIG" "$RELEASE_DIR"

	info "built:"
	info "	- $RELEASE_DIR/$(basename "$MACOS_DMG")"
	info "	- $RELEASE_DIR/$(basename "$MACOS_UPDATER")"
	info "	- $RELEASE_DIR/$(basename "$MACOS_UPDATER_SIG")"
elif [ "$OS" = "linux" ]; then
	APPIMAGE="$(find "$BUNDLE_DIR/appimage" -name \*.AppImage)"
	APPIMAGE_UPDATER="$(find "$BUNDLE_DIR/appimage" -name \*.AppImage.tar.gz)"
	APPIMAGE_UPDATER_SIG="$(find "$BUNDLE_DIR/appimage" -name \*.AppImage.tar.gz.sig)"
	DEB="$(find "$BUNDLE_DIR/deb" -name \*.deb)"
	RPM="$(find "$BUNDLE_DIR/rpm" -name \*.rpm)"