Skip to content

Commit eedcf60

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

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Check for new commits since last tag
37+
id: check
38+
run: |
39+
LATEST=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
40+
if [ -z "$LATEST" ]; then
41+
COUNT=$(git rev-list HEAD --count)
42+
else
43+
COUNT=$(git rev-list "${LATEST}..HEAD" --count)
44+
fi
45+
if [ "$COUNT" -gt 0 ]; then
46+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
47+
else
48+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
49+
echo "No commits since ${LATEST}, skipping release."
50+
fi
51+
52+
- name: Bump version and create tag
53+
id: tag
54+
if: steps.check.outputs.has_changes == 'true'
55+
uses: mathieudutour/github-tag-action@v6.2
56+
with:
57+
github_token: ${{ secrets.GITHUB_TOKEN }}
58+
default_bump: ${{ (github.event.inputs.release_type == 'auto' || github.event.inputs.release_type == '') && 'patch' || github.event.inputs.release_type }}
59+
major_string_token: 'release-type: major'
60+
minor_string_token: 'release-type: minor'
61+
patch_string_token: 'release-type: patch'
62+
with_v: true
63+
release_branches: master
64+
65+
- name: Create GitHub release
66+
if: steps.check.outputs.has_changes == 'true'
67+
uses: softprops/action-gh-release@v3
68+
with:
69+
tag_name: ${{ steps.tag.outputs.new_tag }}
70+
name: Release ${{ steps.tag.outputs.new_tag }}
71+
generate_release_notes: true
72+
73+
- name: No new commits, skipping release
74+
if: steps.check.outputs.has_changes == 'false'
75+
run: echo "Skipping — no commits since last tag."

0 commit comments

Comments
 (0)