Skip to content

Commit 781276d

Browse files
authored
Update release workflow (#451)
1 parent 62eb504 commit 781276d

File tree

1 file changed

+40
-70
lines changed

1 file changed

+40
-70
lines changed

.github/workflows/release.yml

+40-70
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,58 @@
11
name: Release
22

33
on:
4-
push:
5-
tags:
6-
- '*.*.*'
4+
release:
5+
types: [published]
76

87
jobs:
9-
10-
Build:
8+
build:
9+
name: Build
1110
runs-on: ubuntu-latest
12-
1311
steps:
14-
- uses: actions/checkout@v4
15-
- name: Get tag
16-
id: tag
17-
run: |
18-
echo tag=${GITHUB_REF#refs/tags/} >> $GITHUB_OUTPUT
19-
20-
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v5
22-
with:
23-
python-version: "3.10"
24-
25-
- name: Install and set up Poetry
26-
run: |
27-
curl -sL https://install.python-poetry.org | python - -y
12+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
2813

29-
- name: Update PATH
30-
shell: bash
31-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
14+
- run: pipx run build
3215

33-
- name: Build distributions
34-
run: |
35-
poetry build -vvv
36-
37-
- name: Upload distribution artifacts
38-
uses: actions/upload-artifact@v4
39-
with:
40-
name: project-dist
41-
path: dist
16+
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
17+
with:
18+
name: distfiles
19+
path: dist/
20+
if-no-files-found: error
4221

43-
Publish:
44-
needs: [Build]
22+
upload-github:
23+
name: Upload (GitHub)
4524
runs-on: ubuntu-latest
46-
25+
permissions:
26+
contents: write
27+
needs: build
4728
steps:
48-
- name: Checkout code
49-
uses: actions/checkout@v4
50-
- name: Get tag
51-
id: tag
52-
run: |
53-
echo tag=${GITHUB_REF#refs/tags/} >> $GITHUB_OUTPUT
29+
# We need to be in a git repo for gh to work.
30+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
5431

55-
- name: Download distribution artifact
56-
uses: actions/download-artifact@master
32+
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
5733
with:
58-
name: project-dist
59-
path: dist
60-
61-
- name: Install and set up Poetry
62-
run: |
63-
curl -sL https://install.python-poetry.org | python - -y
34+
name: distfiles
35+
path: dist/
6436

65-
- name: Update PATH
66-
shell: bash
67-
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
68-
69-
- name: Check distributions
70-
run: |
71-
ls -la dist
72-
73-
- name: Publish to PyPI
37+
- run: gh release upload ${{ github.event.release.tag_name }} dist/*.{tar.gz,whl}
7438
env:
75-
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
76-
run: |
77-
poetry publish
39+
GH_TOKEN: ${{ github.token }}
7840

79-
- name: Create Release
80-
id: create_release
81-
uses: actions/create-release@v1
82-
env:
83-
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
41+
upload-pypi:
42+
name: Upload (PyPI)
43+
runs-on: ubuntu-latest
44+
environment:
45+
name: pypi
46+
url: https://pypi.org/project/cleo/
47+
permissions:
48+
id-token: write
49+
needs: build
50+
steps:
51+
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
52+
with:
53+
name: distfiles
54+
path: dist/
55+
56+
- uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450 # v1.8.14
8457
with:
85-
tag_name: ${{ steps.tag.outputs.tag }}
86-
release_name: ${{ steps.tag.outputs.tag }}
87-
draft: false
88-
prerelease: false
58+
print-hash: true

0 commit comments

Comments
 (0)