epicweb-dev / epic-stack

This is a Full Stack app starter with the foundational things setup and configured for you to hit the ground running on your next EPIC idea.
https://www.epicweb.dev/epic-stack
MIT License
4.32k stars 355 forks source link

Store epic-stack latest commit hash in the package.json #805

Closed jacobparis closed 1 month ago

jacobparis commented 1 month ago

This PR adds a new Github Actions workflow that writes the current HEAD commit and the date to the package.json as a version tracking scheme. Epic Stack apps can use this to see when they detached from the original epic stack when trying to follow along with changes.

Anyone who clones the repo or uses npx create remix --template or npx create epic-app will have that hash automatically,

During this setup step, the version action is removed so it won't affect consumers of the stack in an ongoing basis.

Future automated tooling 👀 👀 👀 could use this to apply a series of commits automatically

This only applies during pushes to main/dev, all the extra commits in this PR come from that I was pushing to main directly to test it.

Merott commented 3 weeks ago

Thanks @jacobparis.

I'm now using this process to pull the latest changes from epic-stack into my own project:

# Clone the repo into a temporary directory and set up a branch for the update
TEMP_DIR=$(mktemp -d)
git clone --single-branch --branch main --depth 1 $(git remote get-url origin) "$TEMP_DIR/epic-stack-update"
cd "$TEMP_DIR/epic-stack-update"
git checkout -b epic-stack-update

# Add epic-stack as a remote and fetch the latest commits fom main branch
git remote add epic-stack git@github.com:epicweb-dev/epic-stack.git
git fetch epic-stack main

# Extract the last synced commit hash from package.json
LAST_SYNC_COMMIT=$(grep -o '"head": "[^"]*' package.json | sed 's/"head": "//')

# Cherry-pick new commits from Epic Stack
git cherry-pick -x --empty=drop ${LAST_SYNC_COMMIT}..epic-stack/main

# --------- Resolve conflicts (if needed) ---------
# NOTE: Epic Stack-specific files (including the `docs` directory) are not
# included in this repository and are safe to delete in case of conflicts.

# 1. Resolve conflicts in affected files
# 2. Stage resolved files: git add <resolved-file>
# 3. Continue: git cherry-pick --continue
# 4. To abort: git cherry-pick --abort
# -------------------------------------------------

# Switch back to main branch
git checkout main

# Merge epic-stack-update (no fast-forward)
git merge epic-stack-update --no-ff -m "chore: merge latest from epic-stack"

# Push merged changes
git push origin main

# Clean up: return to the original directory and remove the temporary one
cd -
rm -rf "$TEMP_DIR"

# Switch to the main branch and pull changes
git checkout main
git pull origin main