|
1 | 1 | name: Continuous delivery - PyPI |
2 | 2 |
|
3 | | -on: |
4 | | - release: |
5 | | - types: [released] |
6 | | - |
7 | | -env: |
8 | | - REQUIRED_PACKAGES: make |
| 3 | +on: [push] |
9 | 4 |
|
10 | 5 | jobs: |
11 | | - version-check: |
12 | | - name: Check versioning |
| 6 | + check-package-version: |
| 7 | + name: Check package version |
13 | 8 | runs-on: ubuntu-latest |
14 | 9 | container: python:3.9-slim |
15 | 10 | steps: |
16 | 11 | - name: Checkout repository |
17 | 12 | uses: actions/checkout@v4 |
18 | | - - name: Install required packages |
19 | | - run: apt update && apt install -y ${REQUIRED_PACKAGES} |
20 | 13 | - name: Install Poetry |
21 | 14 | run: pip install poetry |
22 | | - - name: Create virtual environment |
23 | | - run: make install |
24 | | - - name: Check version tag format |
25 | | - shell: bash |
26 | | - run: | |
27 | | - VERSION_TAG="${{ github.event.release.tag_name }}" |
28 | | - if [[ $VERSION_TAG =~ ^v[0-9]+.[0-9]+.[0-9]+(-rc\.[1-9])?$ ]]; then exit 0; else exit 1; fi |
29 | | - - name: Check if version tag and package version are equal |
30 | | - shell: bash |
| 15 | + - name: Check package version format |
31 | 16 | run: | |
32 | | - VERSION_TAG="${{ github.event.release.tag_name }}" |
33 | | - PACKAGE_VERSION="v"$(poetry version --short) |
34 | | - if [ $VERSION_TAG == $PACKAGE_VERSION ]; then exit 0; else exit 1; fi |
35 | | - build: |
36 | | - name: Build |
37 | | - runs-on: ubuntu-latest |
38 | | - container: python:3.9-slim |
39 | | - needs: version-check |
40 | | - steps: |
41 | | - - name: Checkout repository |
42 | | - uses: actions/checkout@v4 |
43 | | - - name: Install required packages |
44 | | - run: apt update && apt install -y ${REQUIRED_PACKAGES} |
45 | | - - name: Install Poetry |
46 | | - run: pip install poetry |
47 | | - - name: Create virtual environment |
48 | | - run: make install |
49 | | - - name: Build |
50 | | - run: poetry build |
51 | | - - name: Upload artifacts |
52 | | - uses: actions/upload-artifact@v4 |
53 | | - with: |
54 | | - name: nitrokey-pypi |
55 | | - path: dist |
56 | | - publish: |
57 | | - name: Publish |
58 | | - runs-on: ubuntu-latest |
59 | | - container: python:3.9-slim |
60 | | - needs: build |
61 | | - environment: PyPI |
62 | | - env: |
63 | | - POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} |
64 | | - POETRY_PYPI_URL: https://upload.pypi.org/legacy/ |
65 | | - steps: |
66 | | - - name: Checkout repository |
67 | | - uses: actions/checkout@v4 |
68 | | - - name: Download artifacts |
69 | | - uses: actions/download-artifact@v4 |
70 | | - with: |
71 | | - name: nitrokey-pypi |
72 | | - path: dist |
73 | | - - name: Install Poetry |
74 | | - run: pip install poetry |
75 | | - - name: Configure PyPI repository |
76 | | - run: poetry config repositories.pypi $POETRY_PYPI_URL |
77 | | - - name: Publish release |
78 | | - run: poetry publish --repository pypi |
| 17 | + PACKAGE_VERSION=$(poetry version --short) |
| 18 | + if [[ $PACKAGE_VERSION =~ ^[0-9]+.[0-9]+.[0-9]+(-rc\.[1-9])?$ ]]; then exit 0; else exit 1; fi |
0 commit comments