-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (47 loc) · 1.7 KB
/
Copy pathrelease.yml
File metadata and controls
59 lines (47 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Update README if major version changed
run: |
TAG=${GITHUB_REF#refs/tags/}
MAJOR=$(echo $TAG | cut -d. -f1)
# Get current major version from README
CURRENT=$(grep -oP 'github-streak-stats-action@v\K[0-9]+' README.md | head -1 || echo "")
if [ -n "$CURRENT" ] && [ "$CURRENT" != "${MAJOR#v}" ]; then
echo "Updating README from v$CURRENT to $MAJOR"
# Update all references in README
sed -i "s/github-streak-stats-action@v$CURRENT/github-streak-stats-action@$MAJOR/g" README.md
# Commit and push to main branch
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "Update README to use $MAJOR"
git push origin HEAD:main
else
echo "README already up to date with $MAJOR"
fi
- name: Create release
uses: softprops/action-gh-release@v3
with:
generate_release_notes: true
make_latest: true
- name: Update major version tag
run: |
TAG=${GITHUB_REF#refs/tags/}
MAJOR=$(echo $TAG | cut -d. -f1)
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -f $MAJOR
git push -f origin $MAJOR