Skip to content

Commit 9d1bc0c

Browse files
feat(.github/actions): add new job for weekly release
1 parent e234b49 commit 9d1bc0c

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Weekly Release
2+
3+
on:
4+
# TODO(sambhav-jain-16): enable the schedule after testing manually
5+
# schedule:
6+
# - cron: '0 0 * * 1' # Every Monday at 00:00 UTC
7+
workflow_dispatch:
8+
inputs:
9+
release_type:
10+
description: 'Bump type for this run. auto = detect from merged PR bodies (release-type: minor/major), falling back to patch.'
11+
required: false
12+
type: choice
13+
options:
14+
- auto
15+
- patch
16+
- minor
17+
- major
18+
default: auto
19+
20+
permissions:
21+
contents: write
22+
23+
concurrency:
24+
group: release
25+
cancel-in-progress: false
26+
27+
jobs:
28+
release:
29+
name: Create Release
30+
runs-on: ubuntu-latest
31+
if: github.ref == 'refs/heads/master'
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Check for new commits since last tag
38+
id: check
39+
run: |
40+
LATEST=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
41+
if [ -z "$LATEST" ]; then
42+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
43+
else
44+
COUNT=$(git rev-list "${LATEST}..HEAD" --count)
45+
echo "has_changes=$([ "$COUNT" -gt 0 ] && echo true || echo false)" >> "$GITHUB_OUTPUT"
46+
fi
47+
48+
# ── Auto path: detect bump from 'release-type:' markers in PR bodies ──
49+
- name: Bump version and create tag
50+
id: tag_auto
51+
if: steps.check.outputs.has_changes == 'true' && (github.event_name != 'workflow_dispatch' || github.event.inputs.release_type == 'auto')
52+
uses: mathieudutour/github-tag-action@v6.2
53+
with:
54+
github_token: ${{ secrets.GITHUB_TOKEN }}
55+
default_bump: patch
56+
major_string_token: 'release-type: major'
57+
minor_string_token: 'release-type: minor'
58+
patch_string_token: 'release-type: patch'
59+
release_branches: master
60+
61+
# ── Explicit path: manual override, bypass keyword detection ──────────
62+
- name: Get previous tag
63+
id: prev_tag
64+
if: steps.check.outputs.has_changes == 'true' && github.event_name == 'workflow_dispatch' && github.event.inputs.release_type != 'auto'
65+
uses: WyriHaximus/github-action-get-previous-tag@v1
66+
with:
67+
fallback: v0.0.0
68+
69+
- name: Compute next version
70+
id: next_version
71+
if: steps.check.outputs.has_changes == 'true' && github.event_name == 'workflow_dispatch' && github.event.inputs.release_type != 'auto'
72+
uses: actions-ecosystem/action-bump-semver@v1
73+
with:
74+
current_version: ${{ steps.prev_tag.outputs.tag }}
75+
level: ${{ github.event.inputs.release_type }}
76+
77+
- name: Create tag for manual override
78+
if: steps.check.outputs.has_changes == 'true' && github.event_name == 'workflow_dispatch' && github.event.inputs.release_type != 'auto'
79+
uses: mathieudutour/github-tag-action@v6.2
80+
with:
81+
github_token: ${{ secrets.GITHUB_TOKEN }}
82+
custom_tag: ${{ steps.next_version.outputs.new_version }}
83+
release_branches: master
84+
85+
# ── Release ────────────────────────────────────────────────────────────
86+
- name: Create GitHub release
87+
if: steps.check.outputs.has_changes == 'true'
88+
uses: softprops/action-gh-release@v3
89+
with:
90+
tag_name: ${{ steps.tag_auto.outputs.new_tag || steps.next_version.outputs.new_version }}
91+
name: Release ${{ steps.tag_auto.outputs.new_tag || steps.next_version.outputs.new_version }}
92+
generate_release_notes: true
93+
94+
- name: No new commits, skipping release
95+
if: steps.check.outputs.has_changes == 'false'
96+
run: echo "Skipping — no commits since last tag."
97+

0 commit comments

Comments
 (0)