-
Notifications
You must be signed in to change notification settings - Fork 3
95 lines (93 loc) · 2.95 KB
/
publish.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: publish
on:
push:
branches:
- 'main'
tags:
- v[0-9]+.[0-9]+.[0-9]+
jobs:
build-n-publish-pypi:
name: Build and publish Python distribution 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- name: Check out src from Git
uses: actions/checkout@master
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a source tarball
run: >-
python -m
build
--sdist
--outdir dist/
- name: Publish distribution 📦 to Test PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
build-and-push-docker:
runs-on: ubuntu-latest
needs: build-n-publish-pypi
if: github.event_name != 'pull-request'
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Get Docker metadata for cli tool
id: cli
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKER_USERNAME }}/ofcli
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
- name: Get Docker metadata for api tool
id: api
uses: docker/metadata-action@v5
with:
images: ${{ secrets.DOCKER_USERNAME }}/ofapi
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
- name: Build and push cli image
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
target: ofcli
tags: ${{ steps.cli.outputs.tags }}
labels: ${{ steps.cli.outputs.labels }}
- name: Build and push api image
uses: docker/build-push-action@v6
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
target: ofapi
tags: ${{ steps.api.outputs.tags }}
labels: ${{ steps.api.outputs.labels }}