-
-
Notifications
You must be signed in to change notification settings - Fork 5
76 lines (74 loc) · 2.15 KB
/
ci.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
name: ci
on:
push:
tags:
- "*"
branches:
- main
pull_request:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: pdm-project/setup-pdm@v3
- run: pdm sync -d
- run: pdm run ruff check
- run: pdm run ruff format --check
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: pdm-project/setup-pdm@v3
- run: pdm run pytest
docker:
name: Docker
runs-on: ubuntu-latest
needs:
- lint
- check
- test
steps:
- uses: actions/checkout@v4
- name: Log into docker
run: docker login docker.pkg.github.com -u bahlo -p "${{ secrets.GITHUB_TOKEN }}"
- name: Build docker container
if: github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags')
run: docker build -t docker.pkg.github.com/bahlo/ing-ynab/ing-ynab:branch .
- name: Build and publish docker latest
if: github.ref == 'refs/heads/main'
run: |
docker build -t docker.pkg.github.com/bahlo/ing-ynab/ing-ynab:latest .
docker push docker.pkg.github.com/bahlo/ing-ynab/ing-ynab:latest
- name: Build and publish docker image
if: startsWith(github.ref, 'refs/tags')
run: |
export TAG=$(echo "${{ github.ref }}" | sed 's/^refs\/tags\/v//g')
docker build -t docker.pkg.github.com/bahlo/ing-ynab/ing-ynab:$TAG .
docker push docker.pkg.github.com/bahlo/ing-ynab/ing-ynab:$TAG
publish:
name: Publish on PyPi
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')
needs:
- lint
- check
- test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- uses: pdm-project/setup-pdm@v3
- run: pdm publish
env:
PDM_PUBLISH_USERNAME: "__token__"
PDM_PUBLISH_PASSWORD: "${{ secrets.PYPI_TOKEN }}"