-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (49 loc) · 1.75 KB
/
publish-version-gh.yaml
File metadata and controls
56 lines (49 loc) · 1.75 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
name: Publish version to GitHub
on:
push:
branches:
- main
jobs:
create-version:
name: Create GH version and tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set version
id: set-version
run: |
POETRY_VERSION=$(grep -E '^requires-poetry = ' pyproject.toml | sed -E 's/requires-poetry = "(.*)"/\1/')
pip install poetry==$POETRY_VERSION
VERSION=$(poetry version -s)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Check if release exists
id: check-release
env:
VERSION: ${{ steps.set-version.outputs.VERSION }}
run: |
git fetch --tags
if [ -n "$(git tag -l "$VERSION")" ]; then
echo "## ⚠️ Tag $VERSION already exists in git. Skipping publish." >> $GITHUB_STEP_SUMMARY
echo "skip_publish=true" >> $GITHUB_OUTPUT
else
echo "skip_publish=false" >> $GITHUB_OUTPUT
fi
- name: Create and push annotated git tag
if: steps.check-release.outputs.skip_publish != 'true'
env:
VERSION: ${{ steps.set-version.outputs.VERSION }}
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git tag -a "$VERSION" -m "Release $VERSION"
git push origin "$VERSION"
- name: Create GitHub release
if: steps.check-release.outputs.skip_publish != 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.set-version.outputs.VERSION }}
name: Release ${{ steps.set-version.outputs.VERSION }}
generate_release_notes: true