Skip to content

Commit cfd2676

Browse files
committed
Add publish workflow for tags
1 parent e94cf29 commit cfd2676

File tree

4 files changed

+58
-37
lines changed

4 files changed

+58
-37
lines changed

.github/actions/build-python-package/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ runs:
3333
- uses: actions/upload-artifact@v3
3434
with:
3535
name: ${{ inputs.artifact-name }}
36-
path: dist
36+
path: "dist/"

.github/actions/environment/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ runs:
2626
- name: Fetch built emsarray package
2727
uses: actions/download-artifact@v3
2828
with:
29-
name: ${{ inputs.python-artifact-name }}
29+
name: ${{ inputs.package-artifact-name }}
3030
path: "dist/"
3131

3232
- name: Cache conda packages

.github/workflows/ci.yaml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -113,38 +113,3 @@ jobs:
113113
with:
114114
name: Docs
115115
path: docs/_build/dirhtml
116-
117-
publish:
118-
runs-on: ubuntu-latest
119-
timeout-minutes: 5
120-
needs: ['build', 'test', 'lint', 'docs']
121-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
122-
123-
steps:
124-
- name: Fetch Python package
125-
uses: actions/download-artifact@v3
126-
with:
127-
name: ${{ needs.build.outputs.artifact-name }}
128-
path: "dist"
129-
130-
- name: "Check tag matches version"
131-
shell: bash -l {0}
132-
run: |
133-
VERSION="$( echo "${{ github.ref }}" | sed 's!refs/tags/v!!' )"
134-
echo "Looking for packages with version $VERSION"
135-
ls -l dist/*
136-
packages=(
137-
"dist/emsarray-$VERSION.tar.gz"
138-
"dist/emsarray-$VERSION-*.whl"
139-
)
140-
for package in "${packages[@]}" ; do
141-
if ! test -e $package ; then
142-
echo "Could not find $package"
143-
exit 1
144-
fi
145-
done
146-
147-
- name: "Publish Python package"
148-
uses: pypa/gh-action-pypi-publish@release/v1
149-
with:
150-
password: ${{ secrets.PYPI_API_TOKEN }}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Publish a new version to PyPI
2+
on:
3+
push:
4+
tags:
5+
- "v[0-9]+.*"
6+
7+
workflow_dispatch:
8+
9+
env:
10+
python-version: "3.11"
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
outputs:
16+
artifact-name: ${{ steps.build.outputs.artifact-name }}
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: ./.github/actions/build-python-package
20+
id: build
21+
with:
22+
python-version: ${{ env.python-version }}
23+
24+
publish:
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 5
27+
needs: ['build']
28+
29+
steps:
30+
- name: Fetch Python package
31+
uses: actions/download-artifact@v3
32+
with:
33+
name: ${{ needs.build.outputs.artifact-name }}
34+
path: "dist"
35+
36+
- name: "Check tag matches version"
37+
shell: bash -l {0}
38+
run: |
39+
VERSION="$( echo "${{ github.ref }}" | sed 's!refs/tags/v!!' )"
40+
echo "Looking for packages with version $VERSION"
41+
ls -l dist/*
42+
packages=(
43+
"dist/emsarray-$VERSION.tar.gz"
44+
"dist/emsarray-$VERSION-*.whl"
45+
)
46+
for package in "${packages[@]}" ; do
47+
if ! test -e $package ; then
48+
echo "Could not find $package"
49+
exit 1
50+
fi
51+
done
52+
53+
- name: "Publish Python package"
54+
uses: pypa/gh-action-pypi-publish@release/v1
55+
with:
56+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)