-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (115 loc) · 4.1 KB
/
dynamic_workflow.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
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
126
127
name: Dynamic Pipeline
on: [push]
env:
CHANGELOG_FILE: CHANGELOG.md
FULL_CHANGELOG_FILE: FULL_CHANGELOG.md
CONVCO_VERSION: v0.6.1
POETRY_VERSION: 1.8.2
PACKAGE_NAME: "pysparkdt"
PACKAGE_PATH: "pysparkdt"
jobs:
tests:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Bootstrap poetry
run: |
curl -sL https://install.python-poetry.org | python - -y
- name: Update PATH
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure poetry
run: poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v4
id: venv-cache
with:
path: .venv/
key: poetry-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
if: steps.venv-cache.outputs.cache-hit != 'true'
run: |
poetry env use ${{ matrix.python-version }}
poetry install
- name: Run checks
run: |
poetry run ruff check .
poetry run ruff format --check .
poetry run pytest .
publish:
runs-on: ubuntu-22.04
needs: tests
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python3 - --version ${{ env.POETRY_VERSION }}
- name: Install convco
run: |
curl -sSfL "https://github.com/convco/convco/releases/download/${{ env.CONVCO_VERSION }}/convco-ubuntu.zip" | zcat > /usr/local/bin/convco
chmod +x /usr/local/bin/convco
- name: Set variables
run: |
base_version_command="
convco
version
--prefix=${{ env.PACKAGE_NAME }}/
--paths=${{ env.PACKAGE_PATH }}
--paths=pyproject.toml
--paths=poetry.lock
"
old_version=$($base_version_command)
if [ $old_version = "0.0.0" ]; then # i.e. there is no version yet
new_version="1.0.0"
else
new_version=$($base_version_command --bump)
fi
new_tag=${{ env.PACKAGE_NAME }}/"$new_version"
echo "OLD_VERSION=$old_version" >> $GITHUB_ENV
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV
echo "NEW_TAG=$new_tag" >> $GITHUB_ENV
echo "old version: $old_version"
echo "new version: $new_version"
echo "new tag: $new_tag"
- name: Release and publish
if: ${{ env.OLD_VERSION != env.NEW_VERSION }}
env:
GH_TOKEN: ${{ github.token }}
run: |
########################################
# Generate changelogs
########################################
base_changelog_command="
convco
changelog
--prefix=${{ env.PACKAGE_NAME }}/
--paths=${{ env.PACKAGE_PATH }}
--unreleased=${{ env.NEW_TAG }}
"
$base_changelog_command --max-versions=1 > ${{ env.CHANGELOG_FILE }}
$base_changelog_command > ${{ env.FULL_CHANGELOG_FILE }}
########################################
# Create GitHub Release
########################################
gh release create \
${{ env.NEW_TAG }} \
--title ${{ env.NEW_TAG }} \
--notes-file ${{ env.CHANGELOG_FILE }} \
${{ env.FULL_CHANGELOG_FILE }}
########################################
# Publish to JFrog
########################################
poetry version ${{ env.NEW_VERSION }}
poetry config repositories.dtml "https://datamole.jfrog.io/artifactory/api/pypi/pypi-general-local"
poetry config http-basic.dtml "" ${{ secrets.JFROG_SERVICE_JWT }}
poetry publish --build -r dtml