Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

ci: auto version bump on main — minor for dev merges, patch for hotfixes

Mauricec05640100032
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 05ad1f87a..27bab6f50 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -5,9 +5,67 @@ on:
branches: [main]
workflow_dispatch:
+permissions:
+ contents: write
+
jobs:
+ version-bump:
+ runs-on: ubuntu-latest
+ outputs:
+ version: ${{ steps.bump.outputs.VERSION }}
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Determine bump type and update version
+ id: bump
+ run: |
+ # Check if this push is a merge commit from dev branch
+ COMMIT_MSG=$(git log -1 --pretty=%s)
+ PARENT_COUNT=$(git log -1 --pretty=%p | wc -w)
+
+ if echo "$COMMIT_MSG" | grep -qiE "^Merge (pull request|branch).*dev"; then
+ BUMP="minor"
+ elif [ "$PARENT_COUNT" -gt 1 ] && git log -1 --pretty=%P | xargs -n1 git branch -r --contains 2>/dev/null | grep -q "origin/dev"; then
+ BUMP="minor"
+ else
+ BUMP="patch"
+ fi
+
+ echo "Bump type: $BUMP"
+
+ # Read current version
+ CURRENT=$(node -p "require('./server/package.json').version")
+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
+
+ if [ "$BUMP" = "minor" ]; then
+ MINOR=$((MINOR + 1))
+ PATCH=0
+ else
+ PATCH=$((PATCH + 1))
+ fi
+
+ NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
+ echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
+ echo "$CURRENT → $NEW_VERSION ($BUMP)"
+
+ # Update both package.json files
+ cd server && npm version "$NEW_VERSION" --no-git-tag-version && cd ..
+ cd client && npm version "$NEW_VERSION" --no-git-tag-version && cd ..
+
+ # Commit and tag
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+ git add server/package.json server/package-lock.json client/package.json
+ git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
+ git tag "v$NEW_VERSION"
+ git push origin main --follow-tags
+
build:
runs-on: ${{ matrix.runner }}
+ needs: version-bump
strategy:
fail-fast: false
matrix:
@@ -21,6 +79,8 @@ jobs:
run: echo "PLATFORM_PAIR=$(echo ${{ matrix.platform }} | sed 's|/|-|g')" >> $GITHUB_ENV
- uses: actions/checkout@v4
+ with:
+ ref: main
- uses: docker/setup-buildx-action@v3
@@ -54,13 +114,11 @@ jobs:
merge:
runs-on: ubuntu-latest
- needs: build
+ needs: [version-bump, build]
steps:
- uses: actions/checkout@v4
-
- - name: Get version from package.json
- id: version
- run: echo "VERSION=$(node -p "require('./server/package.json').version")" >> $GITHUB_OUTPUT
+ with:
+ ref: main
- name: Download build digests
uses: actions/download-artifact@v4
@@ -79,12 +137,13 @@ jobs:
- name: Create and push multi-arch manifest
working-directory: /tmp/digests
run: |
+ VERSION=${{ needs.version-bump.outputs.version }}
mapfile -t digests < <(printf 'mauriceboe/trek@sha256:%s\n' *)
docker buildx imagetools create \
-t mauriceboe/trek:latest \
- -t mauriceboe/trek:${{ steps.version.outputs.VERSION }} \
+ -t mauriceboe/trek:$VERSION \
-t mauriceboe/nomad:latest \
- -t mauriceboe/nomad:${{ steps.version.outputs.VERSION }} \
+ -t mauriceboe/nomad:$VERSION \
"${digests[@]}"
- name: Inspect manifest