-
Notifications
You must be signed in to change notification settings - Fork 2
125 lines (107 loc) · 4.37 KB
/
deploy-pre-release.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
---
name: Deploy Pre-Release Artifacts
on:
push:
branches:
- develop
defaults:
run:
shell: bash
env:
LANG: en_US.utf-8
LC_ALL: en_US.utf-8
PYTHON_VERSION: '3.10'
jobs:
bump_version:
if: github.ref_name != 'main'
runs-on: ubuntu-22.04
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Set up Python ${{ env.PYTHON_VERSION }}
id: setup-python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/[email protected]
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/[email protected]
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: |
poetry install --no-interaction
- name: Bump Version
run: |
# current_tag is the last tagged release in the repository. From there
# we need to remove the v from the beginning of the tag.
echo "Bump rule is prerelease"
if ! $(git tag -l "v*" = ''); then
# uses -V which is version sort to keep it monotonically increasing.
current_tag=$(git tag -l "v*" | grep --invert-match '-' | sort --reverse -V | sed -n 1p)
echo "current git tag is ${current_tag}"
current_tag=${current_tag#?}
# current_tag is now the version we want to set our poetry version so
# that we can bump the version
poetry version ${current_tag}
poetry version prerelease --no-interaction
else
# very first release. start with inputs.first-release-version
echo "First release. Setting tag as v0.0.1rc0"
current_tag=v0.0.1rc0
poetry version ${current_tag}
fi
NEW_TAG=v$(poetry version --short)
# Finally because we want to be able to use the variable in later
# steps we set a NEW_TAG environmental variable
echo "NEW_TAG=$(echo ${NEW_TAG})" >> $GITHUB_ENV
#---------------------------------------------------------------
# create build artifacts to be included as part of release
#---------------------------------------------------------------
- name: Create build artifacts
run: |
poetry build -vvv
- uses: ncipollo/[email protected]
with:
artifacts: "dist/*.gz,dist/*.whl"
artifactErrorsFailBuild: true
generateReleaseNotes: true
commit: ${{ github.ref }}
prerelease: true
tag: ${{ env.NEW_TAG }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish pre-release to pypi
if: github.repository_owner == 'eclipse-volttron'
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish