Skip to content

Commit

Permalink
Store epic-stack latest commit hash in the package.json (#805)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: kody <[email protected]>
Co-authored-by: Kent C. Dodds <[email protected]>
Co-authored-by: kody <[email protected]>
  • Loading branch information
5 people authored Aug 3, 2024
1 parent ffc7d04 commit a88ea9e
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 🔖 Version
on:
push:
branches:
- main
- dev

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write

jobs:
version:
name: 🚀 Update Version
runs-on: ubuntu-22.04
if: ${{ github.event_name == 'push' }}

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🔢 Get HEAD commit hash
id: get_head_hash
run: echo "HEAD_HASH=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- name: 📅 Get current date
id: get_date
run:
echo "CURRENT_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT

- name: 📝 Update package.json
run: |
jq '
if .["epic-stack"] then
.["epic-stack"].head = "${{ steps.get_head_hash.outputs.HEAD_HASH }}" |
.["epic-stack"].date = "${{ steps.get_date.outputs.CURRENT_DATE }}"
else
.["epic-stack"] = {
"head": "${{ steps.get_head_hash.outputs.HEAD_HASH }}",
"date": "${{ steps.get_date.outputs.CURRENT_DATE }}"
}
end
' package.json > temp.json && mv temp.json package.json
- name: 💾 Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "kody"
git add package.json
git commit -m "Update epic-stack version [skip ci]"
git push
3 changes: 3 additions & 0 deletions docs/managing-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ peruse
[the Epic Stack's commit history](https://github.com/epicweb-dev/epic-stack/commits/main)
anytime you'd like to see what updates could be made to your project.

Check the [epic-stack field in the package.json file](../package.json) to see
what the date and commit hash were when you created your project.

## How to update NPM dependencies

Another part of the Epic Stack is the dependencies of the project. These you
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"private": true,
"sideEffects": false,
"license": "MIT",
"epic-stack": true,
"epic-stack": {
"head": "6c9d4d2b353e54d70f0378854af95c4cdfd6515e",
"date": "2024-08-03T00:02:41Z"
},
"author": "Kent C. Dodds <[email protected]> (https://kentcdodds.com/)",
"type": "module",
"imports": {
Expand Down
1 change: 1 addition & 0 deletions remix.init/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default async function main({ rootDirectory }) {
fs.rm(path.join(rootDirectory, 'docs'), { recursive: true }),
fs.rm(path.join(rootDirectory, 'tests/e2e/notes.test.ts')),
fs.rm(path.join(rootDirectory, 'tests/e2e/search.test.ts')),
fs.rm(path.join(rootDirectory, '.github/workflows/version.yml')),
]

await Promise.all(fileOperationPromises)
Expand Down

0 comments on commit a88ea9e

Please sign in to comment.