From cf35d57ea8a64c38dee47c00ce3999da006954d3 Mon Sep 17 00:00:00 2001 From: pollenjp Date: Fri, 13 Sep 2024 20:56:30 +0900 Subject: [PATCH 1/2] change version definition location to __about__.py --- .github/workflows/pull_request_main.yml | 20 ++++++++++-------- .github/workflows/release.yml | 21 ++++++++++++------- pyproject.toml | 7 ++++--- .../__about__.py | 1 + 4 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 src/ansible_lint_custom_strict_naming/__about__.py diff --git a/.github/workflows/pull_request_main.yml b/.github/workflows/pull_request_main.yml index a4952d0..825d1bd 100644 --- a/.github/workflows/pull_request_main.yml +++ b/.github/workflows/pull_request_main.yml @@ -11,6 +11,9 @@ on: - synchronize permissions: contents: read +defaults: + run: + shell: bash -eux -o pipefail -o posix jobs: call_autolabel_workflow: permissions: @@ -20,23 +23,22 @@ jobs: check_release_version: runs-on: ubuntu-latest steps: + - name: Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 - name: Checkout - # https://github.com/actions/checkout uses: actions/checkout@v4 - name: Extract package version id: package_version - # https://github.com/freshautomations/stoml/releases - env: - STOML_VERSION: 0.7.1 run: | - set -eux -o pipefail - wget -O stoml "https://github.com/freshautomations/stoml/releases/download/v${STOML_VERSION}/stoml_linux_amd64" - chmod +x stoml - package_version=$(./stoml pyproject.toml project.version) + package_version=$( + PYTHONPATH='src/ansible_lint_custom_strict_naming' \ + python3 -c 'from __about__ import __version__; print(__version__)' + ) echo "package_version=${package_version}" >> $GITHUB_OUTPUT - name: Check the tag is new and doesn't exist run: | - set -eux -o pipefail package_version="${{ steps.package_version.outputs.package_version }}" if git fetch origin "refs/tags/v${package_version}"; then echo "${package_version} tag already exists!" >&2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5f46d3a..6eb1b23 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,25 +8,30 @@ permissions: contents: read env: UV_VERSION: 0.4.1 +defaults: + run: + shell: bash -eux -o pipefail -o posix jobs: update_release: permissions: contents: write runs-on: ubuntu-latest steps: + - name: Python + uses: actions/setup-python@v5 + with: + python-version: 3.12 - name: Checkout uses: actions/checkout@v4 - name: Extract package version id: package_version # https://github.com/freshautomations/stoml/releases - env: - STOML_VERSION: 0.7.1 run: | - set -eux -o pipefail - wget -O stoml "https://github.com/freshautomations/stoml/releases/download/v${STOML_VERSION}/stoml_linux_amd64" - chmod +x stoml - package_version=$(./stoml pyproject.toml project.version) - echo "PACKAGE_VERSION=${package_version}" >> $GITHUB_OUTPUT + package_version=$( + PYTHONPATH='src/ansible_lint_custom_strict_naming' \ + python3 -c 'from __about__ import __version__; print(__version__)' + ) + echo "package_version=${package_version}" >> $GITHUB_OUTPUT - name: Push tag run: | set -eux -o pipefail @@ -35,7 +40,7 @@ jobs: - uses: release-drafter/release-drafter@v5 with: config-name: release-drafter.yml - version: ${{ steps.package_version.outputs.PACKAGE_VERSION }} + version: ${{ steps.package_version.outputs.package_version }} publish: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/pyproject.toml b/pyproject.toml index 3bfadef..c3055ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,5 @@ [project] name = "ansible-lint-custom-strict-naming" -version = "1.1.1" description = "Add your description here" authors = [{ name = "pollenjp", email = "polleninjp@gmail.com" }] dependencies = ["ansible-lint>=6.24.0"] @@ -11,6 +10,7 @@ classifiers = [ "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.12", ] +dynamic = ["version"] [project.urls] "Homepage" = "https://github.com/pollenjp/ansible-lint-custom-strict-naming" @@ -36,8 +36,9 @@ dev-dependencies = ["pyright>=1.1.378", "ruff>=0.6.3"] "ansible_lint_custom_strict_naming" = "src/ansible_lint_custom_strict_naming" "ansiblelint.rules.custom.ansible_lint_custom_strict_naming" = "src/rules" -[tool.hatch.metadata] -allow-direct-references = true +[tool.setuptools.dynamic] +# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#dynamic-metadata +version = { attr = "ansible_lint_custom_strict_naming.__about__.__version__" } [tool.ruff] diff --git a/src/ansible_lint_custom_strict_naming/__about__.py b/src/ansible_lint_custom_strict_naming/__about__.py new file mode 100644 index 0000000..72f26f5 --- /dev/null +++ b/src/ansible_lint_custom_strict_naming/__about__.py @@ -0,0 +1 @@ +__version__ = "1.1.2" From 4a52871325b5bfccfed10db34b49dbe2b4cec6b9 Mon Sep 17 00:00:00 2001 From: pollenjp Date: Fri, 13 Sep 2024 22:02:15 +0900 Subject: [PATCH 2/2] Fix --- .github/workflows/pull_request_main.yml | 2 +- .github/workflows/release.yml | 4 ++-- .github/workflows/release_test.yml | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull_request_main.yml b/.github/workflows/pull_request_main.yml index 825d1bd..5d8e9e8 100644 --- a/.github/workflows/pull_request_main.yml +++ b/.github/workflows/pull_request_main.yml @@ -13,7 +13,7 @@ permissions: contents: read defaults: run: - shell: bash -eux -o pipefail -o posix + shell: bash -eux -o pipefail -o posix {0} jobs: call_autolabel_workflow: permissions: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6eb1b23..8ddcce8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,10 +7,10 @@ on: permissions: contents: read env: - UV_VERSION: 0.4.1 + UV_VERSION: 0.4.9 defaults: run: - shell: bash -eux -o pipefail -o posix + shell: bash -eux -o pipefail -o posix {0} jobs: update_release: permissions: diff --git a/.github/workflows/release_test.yml b/.github/workflows/release_test.yml index f829c03..0b5d42a 100644 --- a/.github/workflows/release_test.yml +++ b/.github/workflows/release_test.yml @@ -8,7 +8,10 @@ on: permissions: contents: read env: - UV_VERSION: 0.4.1 + UV_VERSION: 0.4.9 +defaults: + run: + shell: bash -eux -o pipefail -o posix {0} jobs: # https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-pypi release-build: @@ -16,7 +19,6 @@ jobs: steps: - name: Instal uv run: | - set -eux -o pipefail -o posix curl -LsSf https://astral.sh/uv/${{ env.UV_VERSION }}/install.sh | sh echo PATH="${HOME}/.cargo/bin:${PATH}" >> "${GITHUB_ENV}" - uses: actions/checkout@v4