Skip to content

Commit a88ea9e

Browse files
jacobparisactions-userkodykentcdoddskody
authored
Store epic-stack latest commit hash in the package.json (#805)
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]>
1 parent ffc7d04 commit a88ea9e

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

.github/workflows/version.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: 🔖 Version
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- dev
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
version:
17+
name: 🚀 Update Version
18+
runs-on: ubuntu-22.04
19+
if: ${{ github.event_name == 'push' }}
20+
21+
steps:
22+
- name: ⬇️ Checkout repo
23+
uses: actions/checkout@v4
24+
25+
- name: 🔢 Get HEAD commit hash
26+
id: get_head_hash
27+
run: echo "HEAD_HASH=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
28+
29+
- name: 📅 Get current date
30+
id: get_date
31+
run:
32+
echo "CURRENT_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
33+
34+
- name: 📝 Update package.json
35+
run: |
36+
jq '
37+
if .["epic-stack"] then
38+
.["epic-stack"].head = "${{ steps.get_head_hash.outputs.HEAD_HASH }}" |
39+
.["epic-stack"].date = "${{ steps.get_date.outputs.CURRENT_DATE }}"
40+
else
41+
.["epic-stack"] = {
42+
"head": "${{ steps.get_head_hash.outputs.HEAD_HASH }}",
43+
"date": "${{ steps.get_date.outputs.CURRENT_DATE }}"
44+
}
45+
end
46+
' package.json > temp.json && mv temp.json package.json
47+
48+
- name: 💾 Commit changes
49+
run: |
50+
git config --local user.email "[email protected]"
51+
git config --local user.name "kody"
52+
git add package.json
53+
git commit -m "Update epic-stack version [skip ci]"
54+
git push

docs/managing-updates.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ peruse
4848
[the Epic Stack's commit history](https://github.com/epicweb-dev/epic-stack/commits/main)
4949
anytime you'd like to see what updates could be made to your project.
5050

51+
Check the [epic-stack field in the package.json file](../package.json) to see
52+
what the date and commit hash were when you created your project.
53+
5154
## How to update NPM dependencies
5255

5356
Another part of the Epic Stack is the dependencies of the project. These you

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"private": true,
44
"sideEffects": false,
55
"license": "MIT",
6-
"epic-stack": true,
6+
"epic-stack": {
7+
"head": "6c9d4d2b353e54d70f0378854af95c4cdfd6515e",
8+
"date": "2024-08-03T00:02:41Z"
9+
},
710
"author": "Kent C. Dodds <[email protected]> (https://kentcdodds.com/)",
811
"type": "module",
912
"imports": {

remix.init/index.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export default async function main({ rootDirectory }) {
6666
fs.rm(path.join(rootDirectory, 'docs'), { recursive: true }),
6767
fs.rm(path.join(rootDirectory, 'tests/e2e/notes.test.ts')),
6868
fs.rm(path.join(rootDirectory, 'tests/e2e/search.test.ts')),
69+
fs.rm(path.join(rootDirectory, '.github/workflows/version.yml')),
6970
]
7071

7172
await Promise.all(fileOperationPromises)

0 commit comments

Comments
 (0)