Skip to content

Commit 730189d

Browse files
DEV: Different workflows for git tag / PyPI / GH Release Page (#2596)
Co-authored-by: Stefan <[email protected]>
1 parent eb6b21c commit 730189d

File tree

3 files changed

+81
-42
lines changed

3 files changed

+81
-42
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Create a GitHub release page
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
workflow_dispatch:
8+
workflow_run:
9+
workflows: ["Create git tag"]
10+
types:
11+
- completed
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
build_and_publish:
18+
name: Create a GitHub release page
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@v4
23+
- name: Prepare variables
24+
id: prepare_variables
25+
run: |
26+
git fetch --tags --force
27+
latest_tag=$(git describe --tags --abbrev=0)
28+
echo "latest_tag=$(git describe --tags --abbrev=0)" >> "$GITHUB_ENV"
29+
echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_ENV"
30+
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
31+
echo "tag_body<<$EOF" >> "$GITHUB_ENV"
32+
git --no-pager tag -l "${latest_tag}" --format='%(contents:body)' >> "$GITHUB_ENV"
33+
echo "$EOF" >> "$GITHUB_ENV"
34+
- name: Create GitHub Release 🚀
35+
uses: softprops/action-gh-release@v1
36+
with:
37+
tag_name: ${{ env.latest_tag }}
38+
name: Version ${{ env.latest_tag }}, ${{ env.date }}
39+
draft: false
40+
prerelease: false
41+
body: ${{ env.tag_body }}
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Publish Python Package to PyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- '*.*.*'
7+
workflow_dispatch:
8+
workflow_run:
9+
workflows: ["Create git tag"]
10+
types:
11+
- completed
12+
13+
jobs:
14+
build_and_publish:
15+
name: Publish a new version
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: 3.x
22+
23+
- name: Install Flit
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install flit
27+
28+
- name: Checkout Repository
29+
uses: actions/checkout@v4
30+
31+
- name: Publish Package to PyPI🚀
32+
env:
33+
FLIT_USERNAME: '__token__'
34+
FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }}
35+
run: |
36+
flit publish

.github/workflows/release.yaml

+4-42
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
# and it's decided what should be in the release.
44
# This action only ensures the release is done with the proper contents
55
# and that it's announced with a Github release.
6-
name: Publish Python Package to PyPI
6+
name: Create git tag
77
on:
88
push:
99
branches:
1010
- main
11+
1112
permissions:
1213
contents: write
1314

1415
jobs:
1516
build_and_publish:
16-
name: Publish a new version of pypdf
17+
name: Publish a new version
1718
runs-on: ubuntu-latest
1819
if: "${{ startsWith(github.event.head_commit.message, 'REL: ') }}"
19-
2020
steps:
21-
# Ensure it's on PyPI
2221
- name: Checkout Repository
2322
uses: actions/checkout@v4
23+
2424
- name: Extract version from commit message
2525
id: extract_version
2626
run: |
@@ -45,41 +45,3 @@ jobs:
4545
git config user.email [email protected]
4646
git tag "$VERSION" -m "$MESSAGE"
4747
git push origin $VERSION
48-
49-
- name: Set up Python
50-
uses: actions/setup-python@v5
51-
with:
52-
python-version: 3.x
53-
54-
- name: Install Flit
55-
run: |
56-
python -m pip install --upgrade pip
57-
pip install flit
58-
59-
- name: Publish Package to PyPI🚀
60-
env:
61-
FLIT_USERNAME: '__token__'
62-
FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }}
63-
run: |
64-
flit publish
65-
66-
# Create the Github Page
67-
- name: Prepare variables
68-
id: prepare_variables
69-
run: |
70-
git fetch --tags --force
71-
latest_tag=$(git describe --tags --abbrev=0)
72-
echo "latest_tag=$(git describe --tags --abbrev=0)" >> "$GITHUB_ENV"
73-
echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_ENV"
74-
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
75-
echo "tag_body<<$EOF" >> "$GITHUB_ENV"
76-
git --no-pager tag -l "${latest_tag}" --format='%(contents:body)' >> "$GITHUB_ENV"
77-
echo "$EOF" >> "$GITHUB_ENV"
78-
- name: Create GitHub Release 🚀
79-
uses: softprops/action-gh-release@v2
80-
with:
81-
tag_name: ${{ env.latest_tag }}
82-
name: Version ${{ env.latest_tag }}, ${{ env.date }}
83-
draft: false
84-
prerelease: false
85-
body: ${{ env.tag_body }}

0 commit comments

Comments
 (0)