Skip to content

Commit 1ee16cd

Browse files
authored
CM-22810 - Add a new release workflow that works with Poetry and uses OIDC for PyPI (#107)
1 parent dc34037 commit 1ee16cd

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/release.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build and Publish release
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
release:
9+
name: Release
10+
runs-on: ubuntu-latest
11+
permissions:
12+
actions: write
13+
id-token: write
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Python 3.7
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: '3.7'
25+
26+
- name: Install Poetry
27+
run: |
28+
curl -sSL https://install.python-poetry.org | python - -y
29+
30+
- name: Update PATH
31+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
32+
33+
- name: Install Poetry Plugin
34+
run: poetry self add "poetry-dynamic-versioning[plugin]"
35+
36+
- name: Check Pre-Release Version
37+
id: check-version
38+
run: |
39+
echo "::debug::Package version: $(poetry version --short)"
40+
[[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT
41+
42+
- name: Exit if Pre-Release Version
43+
if: steps.check-version.outputs.prerelease == 'true'
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
run: |
47+
gh run cancel ${{ github.run_id }}
48+
gh run watch ${{ github.run_id }}
49+
50+
- name: Build package
51+
run: poetry build
52+
53+
- name: Publish a Python distribution to PyPI
54+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)