.github/workflows/release.yml# Release on version bump# When dev is pushed with a package.json version change, mirror dev -> main,# tag the release, and publish a GitHub Release with a downloadable zip.name: Releaseon:push:branches:- devjobs:release:# Only run in the canonical repo. Template/forked copies inherit this file# but this guard makes every job a no-op there — no mirror, tags, or releases.if: github.repository == 'gallop-software/2d-3d-floor-planner'runs-on: ubuntu-latestpermissions:contents: writesteps:- name: Checkout dev branchuses: actions/checkout@v4with:ref: devfetch-depth: 0- name: Check for version bumpid: version-checkrun: |CURRENT_VERSION=$(jq -r .version package.json)echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT# Get previous version from git history (commit before the current version bump)PREV_VERSION=$(git log --format=%H -1 --skip=1 -G'"version":' -- package.json | xargs -I{} git show {}:package.json | jq -r .version)echo "prev_version=$PREV_VERSION" >> $GITHUB_OUTPUTif [ "$CURRENT_VERSION" == "$PREV_VERSION" ] || [ -z "$PREV_VERSION" ]; thenecho "No version bump detected (current: $CURRENT_VERSION, prev: $PREV_VERSION)"echo "should_release=false" >> $GITHUB_OUTPUTelseecho "Version bump detected: $PREV_VERSION -> $CURRENT_VERSION"echo "should_release=true" >> $GITHUB_OUTPUTfi- name: Get commit messages since last version bumpif: steps.version-check.outputs.should_release == 'true'id: commitsrun: |# Find the previous version bump commitPREV_BUMP=$(git log --format=%H -2 -G'"version":' -- package.json | tail -1)if [ -z "$PREV_BUMP" ]; thenCOMMITS=$(git log --oneline --no-decorate | head -20)elseCOMMITS=$(git log --oneline --no-decorate $PREV_BUMP..HEAD)fiecho "commits<<EOF" >> $GITHUB_OUTPUTecho "$COMMITS" >> $GITHUB_OUTPUTecho "EOF" >> $GITHUB_OUTPUT- name: Update main to match devif: steps.version-check.outputs.should_release == 'true'run: git push --force origin HEAD:main- name: Create tagif: steps.version-check.outputs.should_release == 'true'run: |VERSION="v${{ steps.version-check.outputs.current_version }}"git tag -f "$VERSION"git push --force origin "$VERSION"- name: Create GitHub Release with zipif: steps.version-check.outputs.should_release == 'true'env:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}RELEASE_NOTES: ${{ steps.commits.outputs.commits }}run: |VERSION="v${{ steps.version-check.outputs.current_version }}"REPO_NAME="2d-3d-floor-planner"# Build a zip that extracts to a top-level 2d-3d-floor-planner/ foldermkdir -p "$REPO_NAME-folder/$REPO_NAME"shopt -s dotglob nullglobrsync -a --exclude='.git' --exclude='.github' --exclude='node_modules' --exclude="$REPO_NAME-folder" ./ "$REPO_NAME-folder/$REPO_NAME/"shopt -u dotglob nullglob(cd "$REPO_NAME-folder" && zip -r "../$REPO_NAME.zip" "$REPO_NAME")# Delete existing release if present (for retries)gh release delete "$VERSION" --yes 2>/dev/null || trueecho "$RELEASE_NOTES" > release-notes.txtgh release create "$VERSION" \--title "Release $VERSION" \--notes-file release-notes.txt \"$REPO_NAME.zip"