added verioning system and stable branch
Browse files- .github/workflows/update-stable.yml +154 -0
- package.json +1 -0
.github/workflows/update-stable.yml
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Update Stable Branch
|
2 |
+
|
3 |
+
on:
|
4 |
+
pull_request:
|
5 |
+
types: [closed]
|
6 |
+
branches:
|
7 |
+
- main
|
8 |
+
|
9 |
+
jobs:
|
10 |
+
update-stable:
|
11 |
+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'stable-release')
|
12 |
+
runs-on: ubuntu-latest
|
13 |
+
|
14 |
+
steps:
|
15 |
+
- uses: actions/checkout@v4
|
16 |
+
with:
|
17 |
+
fetch-depth: 0
|
18 |
+
|
19 |
+
- name: Configure Git
|
20 |
+
run: |
|
21 |
+
git config --global user.name 'GitHub Action'
|
22 |
+
git config --global user.email '[email protected]'
|
23 |
+
|
24 |
+
- name: Setup Node.js
|
25 |
+
uses: actions/setup-node@v4
|
26 |
+
with:
|
27 |
+
node-version: '20'
|
28 |
+
|
29 |
+
- name: Determine Version Bump
|
30 |
+
id: version_bump
|
31 |
+
run: |
|
32 |
+
if contains(github.event.pull_request.labels.*.name, 'major')
|
33 |
+
echo "bump=major" >> $GITHUB_OUTPUT
|
34 |
+
elif contains(github.event.pull_request.labels.*.name, 'minor')
|
35 |
+
echo "bump=minor" >> $GITHUB_OUTPUT
|
36 |
+
else
|
37 |
+
echo "bump=patch" >> $GITHUB_OUTPUT
|
38 |
+
fi
|
39 |
+
|
40 |
+
- name: Get Current Version
|
41 |
+
id: current_version
|
42 |
+
run: |
|
43 |
+
CURRENT_VERSION=$(node -p "require('./package.json').version")
|
44 |
+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
45 |
+
|
46 |
+
- name: Bump Version
|
47 |
+
id: bump_version
|
48 |
+
run: |
|
49 |
+
npm install -g semver
|
50 |
+
NEW_VERSION=$(semver -i ${{ steps.version_bump.outputs.bump }} ${{ steps.current_version.outputs.version }})
|
51 |
+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
52 |
+
|
53 |
+
- name: Update Package.json
|
54 |
+
run: |
|
55 |
+
NEW_VERSION=${{ steps.bump_version.outputs.new_version }}
|
56 |
+
npm version $NEW_VERSION --no-git-tag-version
|
57 |
+
|
58 |
+
- name: Generate Changelog
|
59 |
+
id: changelog
|
60 |
+
run: |
|
61 |
+
# Get the latest tag
|
62 |
+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
|
63 |
+
|
64 |
+
if [ -z "$LATEST_TAG" ]; then
|
65 |
+
# If no tags exist, get all commits
|
66 |
+
echo "### π First Release" >> changelog.md
|
67 |
+
echo "" >> changelog.md
|
68 |
+
else
|
69 |
+
# Get commits since last tag
|
70 |
+
echo "### π Changes since $LATEST_TAG" >> changelog.md
|
71 |
+
echo "" >> changelog.md
|
72 |
+
fi
|
73 |
+
|
74 |
+
# Function to extract conventional commit type
|
75 |
+
get_commit_type() {
|
76 |
+
if [[ $1 =~ ^feat: ]]; then echo "β¨ Features";
|
77 |
+
elif [[ $1 =~ ^fix: ]]; then echo "π Bug Fixes";
|
78 |
+
elif [[ $1 =~ ^docs: ]]; then echo "π Documentation";
|
79 |
+
elif [[ $1 =~ ^style: ]]; then echo "π Styles";
|
80 |
+
elif [[ $1 =~ ^refactor: ]]; then echo "β»οΈ Code Refactoring";
|
81 |
+
elif [[ $1 =~ ^perf: ]]; then echo "β‘οΈ Performance Improvements";
|
82 |
+
elif [[ $1 =~ ^test: ]]; then echo "β
Tests";
|
83 |
+
elif [[ $1 =~ ^build: ]]; then echo "π οΈ Build System";
|
84 |
+
elif [[ $1 =~ ^ci: ]]; then echo "βοΈ CI";
|
85 |
+
elif [[ $1 =~ ^chore: ]]; then echo "π§ Chores";
|
86 |
+
else echo "π Other Changes";
|
87 |
+
fi
|
88 |
+
}
|
89 |
+
|
90 |
+
# Generate categorized changelog
|
91 |
+
CATEGORIES=()
|
92 |
+
declare -A COMMITS_BY_CATEGORY
|
93 |
+
|
94 |
+
# Get commits since last tag or all commits if no tag exists
|
95 |
+
if [ -z "$LATEST_TAG" ]; then
|
96 |
+
git log --pretty=format:"%s" > temp_commits.txt
|
97 |
+
else
|
98 |
+
git log ${LATEST_TAG}..HEAD --pretty=format:"%s" > temp_commits.txt
|
99 |
+
fi
|
100 |
+
|
101 |
+
while IFS= read -r commit; do
|
102 |
+
CATEGORY=$(get_commit_type "$commit")
|
103 |
+
if [[ ! " ${CATEGORIES[@]} " =~ " ${CATEGORY} " ]]; then
|
104 |
+
CATEGORIES+=("$CATEGORY")
|
105 |
+
fi
|
106 |
+
COMMITS_BY_CATEGORY["$CATEGORY"]+="- ${commit#*: }"$'\n'
|
107 |
+
done < temp_commits.txt
|
108 |
+
|
109 |
+
# Write categorized commits to changelog
|
110 |
+
for category in "${CATEGORIES[@]}"; do
|
111 |
+
if [ -n "${COMMITS_BY_CATEGORY[$category]}" ]; then
|
112 |
+
echo "#### $category" >> changelog.md
|
113 |
+
echo "" >> changelog.md
|
114 |
+
echo "${COMMITS_BY_CATEGORY[$category]}" >> changelog.md
|
115 |
+
echo "" >> changelog.md
|
116 |
+
fi
|
117 |
+
done
|
118 |
+
|
119 |
+
rm temp_commits.txt
|
120 |
+
|
121 |
+
# Save changelog content for the release
|
122 |
+
CHANGELOG_CONTENT=$(cat changelog.md)
|
123 |
+
echo "content<<EOF" >> $GITHUB_OUTPUT
|
124 |
+
echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
|
125 |
+
echo "EOF" >> $GITHUB_OUTPUT
|
126 |
+
|
127 |
+
- name: Commit Version Update
|
128 |
+
run: |
|
129 |
+
git add package.json package-lock.json
|
130 |
+
git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }}"
|
131 |
+
git push origin main
|
132 |
+
|
133 |
+
- name: Update Stable Branch
|
134 |
+
run: |
|
135 |
+
git checkout stable
|
136 |
+
git merge main
|
137 |
+
git push origin stable
|
138 |
+
|
139 |
+
- name: Create and Push Tag
|
140 |
+
run: |
|
141 |
+
VERSION="v${{ steps.bump_version.outputs.new_version }}"
|
142 |
+
git tag -a "$VERSION" -m "Release $VERSION"
|
143 |
+
git push origin "$VERSION"
|
144 |
+
|
145 |
+
- name: Create GitHub Release
|
146 |
+
env:
|
147 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
148 |
+
run: |
|
149 |
+
VERSION="v${{ steps.bump_version.outputs.new_version }}"
|
150 |
+
|
151 |
+
# Create release with generated changelog
|
152 |
+
gh release create "$VERSION" \
|
153 |
+
--title "Release $VERSION" \
|
154 |
+
--notes "${{ steps.changelog.outputs.content }}"
|
package.json
CHANGED
@@ -5,6 +5,7 @@
|
|
5 |
"license": "MIT",
|
6 |
"sideEffects": false,
|
7 |
"type": "module",
|
|
|
8 |
"scripts": {
|
9 |
"deploy": "npm run build && wrangler pages deploy",
|
10 |
"build": "remix vite:build",
|
|
|
5 |
"license": "MIT",
|
6 |
"sideEffects": false,
|
7 |
"type": "module",
|
8 |
+
"version": "0.0.0",
|
9 |
"scripts": {
|
10 |
"deploy": "npm run build && wrangler pages deploy",
|
11 |
"build": "remix vite:build",
|