Skip to content

Commit f26a3ff

Browse files
drakehanguyenDrakeNguyen
andauthored
Feature/manual deploy (#62)
* feat(github): enable manual deployment from Actions tab * chore(github): remove redundant pnpm setup step in deploy workflow * chore(github): update deploy workflow to remove auto-deploy on push * chore(config): add base path for assets and update deployment workflows - Added `NEXT_PUBLIC_BASE_PATH` to `next.config.js` for serving assets from a subpath. - Updated GitHub Actions workflows to retrieve and set the application version from `package.json`. - Modified asset paths in `AppSidebar` and `MobileTopBar` components to use the new base path. These changes enhance the flexibility of asset management and ensure version consistency during deployments. --------- Co-authored-by: DrakeNguyen <drake.ha.nguyen@gmail.com>
1 parent c8acbb6 commit f26a3ff

File tree

5 files changed

+31
-21
lines changed

5 files changed

+31
-21
lines changed

.github/workflows/deploy-pages.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ jobs:
3737
node-version: '20'
3838
cache: 'pnpm'
3939

40+
- name: Get version from package.json
41+
id: version
42+
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
43+
4044
- name: Set base URL for GitHub Pages
4145
id: base_url
4246
run: |
@@ -61,6 +65,7 @@ jobs:
6165
env:
6266
NEXT_PUBLIC_BASE_URL: ${{ steps.base_url.outputs.base_url }}
6367
BASE_PATH: ${{ steps.base_url.outputs.base_path }}
68+
NEXT_PUBLIC_APP_VERSION: ${{ steps.version.outputs.version }}
6469

6570
- name: Upload Pages artifact
6671
uses: actions/upload-pages-artifact@v3

.github/workflows/release.yml

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -185,33 +185,36 @@ jobs:
185185
id: deployment
186186
uses: actions/deploy-pages@v4
187187

188-
- name: Verify package.json version matches tag
188+
- name: Sync package.json version to tag
189189
if: success()
190-
continue-on-error: true
191190
run: |
192191
VERSION="${{ steps.tag_version.outputs.version }}"
193-
TAG_NAME="${{ steps.tag_version.outputs.tag_name }}"
194-
195-
# Check version in package.json from the tag
196192
CURRENT_VERSION=$(node -p "require('./package.json').version")
197193
198194
if [ "$CURRENT_VERSION" = "$VERSION" ]; then
199-
echo "✅ package.json version ($CURRENT_VERSION) matches release tag ($TAG_NAME)"
200-
echo "✅ Version sync verified - following Approach 1 (Update Before Tagging)"
201-
else
202-
echo "⚠️ WARNING: package.json version ($CURRENT_VERSION) does not match release tag ($TAG_NAME)"
203-
echo ""
204-
echo "📋 Recommended workflow (Approach 1):"
205-
echo " 1. Update package.json version to $VERSION"
206-
echo " 2. Commit and push (via PR if branch is protected)"
207-
echo " 3. Then create the release tag"
208-
echo ""
209-
echo "💡 For this release, the tag was created but package.json is out of sync."
210-
echo " Please manually update package.json to $VERSION to keep them in sync."
211-
echo ""
212-
echo "⚠️ This is a warning only - the release will continue."
195+
echo "✅ package.json version ($CURRENT_VERSION) already matches tag"
196+
exit 0
213197
fi
214198
199+
echo "📝 Updating package.json from $CURRENT_VERSION to $VERSION"
200+
git config user.name "github-actions[bot]"
201+
git config user.email "github-actions[bot]@users.noreply.github.com"
202+
203+
# Checkout default branch (tag push leaves us in detached HEAD)
204+
git fetch origin ${{ github.event.repository.default_branch }}
205+
git checkout ${{ github.event.repository.default_branch }}
206+
207+
# Update package.json
208+
node -e "
209+
const pkg = require('./package.json');
210+
pkg.version = '$VERSION';
211+
require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
212+
"
213+
214+
git add package.json
215+
git commit -m "chore: bump version to $VERSION"
216+
git push origin ${{ github.event.repository.default_branch }}
217+
215218
- name: Upload build artifacts
216219
if: success()
217220
uses: actions/upload-artifact@v4

next.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const nextConfig = {
1717
NEXT_PUBLIC_APP_VERSION: process.env.NEXT_PUBLIC_APP_VERSION || 'dev',
1818
// Base URL for metadata, sitemap, canonical URLs. Required for self-hosting.
1919
NEXT_PUBLIC_BASE_URL: process.env.NEXT_PUBLIC_BASE_URL || 'https://devpockit.hypkey.com',
20+
// Base path for assets when serving from subpath (e.g. /devpockit). Used for logo, etc.
21+
NEXT_PUBLIC_BASE_PATH: process.env.BASE_PATH || '',
2022
},
2123
// HTTPS is handled via the dev:https script in package.json
2224
}

src/components/AppSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export function AppSidebar({
188188
<PanelLeft className="h-4 w-4 text-sidebar-foreground" />
189189
) : (
190190
<Image
191-
src="/assets/devpockit-logo.svg"
191+
src={`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/assets/devpockit-logo.svg`}
192192
alt="DevPockit Logo"
193193
width={32}
194194
height={32}

src/components/layout/MobileTopBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function MobileTopBar({ onToolSelect, onHomeClick }: MobileTopBarProps) {
5353
aria-label="Go to homepage"
5454
>
5555
<Image
56-
src="/assets/devpockit-logo.svg"
56+
src={`${process.env.NEXT_PUBLIC_BASE_PATH || ''}/assets/devpockit-logo.svg`}
5757
alt="DevPockit Logo"
5858
width={32}
5959
height={32}

0 commit comments

Comments
 (0)