-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (41 loc) · 1.58 KB
/
auto-tag.yaml
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
name: Auto Tag on Merge
on:
pull_request:
types: [closed]
branches:
- main
jobs:
create-tag:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: anothrNick/github-tag-action@1.71.0
name: Get next version
id: get_version
env:
DEFAULT_BUMP: patch
WITH_V: true
DEFAULT_BRANCH: main
RELEASE_BRANCHES: main
DRY_RUN: true # don't actually create tag, I want to create it after updating the python version file
- name: Update __version__.py
run: echo "__version__ = \"${{ steps.get_version.outputs.new_tag }}\"" > src/beeperpurge/__version__.py
- name: Commit version update
uses: EndBug/add-and-commit@v9
with:
author_name: GitHub Actions
author_email: actions@github.com
message: 'Update __version__.py'
add: 'src/beeperpurge/__version__.py'
- name: Get version from package # We intentionally take the version from the updated file and not run github-tag-action again
id: get_version_from_file
run: |
PACKAGE_VERSION=$(python -c "from src.beeperpurge.__version__ import __version__; print(__version__)")
echo "version=${PACKAGE_VERSION}" >> $GITHUB_OUTPUT
- name: Create and push tag
run: |
git tag "v${{ steps.get_version_from_file.outputs.version }}"
git push origin "v${{ steps.get_version_from_file.outputs.version }}"