Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use stackable and PyPA GitHub action #48

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/pr_pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
- uses: stackabletech/actions/run-pre-commit@5901c3b1455488820c4be367531e07c3c3e82538 # v0.4.0
with:
python-version: '3.12'
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: "--from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}"
python-version: '3.13'
57 changes: 37 additions & 20 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: Publish

on:
Expand All @@ -7,25 +8,41 @@ on:

jobs:
build:
name: Package wheel
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ matrix.python-version }}
- name: Install publish dependencies
run: |
python -m pip install --upgrade pip
pip install '.[publish]'
- name: Build and test wheel
run: |
rm -rf dist/
python -m build --sdist --wheel .
twine check dist/*
- name: Publish
run: |
twine upload --non-interactive --verbose --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} dist/*
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4
- name: Set up Python
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5
with:
python-version: "3.13.0"
- name: Install publish dependencies
run: |
python -m pip install --upgrade pip build
- name: Build and test wheel
run: |
rm -rf dist/
python -m build --sdist --wheel .
- name: Store wheel
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: image-tools-stackabletech-package
path: dist/
pypi-publish:
name: Upload to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/image-tools-stackabletech
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Download wheel
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: image-tools-stackabletech-package
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@15c56dba361d8335944d31a2ecd17d700fc7bcbc # v1.12.2
31 changes: 12 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,15 @@ pre-commit run

## Release a new version

1. Create a release PR where you:
1.1. Update the version in:

* `src/image_tools/version.py`
* `README.md` : version and pip install command.

1.2. Update the CHANGELOG.
2. Tag the release commit after it is merged to `main`.
3. Automated GH actions will publish the new version to PyPI.

To publish manually (requires PyPI credentials):

Build and publish:

```shell
rm -rf dist/
python -m build --sdist --wheel .
twine upload dist/*
```
A new release involves bumping the package version and publishing it to PyPI.
The easiest way to publish to PyPI is to allow the release GitHub action to do it for you.
This action is also the preferred way, as it will publish a verified package using PyPI attestations.

To release a new version follow the steps below:

1. Create a new Git branch. For example `release-1.2.3`.
2. Update the version string (`1.2.3`) in: `src/image_tools/version.py` and`README.md`.
3. Commit, push and create a PR.
4. After the PR is merged, switch to the `main` branch and update it by executing `git pull`.
5. On the `main` branch, create and push the release tag. For example: `git tag 1.2.3 -m 1.2.3 && git push origin 1.2.3`.
6. Done!
Loading