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

Introducing trusted publishing #16

Merged
merged 6 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
62 changes: 37 additions & 25 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# For more information see:
# https://nasa-ammos.github.io/slim/docs/guides/software-lifecycle/application-starter-kits/python-starter-kit/
#
# ******** NOTE ********
# This file publishes to TestPyPi. To enable public PyPi the repository flag
# must be removed from the Twine upload call in the "Publish package" block.
#
name: "Upload Python Package"
# This workflows will upload a Python Package when a release is created
# For more information see:
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
branches: [main]
types: [published]
types: [ published ]

jobs:
deploy:
name: Deploy

build:
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
security-events: write
steps:
- name: Checkout repository
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -40,10 +29,33 @@ jobs:
run: |
python3 -m build --wheel
python3 setup.py sdist --format=zip
- name: Publish package
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
- name: Verify package
run: |
twine check dist/*
twine upload --repository testpypi --verbose dist/*.whl dist/*.zip
- name: Store package
uses: actions/upload-artifact@v4
with:
name: python-package-distribution
path: |
dist/*.whl
dist/*.zip
if-no-files-found: error

release:
runs-on: ubuntu-latest
needs: build
environment:
name: release
permissions:
id-token: write # mandatory for trusted publishing
steps:
- name: Retrieve package
uses: actions/download-artifact@v4
with:
name: python-package-distribution
path: dist/
- name: Publish package (PyPi)
uses: pypa/gh-action-pypi-publish@release/v1
with:
print-hash: true
repository-url: https://upload.pypi.org/legacy/ # for testing sub https://test.pypi.org/legacy/
ingyhere marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0] - 2023-01-31
## [1.0.1] - 2024-03-15

### Added

Expand Down
2 changes: 1 addition & 1 deletion slim_sample_project/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.0'
__version__ = '1.1.0'