diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0123613..410b743 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -5,7 +5,9 @@ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye", "features": { - "ghcr.io/devcontainers-contrib/features/poetry:2": {} + "ghcr.io/devcontainers-contrib/features/poetry:2": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} + } // Features to add to the dev container. More info: https://containers.dev/features. diff --git a/.github/workflows/build_and_publish.yml b/.github/workflows/build_and_publish.yml new file mode 100644 index 0000000..8b456fd --- /dev/null +++ b/.github/workflows/build_and_publish.yml @@ -0,0 +1,70 @@ +name: Publish the completed package to Pypi + +on: + push: + branches: + - main + +# permissions: # Global permissions configuration starts here +# contents: read # 'read' access to repository contents +# pull-requests: read # 'write' access to pull requests + +jobs: + codeql: + permissions: + actions: read + contents: read + security-events: write + uses: ./.github/workflows/codeql.yml + + test: + uses: ./.github/workflows/test-workflow.yml + + dependency-review: + uses: ./.github/workflows/dependency-review.yml + + publish: + needs: [test, dependency-review, codeql] + runs-on: ubuntu-latest + environment: + name: 'published' + permissions: # Job-level permissions configuration starts here + contents: write # 'write' access to repository contents + pull-requests: write # 'write' access to pull requests + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b # v1 + with: + version: 1.8.3 # pin the version as they keep changing their APIs + virtualenvs-create: false + virtualenvs-in-project: false + - name: Install dependencies + run: | + python -m venv venv + . venv/bin/activate + poetry install --with dev --no-interaction --sync + python -c "import os; print(os.environ['VIRTUAL_ENV'])" + - name: Bump version + run: | + poetry version minor + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add pyproject.toml + git commit -m "bump version from workflow" + git push origin HEAD:${{ github.head_ref }} + - name: Build + run: poetry build + - name: Use Pypi test + run: | + poetry config repositories.test-pypi https://test.pypi.org/legacy/ + poetry config pypi-token.test-pypi ${{ secrets.PYPI_TOKEN }} + - name: Publish + run: poetry publish -r test-pypi + + \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 63eae77..7463b03 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -9,14 +9,13 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: CodeQL on: + workflow_call: push: - branches: ["*", "*/*"] - pull_request: - # The branches below must be a subset of the branches above - branches: ["*", "*/*"] + branches-ignore: + - main schedule: - cron: "43 4 * * 3" @@ -72,4 +71,4 @@ jobs: - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@b611370bb5703a7efb587f9d136a52ea24c5c38c # v3 with: - category: "/language:${{matrix.language}}" \ No newline at end of file + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 7ab50fd..afa0b91 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -5,7 +5,8 @@ # Source repository: https://github.com/actions/dependency-review-action # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement name: 'Dependency Review' -on: [pull_request] +on: + workflow_call: permissions: contents: read diff --git a/.github/workflows/run_pytest.yml b/.github/workflows/test-workflow.yml similarity index 77% rename from .github/workflows/run_pytest.yml rename to .github/workflows/test-workflow.yml index 94a513b..0380f67 100644 --- a/.github/workflows/run_pytest.yml +++ b/.github/workflows/test-workflow.yml @@ -1,12 +1,15 @@ -name: Python package +name: test package on: + workflow_call: push: - branches-ignore: - - main - pull_request: - branches: - - main + branches-ignore: + - main + + +permissions: # Global permissions configuration starts here + contents: read # 'read' access to repository contents + pull-requests: read # 'write' access to pull requests jobs: test: @@ -14,17 +17,12 @@ jobs: matrix: python-version: ["3.12"] runs-on: ubuntu-latest - container: ubuntu:latest@sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30 steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5 with: python-version: ${{ matrix.python-version }} - - name: Install OS dependencies for snok/install-poetry - run: | - DEBIAN_FRONTEND=noninteractive apt update - DEBIAN_FRONTEND=noninteractive apt install curl sqlite3 -y - uses: snok/install-poetry@93ada01c735cc8a383ce0ce2ae205a21c415379b # v1 with: version: 1.8.3 # pin the version as they keep changing their APIs @@ -50,4 +48,4 @@ jobs: # - name: Upload coverage reports to Codecov # uses: codecov/codecov-action@0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1 # v4 # env: - # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + # CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/poetry.lock b/poetry.lock index 5e12832..ca523cb 100644 --- a/poetry.lock +++ b/poetry.lock @@ -636,4 +636,4 @@ zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "fde15ee212edd38aa2ee251a58533dcb2022d9ed632c8790602cdad2b3c0bc5f" +content-hash = "34842efbdeed2743df2ee59132ca8c52bfe471b1fd0eab814be3202ae812d27b" diff --git a/pyproject.toml b/pyproject.toml index a0e1777..3d1c49c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,15 +1,17 @@ [tool.poetry] name = "pydantic-tfl-api" -version = "0.1.0" +version = "0.2.0" description = "A Pydantic-based wrapper for the TfL Unified API https://api.tfl.gov.uk/. Not associated with or endorsed by TfL." authors = ["Rob Aleck "] license = "MIT" readme = "README.md" +homepage = "https://github.com/mnbf9rca/pydantic_tfl_api" +repository = "https://github.com/mnbf9rca/pydantic_tfl_api" [tool.poetry.dependencies] python = "^3.12" -pydantic = "^2.8.2" -requests = "^2.32.3" +pydantic = ">=2.8.2" +requests = ">=2.32.3" [tool.poetry.group.dev.dependencies] black = "^24.4.2"