Skip to content

Commit 9ce7252

Browse files
committed
feat(config): added auto-releasing workflow
1 parent 2a02388 commit 9ce7252

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Weekly Release
2+
3+
on:
4+
schedule:
5+
# Run every Tuesday at 1:00 PM EST (6:00 PM UTC)
6+
- cron: '0 18 * * 2'
7+
workflow_dispatch: # Allow manual trigger
8+
inputs:
9+
dry_run:
10+
description: 'Dry run mode (test without creating release)'
11+
required: false
12+
type: boolean
13+
default: false
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
create-release:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v5
25+
with:
26+
fetch-depth: 0
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Check for new commits
30+
id: check_commits
31+
run: |
32+
# Get the latest tag
33+
latest_tag=$(git tag --sort=-v:refname | head -n 1)
34+
35+
if [ -z "$latest_tag" ]; then
36+
echo "No existing tags found, will create initial release"
37+
echo "has_changes=true" >> $GITHUB_OUTPUT
38+
echo "latest_tag=" >> $GITHUB_OUTPUT
39+
else
40+
echo "Latest tag: $latest_tag"
41+
42+
# Check if there are any commits since the latest tag
43+
commit_count=$(git rev-list ${latest_tag}..HEAD --count)
44+
45+
if [ "$commit_count" -eq 0 ]; then
46+
echo "No new commits since $latest_tag, skipping release"
47+
echo "has_changes=false" >> $GITHUB_OUTPUT
48+
else
49+
echo "Found $commit_count new commit(s) since $latest_tag"
50+
echo "has_changes=true" >> $GITHUB_OUTPUT
51+
fi
52+
53+
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT
54+
fi
55+
56+
- name: Calculate next version
57+
if: steps.check_commits.outputs.has_changes == 'true'
58+
id: version
59+
run: |
60+
latest_tag="${{ steps.check_commits.outputs.latest_tag }}"
61+
62+
if [ -z "$latest_tag" ]; then
63+
echo "No existing tags found, starting with v.1.0.0"
64+
new_tag="v.1.0.0"
65+
else
66+
# Extract the minor version number from v.1.X.0 format
67+
minor_version=$(echo $latest_tag | sed -E 's/v\.1\.([0-9]+)\.0/\1/')
68+
next_minor=$((minor_version + 1))
69+
new_tag="v.1.${next_minor}.0"
70+
fi
71+
72+
echo "new_tag=$new_tag" >> $GITHUB_OUTPUT
73+
echo "Creating new tag: $new_tag"
74+
75+
- name: Create Release (Dry Run)
76+
if: steps.check_commits.outputs.has_changes == 'true' && inputs.dry_run == true
77+
run: |
78+
echo "🧪 DRY RUN MODE - No release will be created"
79+
echo "Would create release with tag: ${{ steps.version.outputs.new_tag }}"
80+
echo "Title: Release ${{ steps.version.outputs.new_tag }}"
81+
echo "Notes: Automated weekly release"
82+
echo "Generate release notes: Yes"
83+
echo ""
84+
echo "✅ Dry run completed successfully"
85+
86+
- name: Create Release
87+
if: steps.check_commits.outputs.has_changes == 'true' && inputs.dry_run != true
88+
env:
89+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
run: |
91+
gh release create "${{ steps.version.outputs.new_tag }}" \
92+
--title "Release ${{ steps.version.outputs.new_tag }}" \
93+
--notes "Automated weekly release" \
94+
--generate-notes

0 commit comments

Comments
 (0)