From 8c76533eef61e248729a7d4e96417180098647b4 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 25 Oct 2024 10:36:20 +1000 Subject: [PATCH 1/9] remove incorrect 'v' from tag name pattern, we don't use it --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 917856a5..8d9cc0d8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,7 +4,7 @@ on: push: #On versioned releases tags: - - v*.*.* + - *.*.* # Allows you to run this workflow manually from the Actions tab workflow_dispatch: inputs: From e940ee5ac5b0bbbc16c97532e1fea83678215ee5 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 25 Oct 2024 10:37:06 +1000 Subject: [PATCH 2/9] configure default 'environment' value when publish workflow is triggered --- .github/workflows/publish.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8d9cc0d8..78e3dbd0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -100,32 +100,32 @@ jobs: name: Publish Package runs-on: ubuntu-latest environment: - name: ${{ github.event.inputs.environment }} + name: ${{ github.event.inputs.environment || 'pypi' }} url: ${{ steps.version.outputs.url }} concurrency: group: ${{ github.event.inputs.environment }}-deployment cancel-in-progress: false - + env: + ENVIRONMENT: ${{ github.event.inputs.environment || 'pypi' }} steps: - name: Get Git Tag and set url from environment id: version run: | #!/bin/bash - ENVIRONMENT=$1 TAG_VALUE=${GITHUB_REF/refs\/tags\//} echo "version=${TAG_VALUE}" >> $GITHUB_ENV # Extract the repository name (minus the owner/org) reponame=$(basename $GITHUB_REPOSITORY) echo "reponame=${reponame}" >> $GITHUB_OUTPUT - - if [ "$ENVIRONMENT" == "pypi" ]; then - url="https://pypi.com/p/$reponame" - elif [ "$1" == "testpypi" ]; then + + if [ "$env.ENVIRONMENT" == "testpypi" ]; then url="https://test.pypi.com/p/$reponame" + echo "environment=${env.ENVIRONMENT}" >> $GITHUB_OUTPUT else - url="" + url="https://pypi.com/p/$reponame" + echo "environment=pypi" >> $GITHUB_OUTPUT fi echo "url=${url}" >> $GITHUB_OUTPUT @@ -138,14 +138,14 @@ jobs: pip install twine python -m build - name: Publish package distributions to PyPI - if: ${{ startsWith(github.ref, 'refs/tags') && (github.event.inputs.environment == 'pypi' || github.event.inputs.environment == 'publish' ) && github.event.inputs.dryRun != 'true'}} + if: ${{ startsWith(github.ref, 'refs/tags') && steps.version.outputs.environment == 'pypi' && github.event.inputs.dryRun != 'true' }} uses: pypa/gh-action-pypi-publish@release/v1 # with: # skip-existing: true # verbose: true # print-hash: true - name: Test Publish package distributions to PyPI - if: ${{ startsWith(github.ref, 'refs/tags') && github.event.inputs.environment == 'testpypi' && github.event.inputs.dryRun == 'true' }} + if: ${{ startsWith(github.ref, 'refs/tags') && steps.version.outputs.environment == 'testpypi' && github.event.inputs.dryRun == 'true' }} uses: pypa/gh-action-pypi-publish@release/v1 with: repository-url: https://test.pypi.org/legacy/ From 9818b6172fb5c965f3741a542924dd5dce3e5f51 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 25 Oct 2024 10:37:28 +1000 Subject: [PATCH 3/9] check that tag value matches Python version before publishing to PyPI --- .github/workflows/publish.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 78e3dbd0..7a4ad8ca 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -132,6 +132,16 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + + - name: Validate tag version + if: ${{ startsWith(github.ref, 'refs/tags') }} + run: | + PYTHON_VERSION=$(grep "\bversion='[^']+'" | awk -F "'" '{print $2}') + if [ "${steps.version.outputs.version}" != "$PYTHON_VERSION" ]; then + echo "Version mismatch; tag version is [${steps.version.outputs.version}] but Python version is [$PYTHON_VERSION]" + exit 1 + fi + - name: Build package ${{ steps.version.outputs.reponame }} @ ${{ steps.version.outputs.version }} run: | pip install build From f0cbbb1c000b575ec8d2b3c9f6d4a49e88ea820b Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 25 Oct 2024 10:54:55 +1000 Subject: [PATCH 4/9] quote the GitHub publish workflow tag pattern --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7a4ad8ca..f701810a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,7 +4,7 @@ on: push: #On versioned releases tags: - - *.*.* + - '*.*.*' # Allows you to run this workflow manually from the Actions tab workflow_dispatch: inputs: From f398fa0b414c82c7b442ca858b81c5f1bbf64ba2 Mon Sep 17 00:00:00 2001 From: William Dutton Date: Fri, 25 Oct 2024 11:22:07 +1000 Subject: [PATCH 5/9] chore: bump 1.1.2 --- CHANGELOG | 20 ++++++++++++++++++++ setup.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 9159bc03..26bce2d0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,23 @@ +1.1.2 2024-10-25 +================ + +Feat: +* Frontend Status Badges by @JVickery-TBS in https://github.com/ckan/ckanext-xloader/pull/224 + +Fix: +* Fix automated PyPI publishing by @ThrawnCA in https://github.com/ckan/ckanext-xloader/pull/231 + + +**Full Changelog**: https://github.com/ckan/ckanext-xloader/compare/1.1.1...1.1.2 + +1.1.1 2024-10-16 +================ + +* feat: Add pypi cicd publish via github action via environment controls by @duttonw in https://github.com/ckan/ckanext-xloader/pull/228 + + +**Full Changelog**: https://github.com/ckan/ckanext-xloader/compare/1.1.0...1.1.1 + 1.1.0 2024-10-16 ================ diff --git a/setup.py b/setup.py index b3c7ec68..e656c509 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # http://packaging.python.org/en/latest/tutorial.html#version - version='1.1.1', + version='1.1.2', description='Express Loader - quickly load data into CKAN DataStore''', long_description=long_description, From cf5426169c5103b7cc6e9683f0b284f47c481e88 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 25 Oct 2024 11:29:37 +1000 Subject: [PATCH 6/9] send the tag version to the correct GitHub Actions value --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f701810a..f19260f1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -114,7 +114,7 @@ jobs: #!/bin/bash TAG_VALUE=${GITHUB_REF/refs\/tags\//} - echo "version=${TAG_VALUE}" >> $GITHUB_ENV + echo "version=${TAG_VALUE}" >> $GITHUB_OUTPUT # Extract the repository name (minus the owner/org) reponame=$(basename $GITHUB_REPOSITORY) From 320c15c1c139494edd0386842cd6b3192f7e7006 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 25 Oct 2024 12:19:12 +1000 Subject: [PATCH 7/9] fix syntax for GitHub Actions checking tag version --- .github/workflows/publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f19260f1..01b8e530 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -137,8 +137,8 @@ jobs: if: ${{ startsWith(github.ref, 'refs/tags') }} run: | PYTHON_VERSION=$(grep "\bversion='[^']+'" | awk -F "'" '{print $2}') - if [ "${steps.version.outputs.version}" != "$PYTHON_VERSION" ]; then - echo "Version mismatch; tag version is [${steps.version.outputs.version}] but Python version is [$PYTHON_VERSION]" + if [ "${{ steps.version.outputs.version }}" != "$PYTHON_VERSION" ]; then + echo "Version mismatch; tag version is [${{ steps.version.outputs.version }}] but Python version is [$PYTHON_VERSION]" exit 1 fi From b87393d308f4f06b2607491ff9a20de02d99ec9a Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 25 Oct 2024 12:25:52 +1000 Subject: [PATCH 8/9] fix pattern search for GitHub Actions checking tag version --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 01b8e530..ac8e41a7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -136,7 +136,7 @@ jobs: - name: Validate tag version if: ${{ startsWith(github.ref, 'refs/tags') }} run: | - PYTHON_VERSION=$(grep "\bversion='[^']+'" | awk -F "'" '{print $2}') + PYTHON_VERSION=$(grep -E "\bversion='[^']+'" setup.py | awk -F "'" '{print $2}') if [ "${{ steps.version.outputs.version }}" != "$PYTHON_VERSION" ]; then echo "Version mismatch; tag version is [${{ steps.version.outputs.version }}] but Python version is [$PYTHON_VERSION]" exit 1 From ac46cad1df0b54b8fe177dce2495e3bae1ce7839 Mon Sep 17 00:00:00 2001 From: antuarc Date: Fri, 25 Oct 2024 13:00:08 +1000 Subject: [PATCH 9/9] add version mismatch error message to GitHub step summary --- .github/workflows/publish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ac8e41a7..4d6153f3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -137,8 +137,9 @@ jobs: if: ${{ startsWith(github.ref, 'refs/tags') }} run: | PYTHON_VERSION=$(grep -E "\bversion='[^']+'" setup.py | awk -F "'" '{print $2}') + echo "Tag version is [${{ steps.version.outputs.version }}], Python version is [$PYTHON_VERSION]" if [ "${{ steps.version.outputs.version }}" != "$PYTHON_VERSION" ]; then - echo "Version mismatch; tag version is [${{ steps.version.outputs.version }}] but Python version is [$PYTHON_VERSION]" + echo "Version mismatch; tag version is [${{ steps.version.outputs.version }}] but Python version is [$PYTHON_VERSION]" >> $GITHUB_STEP_SUMMARY exit 1 fi