-
Notifications
You must be signed in to change notification settings - Fork 2
62 lines (52 loc) · 1.84 KB
/
version.yml
File metadata and controls
62 lines (52 loc) · 1.84 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
60
61
62
name: Create Tag and Draft Release with Notes
on:
push:
branches:
- trunk
paths:
- 'setup.py'
workflow_dispatch:
permissions:
contents: write
jobs:
check-and-extract:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
tag-exists: ${{ steps.check-tag.outputs.exists }}
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Extract version from setup.py
id: get-version
run: |
VERSION=$(cat setup.py | grep -E '^ +version="[0-9.]+",' | cut -d'"' -f2)
echo "Extracted version is $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Check if tag exists
id: check-tag
run: |
if git tag | grep -q "${{ steps.get-version.outputs.version }}"; then
echo "Tag exists"
echo "exists=1" >> "$GITHUB_OUTPUT"
else
echo "Tag does not exist"
echo "exists=0" >> "$GITHUB_OUTPUT"
fi
create-tag-and-release:
needs: check-and-extract
if: needs.check-and-extract.outputs.tag-exists == '0'
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Create and push tag
run: |
git config --global user.name "GitHub Action"
git config --global user.email "action@github.com"
git tag "v${{ needs.check-and-extract.outputs.version }}"
git push origin "v${{ needs.check-and-extract.outputs.version }}"
- name: Draft a new release with autogenerated notes
run: |
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
gh release create "v${{ needs.check-and-extract.outputs.version }}" --title "Release v${{ needs.check-and-extract.outputs.version }}" --generate-notes --draft