-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (47 loc) · 1.72 KB
/
Copy pathauto-release.yml
File metadata and controls
54 lines (47 loc) · 1.72 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
name: Auto-release on dependency update
on:
pull_request:
types: [closed]
jobs:
auto-release:
if: github.event.pull_request.merged == true && github.event.pull_request.user.login == 'dependabot[bot]'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Run tests before release
run: |
pip install pytest
PYTHONPATH=src pytest tests/ -q
- name: Bump patch version
run: |
CURRENT=$(grep 'version = ' pyproject.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
sed -i "s/version = \"$CURRENT\"/version = \"$NEW_VERSION\"/" pyproject.toml
sed -i "s/__version__ = \"$CURRENT\"/__version__ = \"$NEW_VERSION\"/" src/rakib/__init__.py
echo "VERSION=$NEW_VERSION" >> "$GITHUB_ENV"
- name: Commit version bump
env:
VERSION: ${{ env.VERSION }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add pyproject.toml src/rakib/__init__.py
git commit -m "release: v${VERSION} (dependency update)"
git push
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ env.VERSION }}
run: |
gh release create "v${VERSION}" \
--title "Rakib v${VERSION}" \
--notes "Patch release — dependency update from Dependabot." \
--latest