-
Notifications
You must be signed in to change notification settings - Fork 5
167 lines (143 loc) · 4.95 KB
/
publish-to-test-pypi.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# name: Publish Burj Khalifa to PyPI
# # https://kobifelton.com/notes/fighting-with-github-actions
# on:
# push:
# pull_request:
# branches:
# # Branches from forks have the form 'user:branch-name' so we only run
# # this job on pull_request events for branches that look like fork
# # branches. Without this we would end up running this job twice for non
# # forked PRs, once for the push and then once for opening the PR.
# - '**:**'
# jobs:
# # Build the package
# build:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Install python
# uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Install poetry
# uses: Gr1N/setup-poetry@v7
# - name: Build package
# run: poetry build
# - name: Upload built package
# uses: actions/upload-artifact@v3
# with:
# name: dist
# path: dist/
# retention-days: 1
# # Run pytest using built package
# test:
# needs: build
# runs-on: ubuntu-latest
# strategy:
# matrix:
# python: ["3.10", "3.11"]
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Install python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python }}
# cache: 'pip'
# cache-dependency-path: "poetry.lock"
# - name: Download built package
# uses: actions/download-artifact@v3
# with:
# name: dist
# - name: Install pytest
# shell: bash
# run: pip install pytest
# - name: Install Poetry
# uses: snok/install-poetry@v1
# with:
# virtualenvs-create: true
# virtualenvs-in-project: true
# installer-parallel: true
# - name: Load cached venv
# uses: actions/cache@v2
# with:
# path: .venv
# key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
# - name: Install dependencies
# #if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
# run: |
# poetry install --no-root --no-interaction
# - name: Run tests
# shell: bash
# run: poetry run pytest
# # Publish to pypi on version change
# # This is based on https://github.com/coveooss/pypi-publish-with-poetry
# publish:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# - name: Install python
# uses: actions/setup-python@v4
# with:
# python-version: '3.10'
# - name: Download built package
# uses: actions/download-artifact@v3
# with:
# name: dist
# path: dist/
# - name: Install poetry
# uses: Gr1N/setup-poetry@v7
# - name: Install coveo-pypi-cli
# run: pip install coveo-pypi-cli
# - name: Determine the version for this release from the build
# id: current
# run: |
# BUILD_VER="$(ls dist/pura-*.tar.gz)"
# echo "Path: $BUILD_VER"
# if [[ $BUILD_VER =~ (pura-)([^,][0-9.]{4}) ]]; then
# echo "::set-output name=version::${BASH_REMATCH[2]}"
# echo "Version of build: ${BASH_REMATCH[2]}"
# else
# echo "No version found found"
# fi
# - name: Get latest published version
# id: published
# run: |
# PUB_VER="$(pypi current-version pura)"
# echo "::set-output name=version::$PUB_VER"
# echo "Latest published version: $PUB_VER"
# - name: Publish to pypi if new version
# if: (steps.current.outputs.version != steps.published.outputs.version)
# shell: bash
# run: |
# poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
# if [[ '${{ github.ref_name }}' == 'main' ]]; then
# poetry publish
# else
# echo "Dry run of publishing the package"
# poetry publish --dry-run
# fi
# - name: Tag repository
# shell: bash
# id: get-next-tag
# if: (steps.current.outputs.version != steps.published.outputs.version)
# run: |
# TAG_NAME=${{ steps.current.outputs.version }}
# echo "::set-output name=tag-name::$TAG_NAME"
# echo "This release will be tagged as $TAG_NAME"
# git config user.name "github-actions"
# git config user.email "[email protected]"
# git tag --annotate --message="Automated tagging system" $TAG_NAME ${{ github.sha }}
# - name: Push the tag
# if: (steps.current.outputs.version != steps.published.outputs.version)
# env:
# TAG_NAME: ${{ steps.current.outputs.version }}
# run: |
# if [[ ${{ github.ref_name }} == 'main' ]]; then
# git push origin $TAG_NAME
# else
# echo "If this was the main branch, I would push a new tag named $TAG_NAME"
# fi