Skip to content

Commit

Permalink
ci: add release please to the workflow (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
silentworks authored Aug 15, 2024
1 parent a060118 commit 55cf0ce
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 395 deletions.
94 changes: 65 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,87 +39,123 @@ jobs:
run: |
pip install pydantic==1.10.12
make tests_only
publish:
release-please:
needs: test
if: ${{ !startsWith(github.event.head_commit.message, 'bump') && !startsWith(github.event.head_commit.message, 'chore') && github.ref == 'refs/heads/main' && contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && github.repository_owner == 'supabase' }}
runs-on: ubuntu-latest
name: "supabase_auth: Bump version, create changelog and publish"
name: "Bump version and create changelog"
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: write # needed for github actions bot to write to repo
pull-requests: write
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
target-branch: ${{ github.ref_name }}

- if: ${{ steps.release.outputs }}
id: versions
run: |
set -ex
MAIN_RELEASE_VERSION=${{ steps.release.outputs.major }}.${{ steps.release.outputs.minor }}.${{ steps.release.outputs.patch }}
RELEASE_VERSION="$MAIN_RELEASE_VERSION"
RELEASE_NAME="v$RELEASE_VERSION"
RELEASE_CREATED='${{ steps.release.outputs.release_created }}'
PRS_CREATED='${{ steps.release.outputs.prs_created }}'
PR_TITLE='${{ github.event.head_commit.message }}'
echo "MAIN_RELEASE_VERSION=${MAIN_RELEASE_VERSION}" >> "${GITHUB_OUTPUT}"
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "${GITHUB_OUTPUT}"
echo "RELEASE_CREATED=${RELEASE_CREATED}" >> "${GITHUB_OUTPUT}"
echo "RELEASE_NAME=${RELEASE_NAME}" >> "${GITHUB_OUTPUT}"
echo "PRS_CREATED=${PRS_CREATED}" >> "${GITHUB_OUTPUT}"
echo "PR_TITLE=${PR_TITLE}" >> "${GITHUB_OUTPUT}"
publish:
needs: release-please
if: ${{ startsWith(github.event.head_commit.message, 'chore(main)') && github.ref == 'refs/heads/main' && github.event_name == 'push' && github.repository_owner == 'supabase' }}
runs-on: ubuntu-latest
name: "supabase_auth: Publish to PyPi"
environment:
name: pypi
url: https://pypi.org/p/supabase_auth
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: write # needed for dependabot to write to repo
outputs:
is-released: ${{ steps.release.outputs.released }}
steps:
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Clone Repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
token: ${{ secrets.SILENTWORKS_PAT }}
# This action uses Python Semantic Release v8
- name: Python Semantic Release
id: release
uses: python-semantic-release/[email protected]

- name: Set up Poetry
uses: abatilo/actions-poetry@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
poetry-version: 1.8.3

- name: Install dependencies
run: poetry install

- name: Build package dist directory
run: poetry build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true.
# See https://github.com/actions/runner/issues/1173
if: steps.release.outputs.released == 'true'

- name: Publish package distributions to GitHub Releases
uses: python-semantic-release/upload-to-gh-release@main
if: steps.release.outputs.released == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_legacy:
needs: publish
if: ${{ !startsWith(github.event.head_commit.message, 'bump') && !startsWith(github.event.head_commit.message, 'chore') && github.ref == 'refs/heads/main' && contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && github.repository_owner == 'supabase' }}
if: ${{ startsWith(github.event.head_commit.message, 'chore(main)') && github.ref == 'refs/heads/main' && github.event_name == 'push' && github.repository_owner == 'supabase' }}
runs-on: ubuntu-latest
name: "gotrue: Bump version and publish"
name: "gotrue: Publish to PyPi"
environment:
name: pypi
url: https://pypi.org/p/gotrue
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: write # needed for github actions bot to write to repo
steps:
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Clone Repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 0
token: ${{ secrets.SILENTWORKS_PAT }}

- name: Rename Project
id: rename_project
run: make rename_project

- name: Install poetry
- name: Set up Poetry
uses: abatilo/actions-poetry@v3
with:
poetry-version: 1.8.3

- name: Setup a local virtual environment (if no poetry.toml file)
run: |
poetry config virtualenvs.create true --local
poetry config virtualenvs.in-project true --local
- uses: actions/cache@v4
name: Define a cache for the virtual environment based on the dependencies lock file
with:
path: ./.venv
key: venv-${{ hashFiles('poetry.lock') }}

- name: Install the project dependencies
run: poetry install

- name: Build package distribution directory
id: build_dist
run: make build_package
- name: Build package dist directory
run: poetry build

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
# NOTE: DO NOT wrap the conditional in ${{ }} as it will always evaluate to true.
# See https://github.com/actions/runner/issues/1173
if: needs.publish.outputs.is-released == 'true'
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "2.6.2"
}
Loading

0 comments on commit 55cf0ce

Please sign in to comment.