Skip to content

Commit ec4c742

Browse files
authored
DEV: Decouple git tag / PyPI release / Github release page (#49)
1 parent a2ab003 commit ec4c742

File tree

3 files changed

+67
-39
lines changed

3 files changed

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

.github/workflows/release.yaml

-39
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ jobs:
1818
runs-on: ubuntu-latest
1919
if: "${{ startsWith(github.event.head_commit.message, 'REL: ') }}"
2020
steps:
21-
# Ensure it's on PyPI
2221
- name: Checkout Repository
2322
uses: actions/checkout@v4
2423

@@ -46,41 +45,3 @@ jobs:
4645
git config user.email [email protected]
4746
git tag "$VERSION" -m "$MESSAGE"
4847
git push origin $VERSION
49-
50-
- name: Set up Python
51-
uses: actions/setup-python@v5
52-
with:
53-
python-version: 3.x
54-
55-
- name: Install Flit
56-
run: |
57-
python -m pip install --upgrade pip
58-
pip install flit
59-
60-
- name: Publish Package to PyPI🚀
61-
env:
62-
FLIT_USERNAME: '__token__'
63-
FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }}
64-
run: |
65-
flit publish
66-
67-
# Create the Github Page
68-
- name: Prepare variables
69-
id: prepare_variables
70-
run: |
71-
git fetch --tags --force
72-
latest_tag=$(git describe --tags --abbrev=0)
73-
echo "latest_tag=$(git describe --tags --abbrev=0)" >> "$GITHUB_ENV"
74-
echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_ENV"
75-
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
76-
echo "tag_body<<$EOF" >> "$GITHUB_ENV"
77-
git --no-pager tag -l "${latest_tag}" --format='%(contents:body)' >> "$GITHUB_ENV"
78-
echo "$EOF" >> "$GITHUB_ENV"
79-
- name: Create GitHub Release 🚀
80-
uses: softprops/action-gh-release@v2
81-
with:
82-
tag_name: ${{ env.latest_tag }}
83-
name: Version ${{ env.latest_tag }}, ${{ env.date }}
84-
draft: false
85-
prerelease: false
86-
body: ${{ env.tag_body }}

0 commit comments

Comments
 (0)