Skip to content

Commit ecf698e

Browse files
authored
👷 update release ci
1 parent 545f88e commit ecf698e

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Setup Python
2+
description: Setup Python
3+
4+
inputs:
5+
python-version:
6+
description: Python version
7+
required: false
8+
default: "3.10"
9+
10+
runs:
11+
using: "composite"
12+
steps:
13+
- name: Install poetry
14+
run: pipx install poetry
15+
shell: bash
16+
17+
- uses: actions/setup-python@v4
18+
with:
19+
python-version: ${{ inputs.python-version }}
20+
architecture: "x64"
21+
cache: "poetry"
22+
23+
- run: poetry install
24+
shell: bash

.github/workflows/release.yml

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,24 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v3
1313

14-
- id: python
15-
uses: actions/setup-python@v2
16-
with:
17-
python-version: "3.10"
18-
architecture: "x64"
14+
- name: Setup Python environment
15+
uses: ./.github/actions/setup-python
1916

20-
- uses: Gr1N/setup-poetry@v7
21-
22-
- id: poetry-cache
23-
run: echo "::set-output name=dir::$(poetry config virtualenvs.path)"
24-
25-
- uses: actions/cache@v2
26-
with:
27-
path: ${{ steps.poetry-cache.outputs.dir }}
28-
key: ${{ runner.os }}-poetry-${{ steps.python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
29-
30-
- run: poetry install
17+
- name: Get Version
18+
id: version
19+
run: |
20+
echo "VERSION=$(poetry version -s)" >> $GITHUB_OUTPUT
21+
echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
22+
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
3123
32-
- run: |
33-
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
24+
- name: Check Version
25+
if: steps.version.outputs.VERSION != steps.version.outputs.TAG_VERSION
26+
run: exit 1
3427

3528
- name: Build and Publish Package
3629
run: |
3730
poetry build
38-
poetry publish -u ${{secrets.PYPI_USERNAME}} -p ${{secrets.PYPI_PASSWORD}}
39-
gh release upload --clobber ${{ env.TAG_NAME }} dist/*.tar.gz dist/*.whl
31+
poetry publish -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }}
32+
gh release upload --clobber ${{ steps.version.outputs.TAG_NAME }} dist/*.tar.gz dist/*.whl
4033
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)