-
Notifications
You must be signed in to change notification settings - Fork 1
62 lines (51 loc) · 1.92 KB
/
release.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Automated Release Process
on:
push:
branches:
- 12-31-_add_release_workflow
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install toml
- name: Determine Version Change
id: version_check
run: |
# Function to extract version from pyproject.toml
function get_current_version() {
python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])"
}
# Function to get the latest release version from GitHub
function get_latest_release_version() {
curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/releases/latest \
| jq -r '.tag_name'
}
VERSION=$(get_current_version)
echo "Current version: $VERSION"
LATEST_RELEASE=$(get_latest_release_version)
echo "Latest release version: $LATEST_RELEASE"
if [ "$VERSION" != "$LATEST_RELEASE" ]; then
echo "Version has changed."
echo "version_changed=true" >> $GITHUB_ENV
echo ::set-output name=version_changed::true
echo ::set-output name=new_version::$VERSION
else
echo "No version change detected."
echo "version_changed=false" >> $GITHUB_ENV
echo ::set-output name=version_changed::false
fi
- name: Create Release
if: steps.version_check.outputs.version_changed == 'true'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version_check.outputs.new_version }}