From bd11a153d00e3210cfec322b9492307efc21eb24 Mon Sep 17 00:00:00 2001 From: mstechly Date: Tue, 21 May 2024 11:19:03 -0400 Subject: [PATCH] fix: add cicd workflows for build and release --- .github/workflows/build.yaml | 45 +++++++++++++++++++++++++++ .github/workflows/quality_checks.yaml | 4 +-- .github/workflows/release.yaml | 31 ++++++++---------- .pre-commit-config.yaml | 7 +++++ 4 files changed, 67 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/build.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..9c98377 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,45 @@ +name: Build and Publish + +on: + release: + types: [published] + +jobs: + publish: + runs-on: ubuntu-latest + environment: + name: pypi + # url: https://pypi.org/p/qref + url: https://test.pypi.org/p/qref + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: 3.9 + - name: Install pypa/build + run: python -m pip install build --user + - name: Setup poetry + uses: abatilo/actions-poetry@v2 + - name: Build the package + # run: poetry config pypi-token.pypi ${{ secrets.TWINE_PASSWORD }} + run: poetry config pypi-token.pypi ${{ secrets.TEST_TWINE_PASSWORD }} + + + + - name: Publish the package + run: poetry publish --build + ## Uncomment the below after IT trusted publisher pypi request has been submitted + # - name: Publish package distributions to PyPI + # uses: pypa/gh-action-pypi-publish@release/v1 + - name: Build docs + run: mike deploy $RELEASE_VERSION latest --update-aliases + env: + RELEASE_VERSION: ${GITHUB_REF#refs/*/} # or #{{ github.ref }} + + - name: Push docs + run: git push origin gh-pages:gh-pages + + diff --git a/.github/workflows/quality_checks.yaml b/.github/workflows/quality_checks.yaml index 7045935..bda4525 100644 --- a/.github/workflows/quality_checks.yaml +++ b/.github/workflows/quality_checks.yaml @@ -49,8 +49,8 @@ jobs: - name: Run quality checks run: | poetry install - pip install pre-commit - pre-commit install + pip install pre-commit + pre-commit install --hook-type commit-msg pre-commit run -a - name: Run mypy run: MYPYPATH=src poetry run mypy --install-types --non-interactive src diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3ea0aee..0f0ba59 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,26 +1,21 @@ -name: Build and release +name: Manual Trigger on: - release: - types: [published] + workflow_dispatch: jobs: - publish: + release-please: runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/p/qref # TODO: test PyPI - permissions: - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 + - name: Increment version + uses: googleapis/release-please-action@v4 with: - python-version: 3.9 - - name: Install pypa/build - run: python -m pip install build --user - - name: Build binary wheel and source tarball - run: python -m build --sdist --wheel --outdir dist/ - - name: Publish distribution to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} + release-type: python + skip-github-releases: false + skip-github-pull-request: true + +# bumps z in x.y.z if the commit message is: "fix: blah blah blah" (patch) +# bumps y in x.y.z if the commit message is: "feature: blah blah blah" (minor) +# bumps x in x.y.z if the commit message is "fix! or feature!: blah blah blah" (major) \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f99a4b9..def8df7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,3 +34,10 @@ repos: rev: 6.0.0 hooks: - id: flake8 + + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v3.2.0 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] + args: []