Skip to content

Commit 9efc7f5

Browse files
authored
add publish workflows (#15)
* add publish workflow * add changelog
1 parent ba20cc6 commit 9efc7f5

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed

.github/workflows/publish.yaml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Publish to PyPI
2+
# Adapted from the official Python packaging documentation:
3+
# https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#workflow-definition
4+
5+
name: Publish
6+
7+
# Run on any push to main, including tags.
8+
on:
9+
push:
10+
branches:
11+
- main
12+
tags:
13+
- '*'
14+
15+
jobs:
16+
build:
17+
name: Build distribution
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.x"
25+
- name: Install pypa/build
26+
run: >-
27+
python3 -m
28+
pip install
29+
build
30+
--user
31+
- name: Build a binary wheel and a source tarball
32+
run: python3 -m build
33+
- name: Store the distribution packages
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: python-package-distributions
37+
path: dist/
38+
39+
# Tagged commits on main will be published to PyPI
40+
publish-to-pypi:
41+
name: Publish to PyPI
42+
if: startsWith(github.ref, 'refs/tags/') # only publish on tag pushes
43+
needs:
44+
- build
45+
runs-on: ubuntu-latest
46+
environment:
47+
name: pypi
48+
url: https://pypi.org/p/func-python
49+
permissions:
50+
id-token: write # IMPORTANT: mandatory for trusted publishing
51+
steps:
52+
- name: Download all the dists
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: python-package-distributions
56+
path: dist/
57+
- name: Publish distribution to PyPI
58+
uses: pypa/gh-action-pypi-publish@release/v1
59+
60+
# A GitHub release will be created (and signed) for all PyPI releases.
61+
github-release:
62+
name: GitHub Release
63+
needs:
64+
- publish-to-pypi
65+
runs-on: ubuntu-latest
66+
permissions:
67+
contents: write
68+
id-token: write
69+
steps:
70+
- name: Download all the dists
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: python-package-distributions
74+
path: dist/
75+
- name: Sign the dists with Sigstore
76+
uses: sigstore/[email protected]
77+
with:
78+
inputs: >-
79+
./dist/*.tar.gz
80+
./dist/*.whl
81+
- name: Create GitHub Release
82+
env:
83+
GITHUB_TOKEN: ${{ github.token }}
84+
run: >-
85+
gh release create
86+
'${{ github.ref_name }}'
87+
--repo '${{ github.repository }}'
88+
--notes ""
89+
- name: Upload artifact signatures to GitHub Releases
90+
env:
91+
GITHUB_TOKEN: ${{ github.token }}
92+
# Upload to GitHub Release using the `gh` CLI.
93+
# `dist/` contains the built packages, and the
94+
# sigstore-produced signatures and certificates.
95+
run: >-
96+
gh release upload
97+
'${{ github.ref_name }}' dist/**
98+
--repo '${{ github.repository }}'
99+
100+
# All pushes to main will attempt an upload to PyPI
101+
# Note that re-uploads of the same tag will
102+
publish-to-testpypi:
103+
name: Publish to TestPyPI
104+
needs:
105+
- build
106+
runs-on: ubuntu-latest
107+
environment:
108+
name: testpypi
109+
url: https://test.pypi.org/p/func-python
110+
permissions:
111+
id-token: write # IMPORTANT: mandatory for trusted publishing
112+
steps:
113+
- name: Download all the dists
114+
uses: actions/download-artifact@v4
115+
with:
116+
name: python-package-distributions
117+
path: dist/
118+
- name: Publish to TestPyPI
119+
uses: pypa/gh-action-pypi-publish@release/v1
120+
with:
121+
repository-url: https://test.pypi.org/legacy/
122+

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Changelog
2+
3+
All notable changes to this project should be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
7+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8+
9+
## [Unreleased]
10+
11+
### Added
12+
- Workflows to publish to PyPI and Test PyPI
13+
- Chanagelog
14+
15+
### Changed
16+
### Deprecated
17+
### Removed
18+
### Fixed
19+
### Security
20+
21+
## [0.0.0] - YYYY-MM-DD
22+

0 commit comments

Comments
 (0)