-
Notifications
You must be signed in to change notification settings - Fork 60
101 lines (81 loc) · 2.83 KB
/
release_beta.yaml
File metadata and controls
101 lines (81 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: Release Beta
on:
workflow_dispatch:
permissions:
users:
- ItayTheDar
inputs:
increment_version:
description: 'Increment version by major, minor, or patch'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
env:
VERSION_FILE_PATH: nest/__init__.py
CHANGELOG_FILE_PATH: CHANGELOG.md
jobs:
run-tests:
uses: ./.github/workflows/tests.yaml
release-beta:
runs-on: ubuntu-latest
needs: run-tests
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ secrets.RELEASE_GIT_TOKEN }}
- name: Set version
run: |
VERSION_REGEX='^(__version__ = \")(([[:digit:]]+\.)*[[:digit:]]+)((a|b|rc)[[:digit:]]+)?(\.post[[:digit:]]+)?(.dev[[:digit:]]+)?(\")$'
# get current version from version file
CURRENT_VERSION=`sed -n -E "s/$VERSION_REGEX/\2/p" $VERSION_FILE_PATH`
echo "Current version: $CURRENT_VERSION"
# switch case for incrementing_version based on input
case ${{ inputs.increment_version }} in
major)
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$1=$1+1; $2=0; $3=0; print $0}' OFS=".")
;;
minor)
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$2=$2+1; $3=0; print $0}' OFS=".")
;;
patch)
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$3=$3+1; print $0}' OFS=".")
;;
*)
echo "Invalid input for increment_version"
exit 1
;;
esac
echo "New version: $NEW_VERSION"
echo "RELEASE_VERSION=$NEW_VERSION" >> $GITHUB_ENV
# update version file
sed -i -E "s/$VERSION_REGEX/\1$NEW_VERSION\8/" $VERSION_FILE_PATH
- name: Install python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install python dependencies
run: |
pip install --upgrade pip
pip install -r requirements-release.txt
- name: Update CHANGELOG.md
run: git-changelog . -o $CHANGELOG_FILE_PATH
- name: Build package
run: python -m build
- name: Publish package to TestPyPI
run: |
python -m twine upload dist/* -r testpypi -u ${{ secrets.TEST_PYPI_API_USER }} -p ${{ secrets.TEST_PYPI_API_TOKEN }}
- name: Install test package
run: |
pip install --index-url https://test.pypi.org/simple/ --no-deps pynest-api
# import to check if package is installed correctly
python -c "import nest"
- name: Copy pip url
run: |
echo "pip install --index-url https://test.pypi.org/simple/ --no-deps pynest-api"