diff --git a/.github/actions/check-version-release/action.yml b/.github/actions/check-version-release/action.yml index 8cbc757..640e0c0 100644 --- a/.github/actions/check-version-release/action.yml +++ b/.github/actions/check-version-release/action.yml @@ -1,5 +1,5 @@ -name: check-pyproject-version -description: Check that the pyproject.toml version is the same as the latest GitHub release +name: check-package-attribute-version +description: Check that the package version attribute defined version is the same as the latest GitHub release. runs: using: composite @@ -15,8 +15,8 @@ runs: - shell: bash run: | pip install packaging==24.0 - PYPROJECT_VERSION=$(python -c "from src import cpr_sdk; print(cpr_sdk.__version__)") - echo "PYPROJECT_VERSION=${PYPROJECT_VERSION}" + PACKAGE_ATTRIBUTE_VERSION=$(python -c "from src import cpr_sdk; print(cpr_sdk.__version__)") + echo "PACKAGE_ATTRIBUTE_VERSION=${PACKAGE_ATTRIBUTE_VERSION}" GITHUB_RELEASE_VERSION=$(curl --silent "https://api.github.com/repos/climatepolicyradar/cpr-sdk/releases/latest" | jq -r '.tag_name') # remove the "v" from the version @@ -24,13 +24,13 @@ runs: echo "GITHUB_RELEASE_VERSION=${GITHUB_RELEASE_VERSION}" # Check that semver tag is equal to the github release version - PYPROJECT_EQUALS_GITHUB_RELEASE=$(python -c "from packaging.version import Version; print(Version('${PYPROJECT_VERSION}') == Version('${GITHUB_RELEASE_VERSION}'))") - echo "PYPROJECT_EQUALS_GITHUB_RELEASE=${PYPROJECT_EQUALS_GITHUB_RELEASE}" + PACKAGE_ATTRIBUTE_EQUALS_GITHUB_RELEASE=$(python -c "from packaging.version import Version; print(Version('${PACKAGE_ATTRIBUTE_VERSION}') == Version('${GITHUB_RELEASE_VERSION}'))") + echo "PACKAGE_ATTRIBUTE_EQUALS_GITHUB_RELEASE=${PACKAGE_ATTRIBUTE_EQUALS_GITHUB_RELEASE}" - if [[ "$PYPROJECT_EQUALS_GITHUB_RELEASE" == True ]]; then - echo "The pyproject.toml version is equal to the latest GitHub release." + if [[ "$PACKAGE_ATTRIBUTE_EQUALS_GITHUB_RELEASE" == True ]]; then + echo "The cpr_sdk.__version__ version is equal to the latest GitHub release." else - echo "The pyproject.toml version is NOT equal to the the latest GitHub release." + echo "The cpr_sdk.__version__ version is NOT equal to the the latest GitHub release." exit 1 fi \ No newline at end of file diff --git a/.github/actions/check-version/action.yml b/.github/actions/check-version/action.yml index e8f2036..6a8435d 100644 --- a/.github/actions/check-version/action.yml +++ b/.github/actions/check-version/action.yml @@ -1,5 +1,5 @@ -name: check-pyproject-version -description: Check that the pyproject.toml version is greater than the latest GitHub release +name: check-package-attribute-version +description: Check that the package attribute version is greater than the latest GitHub release runs: using: composite @@ -15,8 +15,8 @@ runs: - shell: bash run: | pip install packaging==24.0 - PYPROJECT_VERSION=$(python -c "from src import cpr_sdk; print(cpr_sdk.__version__)") - echo "PYPROJECT_VERSION=${PYPROJECT_VERSION}" + PACKAGE_ATTRIBUTE_VERSION=$(python -c "from src import cpr_sdk; print(cpr_sdk.__version__)") + echo "PACKAGE_ATTRIBUTE_VERSION=${PACKAGE_ATTRIBUTE_VERSION}" GITHUB_RELEASE_VERSION=$(curl --silent "https://api.github.com/repos/climatepolicyradar/cpr-sdk/releases/latest" | jq -r '.tag_name') # remove the "v" from the version @@ -24,12 +24,12 @@ runs: echo "GITHUB_RELEASE_VERSION=${GITHUB_RELEASE_VERSION}" # Check that semver tag is greater than the github release version - PYPROJECT_GREATER_THAN_GITHUB_RELEASE=$(python -c "from packaging.version import Version; print(Version('${PYPROJECT_VERSION}') > Version('${GITHUB_RELEASE_VERSION}'))") - echo "PYPROJECT_GREATER_THAN_GITHUB_RELEASE=${PYPROJECT_GREATER_THAN_GITHUB_RELEASE}" + PACKAGE_ATTRIBUTE_GREATER_THAN_GITHUB_RELEASE=$(python -c "from packaging.version import Version; print(Version('${PACKAGE_ATTRIBUTE_VERSION}') > Version('${GITHUB_RELEASE_VERSION}'))") + echo "PACKAGE_ATTRIBUTE_GREATER_THAN_GITHUB_RELEASE=${PACKAGE_ATTRIBUTE_GREATER_THAN_GITHUB_RELEASE}" - if [[ "$PYPROJECT_GREATER_THAN_GITHUB_RELEASE" == True ]]; then - echo "The pyproject.toml version is greater than the latest GitHub release." + if [[ "$PACKAGE_ATTRIBUTE_GREATER_THAN_GITHUB_RELEASE" == True ]]; then + echo "The cpr_sdk.__init__ version is greater than the latest GitHub release." else - echo "The pyproject.toml version is not greater than the latest GitHub release." + echo "The cpr_sdk.__init__ version is not greater than the latest GitHub release." exit 1 fi diff --git a/.github/actions/placeholder/action.yml b/.github/actions/placeholder/action.yml new file mode 100644 index 0000000..25d7d35 --- /dev/null +++ b/.github/actions/placeholder/action.yml @@ -0,0 +1,25 @@ +name: check-placeholder-version +description: Check that the placeholder version in the pyproject.toml is 0.0.0 + +runs: + using: composite + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + + - shell: bash + run: | + echo "PYPROJECT_VERSION=$(poetry version --short)" + + if [[ "$PYPROJECT_VERSION" == "0.0.0" ]]; then + echo "The pyproject.toml version is the correct placeholder version." + else + echo "The pyproject.toml version is NOT the correct placeholder version" + exit 1 + fi + \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5104e53..639a887 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,9 +33,18 @@ jobs: - name: Check the package version uses: ./.github/actions/check-version + placeholder-version-checks: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Check the placeholder version + uses: ./.github/actions/placeholder + test: runs-on: ubuntu-latest - needs: [precommit-checks, fixme-checks, package-version-checks] + needs: [precommit-checks, fixme-checks, package-version-checks, placeholder-version-checks] steps: - name: Check out repository code uses: actions/checkout@v4 @@ -58,7 +67,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.10" - cache: "poetry" + cache: poetry - name: Install dependencies run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f41f5f9..e8fbb92 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -32,9 +32,18 @@ jobs: - name: Run package version checks uses: ./.github/actions/check-version-release + placeholder-version-checks: + runs-on: ubuntu-latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + + - name: Check the placeholder version + uses: ./.github/actions/placeholder + test: runs-on: ubuntu-latest - needs: [precommit-checks, fixme-checks, package-version-checks] + needs: [precommit-checks, fixme-checks, package-version-checks, placeholder-version-checks] steps: - name: Check out repository code uses: actions/checkout@v4 @@ -57,7 +66,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.10" - cache: "poetry" + cache: poetry - name: Install dependencies run: |