From 971c788178d5d732107760c1e34c71330aac2da7 Mon Sep 17 00:00:00 2001 From: mariugul Date: Thu, 29 Aug 2024 01:29:35 +0200 Subject: [PATCH] ci: add release-please Adds release please as a tool to automatically create PR's in GitHub incrementing python package versions, as well as building and publishing packages to PyPi on new releases. --- .github/workflows/release-please.yml | 73 ++++++++++++++++++++++++++++ .release-please-manifest.json | 0 pyproject.toml | 2 +- release-please-config.json | 13 +++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-please.yml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 00000000..b3705054 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,73 @@ +on: + push: + branches: + - main + +name: release-please + +permissions: + contents: write + pull-requests: write + + +jobs: + release-please: + runs-on: ubuntu-latest + outputs: + release_created: ${{ steps.release.outputs.release_created }} + steps: + - name: Release Please + id: release + uses: googleapis/release-please-action@v4 + with: + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} + + build-and-publish: + runs-on: ubuntu-latest + needs: release-please + if: ${{ needs.release-please.outputs.release_created == 'true' }} + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + environment: + name: pypi + url: https://pypi.org/p/pikaraoke + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.9' + + - name: Cache Poetry Install + id: cache-poetry + uses: actions/cache@v4 + with: + path: | + /opt/poetry + ~/.cache/pypoetry + .venv + key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('**/pyproject.toml') + }} + + - name: Install Poetry + if: steps.cache-poetry.outputs.cache-hit != 'true' + run: | + export POETRY_HOME=/opt/poetry + python3 -m venv $POETRY_HOME + $POETRY_HOME/bin/pip install poetry==1.8.2 + $POETRY_HOME/bin/poetry --version + + - name: Add Poetry to PATH + run: echo "/opt/poetry/bin" >> $GITHUB_PATH + + - name: Install Package + run: poetry install --no-interaction --no-ansi + + - name: Build Package + run: poetry build + + - name: Publish Python 🐍 distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 00000000..e69de29b diff --git a/pyproject.toml b/pyproject.toml index 22d983db..7c8d14ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pikaraoke" -version = "1.0.0" +version = "1.3.0" description = "Youtube-based Karaoke machine for Raspberry Pi, OSX, Windows, and Linux" authors = ["Vic Wong"] diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..0efc5904 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "packages": { + ".": { + "package-name": "pikaraoke", + "release-type": "python", + "include-component-in-tag": false, + "include-v-in-tag": false, + "changelog-path": "pikaraoke/CHANGELOG.md", + "version-file": "pikaraoke/version.py" + } + } +}