Skip to content

fix(flow-chat): preserve explicit session selection during restore #828

fix(flow-chat): preserve explicit session selection during restore

fix(flow-chat): preserve explicit session selection during restore #828

name: Release On Version Bump
on:
push:
branches: [main]
permissions:
contents: write
actions: write
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect version bump
id: detect
shell: bash
env:
BEFORE_SHA: ${{ github.event.before }}
run: |
set -euo pipefail
CURRENT_VERSION="$(jq -r '.version' package.json)"
TAG_NAME="v${CURRENT_VERSION}"
echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
# First push to branch or unknown previous commit
if [[ -z "${BEFORE_SHA}" || "${BEFORE_SHA}" =~ ^0+$ ]]; then
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "reason=before_sha_unavailable" >> "$GITHUB_OUTPUT"
exit 0
fi
PREV_VERSION="$(git show "${BEFORE_SHA}:package.json" 2>/dev/null | jq -r '.version' 2>/dev/null || true)"
if [[ -z "${PREV_VERSION}" ]]; then
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "reason=previous_version_unavailable" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ "$CURRENT_VERSION" == "$PREV_VERSION" ]]; then
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "reason=version_unchanged" >> "$GITHUB_OUTPUT"
exit 0
fi
if git ls-remote --exit-code --tags origin "refs/tags/${TAG_NAME}" >/dev/null 2>&1; then
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "reason=tag_exists" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "previous_version=$PREV_VERSION" >> "$GITHUB_OUTPUT"
echo "should_release=true" >> "$GITHUB_OUTPUT"
echo "reason=version_changed" >> "$GITHUB_OUTPUT"
- name: Log decision
shell: bash
run: |
echo "Decision: ${{ steps.detect.outputs.reason }}"
echo "Current version: ${{ steps.detect.outputs.current_version }}"
echo "Tag: ${{ steps.detect.outputs.tag_name }}"
- name: Create release tag
if: steps.detect.outputs.should_release == 'true'
shell: bash
env:
TAG_NAME: ${{ steps.detect.outputs.tag_name }}
run: |
set -euo pipefail
git tag "${TAG_NAME}" "${GITHUB_SHA}"
git push origin "refs/tags/${TAG_NAME}"
- name: Trigger desktop package
if: steps.detect.outputs.should_release == 'true'
shell: bash
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ steps.detect.outputs.tag_name }}
run: |
set -euo pipefail
gh workflow run desktop-package.yml \
--ref "${GITHUB_REF_NAME}" \
-f "tag_name=${TAG_NAME}" \
-f "upload_to_release=true"