Skip to content

Commit 1757931

Browse files
authored
Merge pull request #5088 from crazy-max/ci-refactor
ci: merge publish workflow with build one
2 parents 8696f84 + 01377d2 commit 1757931

File tree

2 files changed

+95
-109
lines changed

2 files changed

+95
-109
lines changed

.github/workflows/build.yml

+95-4
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,23 @@
2020

2121
name: build
2222
on:
23-
- push
24-
- pull_request
23+
push:
24+
branches:
25+
- master
26+
pull_request:
27+
release:
28+
types:
29+
- published
2530

2631
env:
2732
NODE_VERSION: 14.x
33+
PYTHON_VERSION: 3.x
2834

2935
permissions:
3036
contents: read
3137

3238
jobs:
33-
build:
34-
name: Build project
39+
npm:
3540
runs-on: ubuntu-latest
3641
steps:
3742

@@ -61,3 +66,89 @@ jobs:
6166
run: |
6267
npm run build
6368
git diff --name-only
69+
70+
pypi:
71+
runs-on: ubuntu-latest
72+
steps:
73+
74+
- name: Checkout repository
75+
uses: actions/checkout@v3
76+
77+
- name: Set up Python runtime
78+
uses: actions/setup-python@v4
79+
with:
80+
python-version: ${{ env.PYTHON_VERSION }}
81+
82+
- name: Set up Python dependencies
83+
run: pip install --upgrade build twine
84+
85+
- name: Build Python package
86+
run: python -m build
87+
88+
- name: Publish Python package
89+
if: github.event_name == 'release'
90+
env:
91+
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
92+
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
93+
run: twine upload --disable-progress-bar -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} dist/*
94+
95+
docker:
96+
runs-on: ubuntu-latest
97+
steps:
98+
99+
- name: Checkout repository
100+
uses: actions/checkout@v3
101+
102+
- name: Set up Docker Buildx
103+
uses: docker/setup-buildx-action@v2
104+
105+
- name: Login to DockerHub
106+
if: github.event_name == 'release'
107+
uses: docker/login-action@v2
108+
with:
109+
username: ${{ secrets.DOCKER_USERNAME }}
110+
password: ${{ secrets.DOCKER_PASSWORD }}
111+
112+
- name: Login to GitHub Container Registry
113+
if: github.event_name == 'release'
114+
uses: docker/login-action@v2
115+
with:
116+
registry: ghcr.io
117+
username: ${{ github.repository_owner }}
118+
password: ${{ secrets.GHCR_TOKEN }}
119+
120+
- name: Generate Docker tags and labels
121+
id: meta
122+
uses: docker/metadata-action@v4
123+
with:
124+
images: |
125+
${{ github.event.repository.full_name }}
126+
ghcr.io/${{ github.event.repository.full_name }}
127+
tags: |
128+
type=ref,event=branch
129+
type=ref,event=tag
130+
type=ref,event=pr
131+
flavor: |
132+
latest=${{ github.event.release.prerelease == false }}
133+
134+
- name: Build Docker image
135+
uses: docker/build-push-action@v4
136+
with:
137+
context: .
138+
load: true
139+
tags: ${{ steps.meta.outputs.tags }}
140+
labels: ${{ steps.meta.outputs.labels }}
141+
142+
- name: Check Docker image
143+
working-directory: /tmp
144+
run: |
145+
docker run --rm -i -v ${PWD}:/docs ${{ github.event.repository.full_name }}:${{ steps.meta.outputs.version }} new .
146+
docker run --rm -i -v ${PWD}:/docs ${{ github.event.repository.full_name }}:${{ steps.meta.outputs.version }} build
147+
148+
- name: Publish Docker image
149+
uses: docker/build-push-action@v4
150+
with:
151+
context: .
152+
push: ${{ github.event_name == 'release' }}
153+
tags: ${{ steps.meta.outputs.tags }}
154+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/publish.yml

-105
This file was deleted.

0 commit comments

Comments
 (0)