Skip to content

Commit 75a581f

Browse files
committed
Add build and publish automation. Set version
1 parent 6612718 commit 75a581f

File tree

3 files changed

+121
-3
lines changed

3 files changed

+121
-3
lines changed

Diff for: .github/workflows/publish-release.yml

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Publish release build to pypi and create release tag
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
outputs:
12+
version: ${{ steps.build-step.outputs.version }}
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up Python 3.10
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.9"
20+
- name: Install pip and flake package
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install flake8 pytest
24+
- name: Lint with flake8
25+
run: |
26+
# stop the build if there are Python syntax errors or undefined names
27+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
28+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
29+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
30+
- name: Install poetry and project dependencies
31+
run: |
32+
python -m pip install poetry
33+
poetry install
34+
- name: Test with pytest
35+
run: |
36+
echo ${{ github.workspace }}
37+
cd ${{ github.workspace }}/tests
38+
poetry run pytest
39+
- name: Build
40+
id: build-step
41+
run: |
42+
poetry build
43+
VERSION=$(poetry version -s)
44+
echo "$VERSION"
45+
echo "version=$VERSION" >> $GITHUB_OUTPUT
46+
- name: Print release version
47+
run: |
48+
echo "the version number is ${{ steps.build-step.outputs.version }}"
49+
- name: Archive production artifacts
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: dwcahandler-dist-v${{ steps.build-step.outputs.version }}
53+
path: dist
54+
55+
publish-to-pypi:
56+
name: Publish dwcahandler distribution to PyPI
57+
runs-on: ubuntu-latest
58+
59+
needs:
60+
- build
61+
62+
environment:
63+
name: production
64+
url: https://pypi.org/p/dwcahandler
65+
66+
permissions:
67+
id-token: write # IMPORTANT: mandatory for trusted publishing
68+
69+
steps:
70+
- name: Download all the dists
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: dwcahandler-dist-v${{ needs.build.outputs.version }}
74+
path: dist/
75+
- name: Publish dwcahandler distribution to PyPI
76+
uses: pypa/gh-action-pypi-publish@release/v1
77+
78+
github-release:
79+
name: >-
80+
Sign the dwcahandler distribution with Sigstore
81+
and upload them to GitHub Release
82+
needs: [build, publish-to-pypi]
83+
runs-on: ubuntu-latest
84+
85+
permissions:
86+
contents: write # IMPORTANT: mandatory for making GitHub Releases
87+
id-token: write # IMPORTANT: mandatory for sigstore
88+
89+
steps:
90+
- name: Download all the dists
91+
uses: actions/download-artifact@v4
92+
with:
93+
name: dwcahandler-dist-v${{ needs.build.outputs.version }}
94+
path: dist/
95+
- name: Sign the dists with Sigstore
96+
uses: sigstore/gh-action-sigstore-python@v2.1.1
97+
with:
98+
inputs: >-
99+
./dist/*.tar.gz
100+
./dist/*.whl
101+
- name: Create GitHub Release
102+
id: create-release
103+
env:
104+
GITHUB_TOKEN: ${{ github.token }}
105+
run: |
106+
version="v${{ needs.build.outputs.version }}"
107+
gh release create $version --repo ${{ github.repository }}
108+
echo "tag-version=$version" >> "$GITHUB_OUTPUT"
109+
- name: Upload artifact signatures to GitHub Release
110+
env:
111+
GITHUB_TOKEN: ${{ github.token }}
112+
# Upload to GitHub Release using the `gh` CLI.
113+
# `dist/` contains the built packages, and the
114+
# sigstore-produced signatures and certificates.
115+
run: >-
116+
gh release upload
117+
'${{ steps.create-release.outputs.tag-version }}' dist/**
118+
--repo '${{ github.repository }}'

Diff for: .github/workflows/publish-test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
2626
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
2727
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
28-
- name: Install project dependencies
28+
- name: Install poetry and project dependencies
2929
run: |
3030
python -m pip install poetry
3131
poetry install
@@ -51,7 +51,7 @@ jobs:
5151
path: dist
5252

5353
publish-to-pypi:
54-
name: Publish dwca distribution to TestPyPI
54+
name: Publish dwcahandler distribution to TestPyPI
5555
needs:
5656
- build
5757
runs-on: ubuntu-latest

Diff for: pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "dwcahandler"
3-
version = "0.0.8"
3+
version = "0.1.0"
44
description = "Python package to handle Darwin Core Archive (DwCA) operations. This includes creating a DwCA zip file from one or more csvs, reading a DwCA, merge two DwCAs, validate DwCA and delete records from DwCA based on one or more key columns"
55
authors = ["Atlas of Living Australia data team <support@ala.org.au>"]
66
maintainers = ["Atlas of Living Australia data team <support@ala.org.au>"]

0 commit comments

Comments
 (0)