-
Notifications
You must be signed in to change notification settings - Fork 8
110 lines (99 loc) · 3.34 KB
/
Copy pathpython-publish.yml
File metadata and controls
110 lines (99 loc) · 3.34 KB
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
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package
on:
release:
types: [published]
permissions:
contents: read
jobs:
validate:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: 2.1.1
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Install library
run: poetry install --no-interaction
- name: Lint and test with poetry
run: |
poetry run pytest --cov=foliant
poetry run codecov
poetry run pylint foliant
- name: Add version to environment vars
run: |
FOLIANT_VERSION=$(poetry version --short)
echo "FOLIANT_VERSION=$FOLIANT_VERSION" >> $GITHUB_ENV
- name: Check if tag version matches project version
run: |
TAG=$(git describe HEAD --tags --abbrev=0)
echo $TAG
echo $FOLIANT_VERSION
if [[ "$TAG" != "$FOLIANT_VERSION" ]]; then exit 1; fi
publish:
needs: validate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build and publish to pypi
uses: JRubics/poetry-publish@v1.11
with:
poetry_version: ==2.1.1
pypi_token: ${{ secrets.PYPI_TOKEN }}
after_deploy:
needs: publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
repository: foliant-docs/docker
ref: master
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push slim
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
foliant/foliant:slim
foliant/foliant:${{ github.event.release.tag_name }}-slim
build-args: VERSION=$FOLIANT_VERSION
file: "./Dockerfile-slim"
- name: Build and push default
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
foliant/foliant
foliant/foliant:${{ github.event.release.tag_name }}
file: "./Dockerfile"
- name: Build and push pandoc
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
foliant/foliant:pandoc
foliant/foliant:${{ github.event.release.tag_name }}-pandoc
file: "./Dockerfile-pandoc"