Skip to content

Commit 977a011

Browse files
committed
Automatically cut release each month
1 parent 91cb1ff commit 977a011

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/release.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Automated Release
2+
3+
on:
4+
schedule:
5+
# Runs at 2:00 AM UTC on the first Saturday of every month
6+
- cron: '0 2 * * 6'
7+
workflow_dispatch: # Allow manual triggering of the workflow
8+
9+
jobs:
10+
check-and-release:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Check for changes since last release
20+
run: |
21+
if [ -z "$(git diff --name-only ${{ env.latest_tag }})" ]; then
22+
echo "No changes detected since last release"
23+
exit 1
24+
fi
25+
26+
- name: Check for Blocking Issues/PRs
27+
id: check_blocks
28+
run: |
29+
gh auth setup-git
30+
gh auth status
31+
32+
echo "Checking for blocking issues and PRs..."
33+
34+
# Check for blocking issues
35+
blocking_issues=$(gh issue list -l blocks-release --json number,title --jq '.[] | "- \(.title) (#\(.number))"')
36+
37+
# Check for blocking PRs
38+
blocking_prs=$(gh pr list -l blocks-release --json number,title --jq '.[] | "- \(.title) (#\(.number)) (PR)"')
39+
40+
# Combine the results
41+
blocking_items="$blocking_issues"$'\n'"$blocking_prs"
42+
43+
# Remove empty lines
44+
blocking_items=$(echo "$blocking_items" | grep . || true)
45+
46+
if [ -n "$blocking_items" ]; then
47+
echo "Blocking issues/PRs detected:"
48+
echo "$blocking_items"
49+
exit 1
50+
fi
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Calculate next version
55+
run: |
56+
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1) || echo "v0.0.0")
57+
echo "Latest tag: $latest_tag"
58+
IFS='.' read -r major minor patch <<< "$latest_tag"
59+
new_minor=$((minor + 1))
60+
new_tag="$major.$new_minor.0"
61+
echo "New tag: $new_tag"
62+
echo "new_tag=$new_tag" >> $GITHUB_ENV
63+
64+
# This will trigger a deploy via .github/workflows/cd.yml
65+
- name: Push New Tag
66+
run: |
67+
git config user.name "github-actions[bot]"
68+
git config user.email "github-actions[bot]@users.noreply.github.com"
69+
git tag ${{ env.new_tag }}
70+
git push origin ${{ env.new_tag }}
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)