Skip to content

Commit

Permalink
add release and publish capabilities (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
d33bs authored Jun 4, 2024
1 parent 74870df commit a7e8894
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# template configuration for release-drafter
# see: https://github.com/release-drafter/release-drafter
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
version-resolver:
major:
labels:
- 'release-major'
minor:
labels:
- 'release-minor'
patch:
labels:
- 'release-patch'
default: patch
change-template: '- $TITLE (@$AUTHOR via #$NUMBER)'
template: |
## Changes
$CHANGES
23 changes: 23 additions & 0 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
# workflow for drafting releases on GitHub
# see: https://github.com/release-drafter/release-drafter
name: release drafter

on:
push:
branches:
- main

jobs:
draft_release:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# used for publishing packages to pypi on release
name: publish pypi release

on:
release:
types:
- published

jobs:
publish_pypi:
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install python env
uses: ./.github/actions/install-python-env
- name: poetry build distribution content
run: poetry build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,23 @@ We also use the `__init__.py` file as a place to persist the version data for oc

The following command is used to add `poetry-dynamic-versioning` to Poetry for use with this project: `poetry self add "poetry-dynamic-versioning[plugin]"`.
Versioning for the project is intended to align with GitHub Releases which provide `git` tag capabilities.

### Releases

We publish source code by using [GitHub Releases](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases) available [here](https://github.com/wayscience/cosmicqc/releases).
We publish a related Python package through the [Python Packaging Index (PyPI)](https://pypi.org/) available [here](https://pypi.org/project/cosmicqc/).

#### Release Publishing Process

Several manual and automated steps are involved with publishing coSMicQC releases.
See below for an overview of how this works.

Notes about [semantic version](https://en.wikipedia.org/wiki/Software_versioning#Semantic_versioning) (semver) specifications:
coSMicQC version specifications are controlled through [`poetry-dynamic-versioning`](https://github.com/mtkennerly/poetry-dynamic-versioning) which leverages [`dunamai`](https://github.com/mtkennerly/dunamai) to create version data based on [git tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging) and commits.
coSMicQC release git tags are automatically applied through [GitHub Releases](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases) and related inferred changes from [`release-drafter`](https://github.com/release-drafter/release-drafter).

1. Open a pull request and use a repository label for `release-<semver release type>` to label the pull request for visibility with [`release-drafter`](https://github.com/release-drafter/release-drafter) (for example, see [coSMicQC#24](https://github.com/wayscience/cosmicqc/pull/24) as a reference of a semver patch update).
1. On merging the pull request for the release, a [GitHub Actions workflow](https://docs.github.com/en/actions/using-workflows) defined in `draft-release.yml` leveraging [`release-drafter`](https://github.com/release-drafter/release-drafter) will draft a release for maintainers.
1. The draft GitHub release will include a version tag based on the GitHub PR label applied and `release-drafter`.
1. Make modifications as necessary to the draft GitHub release, then publish the release (the draft release does not normally need additional modifications).
1. On publishing the release, another GitHub Actions workflow defined in `publish-pypi.yml` will run to build and deploy the Python package to PyPI (utilizing the earlier modified `pyproject.toml` semantic version reference for labeling the release).

0 comments on commit a7e8894

Please sign in to comment.