-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
103 lines (92 loc) · 3.22 KB
/
action.yml
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Release new version
description: Release python project on pypi and github
inputs:
pre-release-tag:
description: 'Tag for pre-release'
default: ''
required: true
major-release:
description: 'Trigger a major release. Leave empty for regular release.'
default: ''
required: true
pypi-username:
description: 'Pypi username for deployment'
required: true
pypi-password:
description: 'Pypi password for deployment'
required: true
version-file-path:
description: 'Path to the file containing __version__ = '
required: true
main-branch:
description: 'Name of the main branch in the repo'
default: 'main'
required: false
version-override:
description: 'Override automatic version generation'
required: false
runs:
using: "composite"
steps:
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install argparse build semver twine
shell: bash
- name: Setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
shell: bash
- name: Checkout action repo
uses: actions/checkout@v2
with:
repository: firebolt-db/action-python-release
path: release_action
- name: Generate new version tag
id: tag_generation
if: inputs.version-override == ''
run: |
OLD_TAG=$(git describe --tags --abbrev=0)
echo "Old tag was ${OLD_TAG}"
CHANGE_LOG=$(git log $OLD_TAG..HEAD --pretty=format:%s)
NEW_TAG=$(python3 release_action/scripts/generate_version_tag.py "${CHANGE_LOG}" $OLD_TAG --prerelease_tag "${{ inputs.pre-release-tag }}" --major_release "${{ inputs.major-release }}")
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
shell: bash
- name: Use overridden tag if supplied
id: tag_resolution
run: |
TAG=${{ steps.tag_generation.outputs.new_tag }}${{ inputs.version-override }}
echo "new_tag=${TAG}" >> "${GITHUB_OUTPUT}"
shell: bash
- name: Version bump
run: |
# Bump version = <number> in version file
sed -i "s/^__version__ = .*/__version__ = \"${{ steps.tag_resolution.outputs.new_tag }}\"/" ${{ inputs.version-file-path }}
git add ${{ inputs.version-file-path }}
git commit -m "Automatic version bump to ${{ steps.tag_resolution.outputs.new_tag }}"
git push origin ${{ inputs.main-branch }}
shell: bash
- name: Publish tag on github
run: |
git tag ${{ steps.tag_resolution.outputs.new_tag }}
git push origin ${{ steps.tag_resolution.outputs.new_tag }}
shell: bash
- name: Release on github
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.tag_resolution.outputs.new_tag }}
generate_release_notes: true
prerelease: ${{ inputs.pre-release-tag != '' }}
- name: Publish to pypi
run: |
python3 -m build
python3 -m twine upload dist/*
env:
TWINE_USERNAME: ${{ inputs.pypi-username }}
TWINE_PASSWORD: ${{ inputs.pypi-password }}
shell: bash