forked from smart-social-contracts/kybra-simple-db
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (76 loc) · 2.83 KB
/
release.yml
File metadata and controls
84 lines (76 loc) · 2.83 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Create new release
on:
workflow_run:
workflows: ["Test", "Test IC"]
types:
- completed
branches: [main]
workflow_dispatch: # Allows manual triggering without restrictions
inputs:
release_type:
description: 'Type of release (patch, minor, major)'
required: false
default: 'patch'
type: choice
options:
- patch
- minor
- major
create_github_release:
description: 'Create GitHub Release'
required: false
default: true
type: boolean
jobs:
deploy:
# Only run if the workflow_run event was successful or if it's a manual dispatch
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build setuptools wheel bumpversion
# Only perform version bump if release_type is provided
- name: Bump version
if: ${{ github.event.inputs.release_type != '' }}
id: bump_version
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
# Run bumpversion to update version in files
bumpversion ${{ github.event.inputs.release_type }}
# Extract and verify the new version from setup.py
NEW_VERSION=$(grep -Po '(?<=version="|version=\")[^"]*' setup.py)
# Also get version from .bumpversion.cfg to verify they match
BUMP_VERSION=$(grep -Po '(?<=current_version = )[^\s]*' .bumpversion.cfg)
# Make sure versions match
if [ "$NEW_VERSION" != "$BUMP_VERSION" ]; then
echo "ERROR: Version mismatch between setup.py ($NEW_VERSION) and .bumpversion.cfg ($BUMP_VERSION)"
exit 1
fi
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "New version: $NEW_VERSION"
# Only push changes if we did a version bump
- name: Push changes
if: ${{ github.event.inputs.release_type != '' }}
run: |
git push origin
git push origin --tags
# Only create a GitHub release if we did a version bump and the user requested it
- name: Create Release
if: ${{ github.event.inputs.release_type != '' && github.event.inputs.create_github_release == 'true' }}
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.bump_version.outputs.NEW_VERSION }}
name: Release v${{ steps.bump_version.outputs.NEW_VERSION }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}