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

ci: automatically build and publish package #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
72 changes: 72 additions & 0 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# .github/workflows/build_and_publish.yml

name: Build and Publish to PyPI
on:
push:
branches:
- master

# by default, permissions are read-only, read + write is required for git pushes
permissions:
contents: write

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: ASDF Parse
uses: kota65535/[email protected]
id: versions

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "${{ steps.versions.outputs.python }}"

- name: Install Poetry
uses: Gr1N/setup-poetry@v8
with:
poetry-version: "${{ steps.versions.outputs.poetry }}"

- name: Install dependencies
run: |
poetry install

- name: Make sure it runs
run: |
poetry run gmail-draft-creator --help

- name: Conventional Changelog Action
id: changelog
uses: TriPSs/conventional-changelog-action@v3
with:
github-token: ${{ secrets.github_token }}
version-file: "./pyproject.toml"
version-path: "tool.poetry.version"
fallback-version: "1.0.0"
output-file: "CHANGELOG.md"

# NOTE must run after versioning otherwise the right version won't be pushed
- name: Build distribution package
if: ${{ steps.changelog.outputs.skipped == 'false' }}
run: |
poetry build

- name: Publish to PyPI
if: ${{ steps.changelog.outputs.skipped == 'false' }}
run: |
# `gh secret set PYPI_API_TOKEN --app actions --body $PYPI_API_TOKEN`
poetry publish -u __token__ -p ${{ secrets.PYPI_API_TOKEN }}

- name: Github Release
if: ${{ steps.changelog.outputs.skipped == 'false' }}
uses: softprops/action-gh-release@v1
with:
# output options: https://github.com/TriPSs/conventional-changelog-action#outputs
body: ${{ steps.changelog.outputs.clean_changelog }}
tag_name: ${{ steps.changelog.outputs.tag }}
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python 3.11.4