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: Fixed release workflow #34

Merged
merged 7 commits into from
Nov 8, 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
36 changes: 36 additions & 0 deletions .github/workflows/main-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Semver Bump
on:
push:
branches:
- main
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
auto-semver:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Release with semantic-release
uses: tjtharrison/github-actions-releaser@v1
id: release
with:
PROJECT_NAME: gpush
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update version file
env:
NEW_VERSION: ${{ steps.release.outputs.NEW_RELEASE }}
run: |
echo "$NEW_VERSION"
sed -i 's/\".*\"/'"$NEW_VERSION"'/g' _version.py
- name: Commit version file
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: bump version to ${{ steps.release.outputs.NEW_RELEASE }} [skip ci]"
file_pattern: _version.py
2 changes: 1 addition & 1 deletion .github/workflows/pr-actionlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: Action Linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Download actionlint
id: get_actionlint
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/pr-codeql.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/pr-linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout code"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"
- name: "Code format"
run: |
pip3 install isort pylint black
Expand All @@ -34,7 +34,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout code"
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"
- name: "Install requirements"
run: |
pip3 install darglint pydocstyle
Expand Down
40 changes: 0 additions & 40 deletions .github/workflows/pr-merge-dependabot.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/semver.yaml

This file was deleted.

43 changes: 4 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# gpush

`gpush` is a command line utility for standardising commit messages using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). It is designed to be used in conjunction with [python-semantic-release](https://python-semantic-release.readthedocs.io/en/latest/) to automate the release of your python package based on commits that are made on a branch when a PR is merged.
`gpush` is a command line utility for standardising commit messages using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). It is designed to be used in conjunction with [semantic-release](https://semantic-release.gitbook.io/semantic-release/usage/configuration) to automate the release of your package based on commits that are made on a branch when a PR is merged.

## Signing commits

`gpush` natively supports signing commits using GPG. To enable this, you will need to have GPG installed and configured on your machine. You can find instructions on how to do this [here](https://docs.github.com/en/github/authenticating-to-github/managing-commit-signature-verification/generating-a-new-gpg-key).

# Installation

This package is available for installation via pypi using pip3:
This package is available for installation via git. To install the latest version, run the following command:

```
pip3 install gpush
pip3 install git+https://github.com/tjtharrison/gpush.git
```

# Usage
Expand All @@ -38,45 +38,10 @@ make dev

# Unit tests

To run unit tests, execute the following command, you will need to have pytest installed and set environment
variable `GITHUB_TOKEN` to a valid GitHub token that has permissions to create/delete and push to a repository
within your account.
To run unit tests, execute the following command, you will need to have pytest installed and set environment variable `GITHUB_TOKEN` to a valid GitHub token that has permissions to create/delete and push to a repository within your account.

```
make test
```

The unit tests will create a test repository within your account for each unit test before testing functionality and deleting the repository.

# python-semantic-release

`gpush` generates commit messages that are compliant with [python-semantic-release](https://python-semantic-release.readthedocs.io/en/latest/). This allows you to automate the release of your python package using GitHub Actions.

To use python-semantic-release, you will need to create a GitHub Action workflow that runs on the `main` branch. The workflow will need to checkout the code, install python-semantic-release and then run the release command. The following is an example workflow that will run on the `main` branch and release a new version of your package and push to PyPI when a PR is merged.

You will need to create a PyPI token and add it to your GitHub repository secrets (As `PYPI_TOKEN`). You can find instructions on how to do this [here](https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#publishing-to-pypi).

## .github/workflow/release.yml
```yaml
name: Semver Bump
on:
push:
branches:
- "main"

jobs:
auto-semver:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout code"
uses: "actions/checkout@v3"
with:
fetch-depth: 0
- name: "Python Semantic Release"
uses: "python-semantic-release/python-semantic-release@master"
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
repository_username: __token__
repository_password: ${{ secrets.PYPI_TOKEN }}

```
2 changes: 1 addition & 1 deletion _version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""File to containing the version of the package."""

__version__ = "3.1.2"
__version__ = "3.2.0"
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Setup file for python-semantic-versioning."""

from setuptools import setup

from _version import __version__
Expand Down
Loading