diff --git a/.github/workflows/main-release.yaml b/.github/workflows/main-release.yaml new file mode 100644 index 0000000..ab22dab --- /dev/null +++ b/.github/workflows/main-release.yaml @@ -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 \ No newline at end of file diff --git a/.github/workflows/pr-actionlint.yaml b/.github/workflows/pr-actionlint.yaml index 00ed73a..59a60b3 100644 --- a/.github/workflows/pr-actionlint.yaml +++ b/.github/workflows/pr-actionlint.yaml @@ -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) diff --git a/.github/workflows/pr-codeql.yaml b/.github/workflows/pr-codeql.yaml deleted file mode 100644 index 5bb368f..0000000 --- a/.github/workflows/pr-codeql.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: "CodeQL" - -on: - pull_request: - branches: [ "main" ] - paths: - - "**.py" - schedule: - - cron: '27 3 * * 1' - -permissions: read-all - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'python' ] - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" diff --git a/.github/workflows/pr-linting.yaml b/.github/workflows/pr-linting.yaml index 7fa361e..e8e8fd3 100644 --- a/.github/workflows/pr-linting.yaml +++ b/.github/workflows/pr-linting.yaml @@ -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 @@ -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 diff --git a/.github/workflows/pr-merge-dependabot.yaml b/.github/workflows/pr-merge-dependabot.yaml deleted file mode 100644 index a1064a4..0000000 --- a/.github/workflows/pr-merge-dependabot.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Dependabot auto-merge -on: - pull_request_target: - branches: - - main - -permissions: - pull-requests: write - contents: write - -jobs: - merge-dependabot: - runs-on: ubuntu-latest - if: ${{ github.actor == 'dependabot[bot]' }} - steps: - - name: Get token from Github App - id: app_token - uses: getsentry/action-github-app-token@v2 - with: - app_id: ${{ secrets.PR_APPROVAL_ID }} - private_key: ${{ secrets.PR_APPROVAL_PEM }} - - - name: Dependabot metadata - id: metadata - uses: dependabot/fetch-metadata@v1 - with: - github-token: "${{ secrets.GITHUB_TOKEN }}" - - name: Print package names - run: echo "${{ steps.metadata.outputs.dependency-names }}" - - name: Approve PR - run: gh pr review --approve "$PR_URL" - env: - PR_URL: ${{ github.event.pull_request.html_url }} - GITHUB_TOKEN: ${{ steps.app_token.outputs.token }} - - name: Merge PR - if: ${{ steps.metadata.outputs.update-type != 'version-update:semver-major' }} - run: gh pr merge --auto --squash "$PR_URL" - env: - PR_URL: ${{ github.event.pull_request.html_url }} - GITHUB_TOKEN: ${{ steps.app_token.outputs.token }} diff --git a/.github/workflows/semver.yaml b/.github/workflows/semver.yaml deleted file mode 100644 index 40b5083..0000000 --- a/.github/workflows/semver.yaml +++ /dev/null @@ -1,25 +0,0 @@ -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@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 }} diff --git a/README.md b/README.md index b0dbd88..65717bb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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 @@ -8,10 +8,10 @@ # 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 @@ -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 }} - -``` diff --git a/_version.py b/_version.py index 7d1b13b..4e66c3c 100644 --- a/_version.py +++ b/_version.py @@ -1,3 +1,3 @@ """File to containing the version of the package.""" -__version__ = "3.1.2" +__version__ = "3.2.0" diff --git a/setup.py b/setup.py index da00ced..9dafca6 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ """Setup file for python-semantic-versioning.""" + from setuptools import setup from _version import __version__