Skip to content

Commit 3f6ca1e

Browse files
ci: Merge automatic-release and pypi workflows into one build-and-publish
1 parent fa89e40 commit 3f6ca1e

3 files changed

Lines changed: 80 additions & 89 deletions

File tree

.github/workflows/automatic-release.yml

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: build-and-publish
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@master
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v2
17+
with:
18+
python-version: '3.x'
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install uv
24+
25+
- name: Build
26+
run: |
27+
uv build
28+
pip install dist/*.whl
29+
echo "PACKAGE_VERSION=$(pip show pdf-helper | grep '^Version: ' | cut -d ' ' -f 2)" >> $GITHUB_ENV
30+
31+
- name: check-version
32+
uses: KyoriPowered/action-regex-match@v3
33+
id: check-version
34+
with:
35+
text: ${{ env.PACKAGE_VERSION }}
36+
regex: '\d+\.\d+\.\d+a\d+'
37+
38+
- uses: actions/upload-artifact@v7
39+
with:
40+
name: dist
41+
path: dist/
42+
43+
outputs:
44+
version: ${{ env.PACKAGE_VERSION }}
45+
is_alpha: ${{ steps.check-version.outputs.match }}
46+
47+
release:
48+
name: Auto Release
49+
runs-on: ubuntu-latest
50+
needs: build
51+
if: ${{ needs.build.outputs.is_alpha == '' }}
52+
steps:
53+
- uses: actions/download-artifact@v8
54+
with:
55+
name: dist
56+
path: dist/
57+
58+
- uses: "marvinpinto/action-automatic-releases@latest"
59+
with:
60+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
61+
automatic_release_tag: "${{ needs.build.outputs.version }}"
62+
title: "Auto Build"
63+
files: |
64+
dist/*
65+
66+
publish:
67+
name: Publish to PyPI
68+
runs-on: ubuntu-latest
69+
needs: build
70+
if: ${{ needs.build.outputs.is_alpha == '' }}
71+
steps:
72+
- uses: actions/download-artifact@v8
73+
with:
74+
name: dist
75+
path: dist/
76+
77+
- name: Publish
78+
uses: pypa/gh-action-pypi-publish@release/v1
79+
with:
80+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/pypi.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)