From c1c6a2fdf79fb60a9a55882889c3182788f32667 Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Fri, 7 Aug 2026 14:01:09 -0700 Subject: [PATCH 01/16] Add automation to drafting python release --- .github/workflows/draft-release.yml | 117 ++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 .github/workflows/draft-release.yml diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml new file mode 100644 index 0000000..e42c43b --- /dev/null +++ b/.github/workflows/draft-release.yml @@ -0,0 +1,117 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions. +# After doing that, it will draft a release with the most up to date version + +name: Draft release + +on: + workflow_dispatch: + inputs: + version: + description: 'Release version (must be in format .., e.g. 1.1.1)' + required: true + type: string + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + + steps: + - name: Verify inputs + env: + VERSION: ${{ inputs.version }} + run: | + SEMVER_REGEX="^([0-9]+)\.([0-9]+)\.([0-9]+)$" + if [[ ! "$VERSION" =~ $SEMVER_REGEX ]]; then + echo "::error::Invalid version format '$VERSION'. Must match X.Y.Z (e.g., 1.0.4)" + exit 1 + fi + + MAJOR="${BASH_REMATCH[1]}" + MINOR="${BASH_REMATCH[2]}" + PATCH="${BASH_REMATCH[3]}" + + # Latest released tag, newest first, ignoring anything not vX.Y.Z + LATEST_TAG=$(git ls-remote --tags --refs --sort=-v:refname \ + "https://github.com/${GITHUB_REPOSITORY}.git" \ + | sed 's#.*refs/tags/##' \ + | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \ + | head -n1) || true + + if [[ -z "$LATEST_TAG" ]]; then + echo "::error::No existing tag matching vX.Y.Z found" + exit 1 + fi + echo "Latest released tag: $LATEST_TAG" + + if [[ "$LATEST_TAG" == "v$VERSION" ]]; then + echo "::error::v$VERSION is already released" + exit 1 + fi + + [[ "${LATEST_TAG#v}" =~ $SEMVER_REGEX ]] + LATEST_MAJOR="${BASH_REMATCH[1]}" + LATEST_MINOR="${BASH_REMATCH[2]}" + LATEST_PATCH="${BASH_REMATCH[3]}" + + if [[ "$MAJOR" -eq "$LATEST_MAJOR" && "$MINOR" -eq "$LATEST_MINOR" && "$PATCH" -eq $((LATEST_PATCH + 1)) ]]; then + BUMP=patch + elif [[ "$MAJOR" -eq "$LATEST_MAJOR" && "$MINOR" -eq $((LATEST_MINOR + 1)) && "$PATCH" -eq 0 ]]; then + BUMP=minor + elif [[ "$MAJOR" -eq $((LATEST_MAJOR + 1)) && "$MINOR" -eq 0 && "$PATCH" -eq 0 ]]; then + BUMP=major + else + echo "::error::v$VERSION is not a valid bump from $LATEST_TAG" + exit 1 + fi + + echo "Releasing v$VERSION ($BUMP bump from $LATEST_TAG)" + + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt -r dev-requirements.txt + pip install -e . + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Lint with PyLint + run: pylint --rcfile=.pylintrc src/aws_secretsmanager_caching + - name: Check formatting with Ruff + uses: astral-sh/ruff-action@v3 + - name: Test with pytest + run: | + pytest test/unit/ + + draft-release: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Draft release v${{ inputs.version }} + env: + GH_TOKEN: ${{ github.token }} + VERSION: ${{ inputs.version }} + run: | + gh release create "v$VERSION" \ + --title "v$VERSION" \ + --generate-notes \ + --target "$GITHUB_SHA" + + echo "Drafted release v$VERSION" + gh release view "v$VERSION" --json url -q .url + \ No newline at end of file From cc73b6be8156caafebd3fcf43103d44af86a314d Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Tue, 11 Aug 2026 15:23:20 -0700 Subject: [PATCH 02/16] Add call to PR workflow --- .github/workflows/draft-release.yml | 94 +++++++--------------------- .github/workflows/python-package.yml | 11 ++-- 2 files changed, 28 insertions(+), 77 deletions(-) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index e42c43b..a1c415b 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions. # After doing that, it will draft a release with the most up to date version -name: Draft release +name: Create New Release on: workflow_dispatch: @@ -11,19 +11,14 @@ on: required: true type: string -permissions: - contents: write - jobs: - build: + verify-input: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] - + permissions: + contents: read steps: - - name: Verify inputs + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + - name: Verify input env: VERSION: ${{ inputs.version }} run: | @@ -33,75 +28,31 @@ jobs: exit 1 fi - MAJOR="${BASH_REMATCH[1]}" - MINOR="${BASH_REMATCH[2]}" - PATCH="${BASH_REMATCH[3]}" + TAG="v$VERSION" - # Latest released tag, newest first, ignoring anything not vX.Y.Z - LATEST_TAG=$(git ls-remote --tags --refs --sort=-v:refname \ - "https://github.com/${GITHUB_REPOSITORY}.git" \ - | sed 's#.*refs/tags/##' \ - | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \ - | head -n1) || true - - if [[ -z "$LATEST_TAG" ]]; then - echo "::error::No existing tag matching vX.Y.Z found" + # Fail if the tag already exists + if git ls-remote --tags origin | grep -q "refs/tags/$TAG"; then + echo "Error: Tag $TAG already exists. Aborting." exit 1 fi - echo "Latest released tag: $LATEST_TAG" - if [[ "$LATEST_TAG" == "v$VERSION" ]]; then - echo "::error::v$VERSION is already released" - exit 1 - fi - - [[ "${LATEST_TAG#v}" =~ $SEMVER_REGEX ]] - LATEST_MAJOR="${BASH_REMATCH[1]}" - LATEST_MINOR="${BASH_REMATCH[2]}" - LATEST_PATCH="${BASH_REMATCH[3]}" + echo "Creating Tag $TAG ..." - if [[ "$MAJOR" -eq "$LATEST_MAJOR" && "$MINOR" -eq "$LATEST_MINOR" && "$PATCH" -eq $((LATEST_PATCH + 1)) ]]; then - BUMP=patch - elif [[ "$MAJOR" -eq "$LATEST_MAJOR" && "$MINOR" -eq $((LATEST_MINOR + 1)) && "$PATCH" -eq 0 ]]; then - BUMP=minor - elif [[ "$MAJOR" -eq $((LATEST_MAJOR + 1)) && "$MINOR" -eq 0 && "$PATCH" -eq 0 ]]; then - BUMP=major - else - echo "::error::v$VERSION is not a valid bump from $LATEST_TAG" - exit 1 - fi - - echo "Releasing v$VERSION ($BUMP bump from $LATEST_TAG)" - - - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt -r dev-requirements.txt - pip install -e . - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Lint with PyLint - run: pylint --rcfile=.pylintrc src/aws_secretsmanager_caching - - name: Check formatting with Ruff - uses: astral-sh/ruff-action@v3 - - name: Test with pytest - run: | - pytest test/unit/ + run-test: + permissions: + contents: read + id-token: write + needs: verify-input + uses: ./.github/workflows/python-package.yml draft-release: - needs: build + needs: run-test runs-on: ubuntu-latest + permissions: + contents: write + environment: release steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 - name: Draft release v${{ inputs.version }} env: GH_TOKEN: ${{ github.token }} @@ -113,5 +64,4 @@ jobs: --target "$GITHUB_SHA" echo "Drafted release v$VERSION" - gh release view "v$VERSION" --json url -q .url \ No newline at end of file diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 80bd166..1a14316 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -8,6 +8,7 @@ on: branches: [master] pull_request: branches: [master] + workflow_call: permissions: contents: read @@ -22,9 +23,9 @@ jobs: python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -41,14 +42,14 @@ jobs: - name: Lint with PyLint run: pylint --rcfile=.pylintrc src/aws_secretsmanager_caching - name: Check formatting with Ruff - uses: astral-sh/ruff-action@v3 + uses: astral-sh/ruff-action@4919ec5cf1f49eff0871dbcea0da843445b837e6 with: version: "0.15.22" - name: Test with pytest run: | pytest test/unit/ - name: Upload coverage to Codecov - uses: codecov/codecov-action@v5 + uses: codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac with: - fail_ci_if_error: true + fail_ci_if_error: false # REMEMBER TO FIX (SET LIKE THIS FOR TESTING) use_oidc: true From 32978bdf5efea553649a7fd146f0517dbd894c4d Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Tue, 11 Aug 2026 15:30:07 -0700 Subject: [PATCH 03/16] test --- .github/workflows/draft-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index a1c415b..0be6916 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -52,6 +52,7 @@ jobs: contents: write environment: release steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 - name: Draft release v${{ inputs.version }} env: From e53fadf5f56c0d45d2e62569d2e30a79f830a8d1 Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Tue, 11 Aug 2026 15:37:27 -0700 Subject: [PATCH 04/16] test pr --- .github/workflows/draft-release.yml | 1 - .github/workflows/python-package.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index 0be6916..a1c415b 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -52,7 +52,6 @@ jobs: contents: write environment: release steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 - name: Draft release v${{ inputs.version }} env: diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 1a14316..a09a978 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -51,5 +51,5 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac with: - fail_ci_if_error: false # REMEMBER TO FIX (SET LIKE THIS FOR TESTING) + fail_ci_if_error: false # REMEMBER TO FIX (SET LIKE THIS FOR TESTING) blah blah blah use_oidc: true From d5bc6b91442984f5dd05f89842ab6c776b83af3c Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Tue, 11 Aug 2026 15:42:28 -0700 Subject: [PATCH 05/16] reenable code cov --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a09a978..0b4199c 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -51,5 +51,5 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac with: - fail_ci_if_error: false # REMEMBER TO FIX (SET LIKE THIS FOR TESTING) blah blah blah + fail_ci_if_error: true use_oidc: true From d92bd453b1d5f33fb5096b5e7a1915ac40c7fa5d Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Wed, 12 Aug 2026 09:39:28 -0700 Subject: [PATCH 06/16] Add some comments --- .github/workflows/draft-release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml index a1c415b..6ba186b 100644 --- a/.github/workflows/draft-release.yml +++ b/.github/workflows/draft-release.yml @@ -22,6 +22,7 @@ jobs: env: VERSION: ${{ inputs.version }} run: | + # Make sure the input matches the intended format SEMVER_REGEX="^([0-9]+)\.([0-9]+)\.([0-9]+)$" if [[ ! "$VERSION" =~ $SEMVER_REGEX ]]; then echo "::error::Invalid version format '$VERSION'. Must match X.Y.Z (e.g., 1.0.4)" @@ -43,6 +44,7 @@ jobs: contents: read id-token: write needs: verify-input + # Calls the Pull Request workflow and ensure all tests pass before moving on uses: ./.github/workflows/python-package.yml draft-release: From 0a6ebac985609ebb50075cdd7241af8dba696db4 Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Fri, 14 Aug 2026 09:44:53 -0700 Subject: [PATCH 07/16] Rename Yaml --- .github/workflows/{draft-release.yml => create-release.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{draft-release.yml => create-release.yml} (100%) diff --git a/.github/workflows/draft-release.yml b/.github/workflows/create-release.yml similarity index 100% rename from .github/workflows/draft-release.yml rename to .github/workflows/create-release.yml From 36e7ac5e623258cab2ba74e250225c536e9440ca Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Tue, 1 Sep 2026 10:24:34 -0700 Subject: [PATCH 08/16] Add a Publish Release Workflow --- .github/workflows/publish-release.yml | 80 +++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..0bc817f --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,80 @@ +# This workflow will publish the python binaries to PyPI + +name: Publish Release + +on: + workflow_call: + +jobs: + release-build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + with: + python-version: "3.x" + + - name: build release distributions + run: | + # NOTE: put your own distribution build steps here. + pip install --upgrade pip + pip install -r requirements.txt + pip install build wheel setuptools + python setup.py install + python -m build + + - name: upload windows dists + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + with: + name: release-dists + path: dist/ + + pypi-publish-test: + runs-on: ubuntu-latest + needs: + - release-build + permissions: + id-token: write + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 + with: + name: release-dists + path: dist/ + + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f + with: + repository-url: https://test.pypi.org/legacy/ + + READ-PLEASE: + runs-on: ubuntu-latest + needs: pypi-publish-test + steps: + - name: Review Instructuons (PLEASE READ) + run: | + echo "Please do the following before approving release for prod." + echo "Go to https://test.pypi.org/project/aws-secretsmanager-caching/" + echo "Check the page for completeness. There should be a new version published, and two artifacts in the "Download files" section: a wheel (.whl) and a source distribution (.tar.gz)" + + pypi-publish: + runs-on: ubuntu-latest + environment: publish # Will act as a temporary blocker that the invoker can self-approve so that they would check if the binaries uploaded properly + needs: + - READ-PLEASE + permissions: + id-token: write + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 + with: + name: release-dists + path: dist/ + + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f + \ No newline at end of file From e56a52506fa227164c2bdb63f1df17557de5e3c2 Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Tue, 1 Sep 2026 10:39:22 -0700 Subject: [PATCH 09/16] add release --- .github/workflows/publish-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 0bc817f..dbc53d6 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -46,7 +46,7 @@ jobs: path: dist/ - name: Publish release distributions to PyPI - uses: pypa/gh-action-pypi-publish@3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f + uses: pypa/gh-action-pypi-publish@release/3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f with: repository-url: https://test.pypi.org/legacy/ @@ -76,5 +76,5 @@ jobs: path: dist/ - name: Publish release distributions to PyPI - uses: pypa/gh-action-pypi-publish@3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f + uses: pypa/gh-action-pypi-publish@release/3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f \ No newline at end of file From 8e0ce736fa7bca4b74e04f9a67e3af3d5b46346c Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Wed, 2 Sep 2026 08:37:33 -0700 Subject: [PATCH 10/16] Add version comments --- .github/workflows/create-release.yml | 8 +++----- .github/workflows/publish-release.yml | 16 ++++++++-------- .github/workflows/python-package.yml | 8 ++++---- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 6ba186b..94527eb 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -1,5 +1,4 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions. -# After doing that, it will draft a release with the most up to date version +# Create a new release with the specified version name: Create New Release @@ -17,7 +16,7 @@ jobs: permissions: contents: read steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - name: Verify input env: VERSION: ${{ inputs.version }} @@ -44,7 +43,6 @@ jobs: contents: read id-token: write needs: verify-input - # Calls the Pull Request workflow and ensure all tests pass before moving on uses: ./.github/workflows/python-package.yml draft-release: @@ -54,7 +52,7 @@ jobs: contents: write environment: release steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - name: Draft release v${{ inputs.version }} env: GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index dbc53d6..b713ed5 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -10,9 +10,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 with: python-version: "3.x" @@ -25,8 +25,8 @@ jobs: python setup.py install python -m build - - name: upload windows dists - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 + - name: upload artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 with: name: release-dists path: dist/ @@ -40,13 +40,13 @@ jobs: steps: - name: Retrieve release distributions - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5 with: name: release-dists path: dist/ - name: Publish release distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f + uses: pypa/gh-action-pypi-publish@release/717ba43cfbb0387f6ce311b169a825772f54d295 # v1 with: repository-url: https://test.pypi.org/legacy/ @@ -70,11 +70,11 @@ jobs: steps: - name: Retrieve release distributions - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5 with: name: release-dists path: dist/ - name: Publish release distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f + uses: pypa/gh-action-pypi-publish@release/717ba43cfbb0387f6ce311b169a825772f54d295 # v1 \ No newline at end of file diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 0b4199c..74ec744 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -23,9 +23,9 @@ jobs: python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -42,14 +42,14 @@ jobs: - name: Lint with PyLint run: pylint --rcfile=.pylintrc src/aws_secretsmanager_caching - name: Check formatting with Ruff - uses: astral-sh/ruff-action@4919ec5cf1f49eff0871dbcea0da843445b837e6 + uses: astral-sh/ruff-action@4919ec5cf1f49eff0871dbcea0da843445b837e6 # v3 with: version: "0.15.22" - name: Test with pytest run: | pytest test/unit/ - name: Upload coverage to Codecov - uses: codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac + uses: codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac # v5 with: fail_ci_if_error: true use_oidc: true From ced9ca6523412310d68b73b5cabb971348586b7d Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Wed, 2 Sep 2026 13:48:11 -0700 Subject: [PATCH 11/16] Add new publish-test environment --- .github/workflows/publish-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index b713ed5..934c173 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -33,6 +33,7 @@ jobs: pypi-publish-test: runs-on: ubuntu-latest + environment: publish-test needs: - release-build permissions: From 2a96a3ceed468f57ffe962df5f32b9ad66e75f18 Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Mon, 14 Sep 2026 15:58:28 -0700 Subject: [PATCH 12/16] Address Comments --- .github/workflows/create-release.yml | 13 ++++++++++--- .github/workflows/publish-release.yml | 13 ++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 94527eb..6c8291a 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -39,13 +39,13 @@ jobs: echo "Creating Tag $TAG ..." run-test: + needs: verify-input permissions: contents: read id-token: write - needs: verify-input uses: ./.github/workflows/python-package.yml - draft-release: + create-release: needs: run-test runs-on: ubuntu-latest permissions: @@ -64,4 +64,11 @@ jobs: --target "$GITHUB_SHA" echo "Drafted release v$VERSION" - \ No newline at end of file + + publish-binaries: + needs: create-release + permissions: + contents: read + id-token: write + uses: ./.github/workflows/publish-release.yml + \ No newline at end of file diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 934c173..e8ad6bf 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -8,6 +8,8 @@ on: jobs: release-build: runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 @@ -18,11 +20,11 @@ jobs: - name: build release distributions run: | - # NOTE: put your own distribution build steps here. + set -euo pipefail pip install --upgrade pip pip install -r requirements.txt pip install build wheel setuptools - python setup.py install + python -m pip install . python -m build - name: upload artifacts @@ -46,10 +48,11 @@ jobs: name: release-dists path: dist/ - - name: Publish release distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/717ba43cfbb0387f6ce311b169a825772f54d295 # v1 + - name: Publish release distributions to Test PyPI + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1 with: repository-url: https://test.pypi.org/legacy/ + skip-existing: true READ-PLEASE: runs-on: ubuntu-latest @@ -77,5 +80,5 @@ jobs: path: dist/ - name: Publish release distributions to PyPI - uses: pypa/gh-action-pypi-publish@release/717ba43cfbb0387f6ce311b169a825772f54d295 # v1 + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1 \ No newline at end of file From ccfc3aa45bf471f5cd4ff38612b590c13b1008c4 Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Tue, 15 Sep 2026 10:23:55 -0700 Subject: [PATCH 13/16] fix issues in comments --- .github/workflows/create-release.yml | 74 ++++++++++++++++++++++- .github/workflows/publish-release.yml | 84 --------------------------- 2 files changed, 71 insertions(+), 87 deletions(-) delete mode 100644 .github/workflows/publish-release.yml diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 6c8291a..01f8309 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -65,10 +65,78 @@ jobs: echo "Drafted release v$VERSION" - publish-binaries: + release-build: needs: create-release + runs-on: ubuntu-latest permissions: contents: read + + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + fetch-tags: true + + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 + with: + python-version: "3.x" + + - name: build release distributions + run: | + set -euo pipefail + pip install build + python -m build + + - name: upload artifacts + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: release-dists + path: dist/ + + pypi-publish-test: + needs: release-build + runs-on: ubuntu-latest + environment: publish-test + permissions: + id-token: write + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5 + with: + name: release-dists + path: dist/ + + - name: Publish release distributions to Test PyPI + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1 + with: + repository-url: https://test.pypi.org/legacy/ + skip-existing: true + verbose: true + + READ-PLEASE: + needs: pypi-publish-test + runs-on: ubuntu-latest + steps: + - name: Review Instructuons (PLEASE READ) + run: | + echo "Please do the following before approving release for prod." + echo "Go to https://test.pypi.org/project/aws-secretsmanager-caching/" + echo "Check the page for completeness. There should be a new version published, and two artifacts in the "Download files" section: a wheel (.whl) and a source distribution (.tar.gz)" + + pypi-publish: + needs: READ-PLEASE + runs-on: ubuntu-latest + environment: publish + permissions: id-token: write - uses: ./.github/workflows/publish-release.yml - \ No newline at end of file + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5 + with: + name: release-dists + path: dist/ + + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1 + \ No newline at end of file diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml deleted file mode 100644 index e8ad6bf..0000000 --- a/.github/workflows/publish-release.yml +++ /dev/null @@ -1,84 +0,0 @@ -# This workflow will publish the python binaries to PyPI - -name: Publish Release - -on: - workflow_call: - -jobs: - release-build: - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - - - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 - with: - python-version: "3.x" - - - name: build release distributions - run: | - set -euo pipefail - pip install --upgrade pip - pip install -r requirements.txt - pip install build wheel setuptools - python -m pip install . - python -m build - - - name: upload artifacts - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 - with: - name: release-dists - path: dist/ - - pypi-publish-test: - runs-on: ubuntu-latest - environment: publish-test - needs: - - release-build - permissions: - id-token: write - - steps: - - name: Retrieve release distributions - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5 - with: - name: release-dists - path: dist/ - - - name: Publish release distributions to Test PyPI - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1 - with: - repository-url: https://test.pypi.org/legacy/ - skip-existing: true - - READ-PLEASE: - runs-on: ubuntu-latest - needs: pypi-publish-test - steps: - - name: Review Instructuons (PLEASE READ) - run: | - echo "Please do the following before approving release for prod." - echo "Go to https://test.pypi.org/project/aws-secretsmanager-caching/" - echo "Check the page for completeness. There should be a new version published, and two artifacts in the "Download files" section: a wheel (.whl) and a source distribution (.tar.gz)" - - pypi-publish: - runs-on: ubuntu-latest - environment: publish # Will act as a temporary blocker that the invoker can self-approve so that they would check if the binaries uploaded properly - needs: - - READ-PLEASE - permissions: - id-token: write - - steps: - - name: Retrieve release distributions - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5 - with: - name: release-dists - path: dist/ - - - name: Publish release distributions to PyPI - uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1 - \ No newline at end of file From 2362195400423d9ab2f85c53a46e7754a2185a88 Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Mon, 21 Sep 2026 23:47:52 -0700 Subject: [PATCH 14/16] Address Comments --- .github/workflows/create-release.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 01f8309..0a33cc0 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -10,6 +10,10 @@ on: required: true type: string +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: true + jobs: verify-input: runs-on: ubuntu-latest @@ -31,7 +35,7 @@ jobs: TAG="v$VERSION" # Fail if the tag already exists - if git ls-remote --tags origin | grep -q "refs/tags/$TAG"; then + if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then echo "Error: Tag $TAG already exists. Aborting." exit 1 fi @@ -111,7 +115,6 @@ jobs: with: repository-url: https://test.pypi.org/legacy/ skip-existing: true - verbose: true READ-PLEASE: needs: pypi-publish-test @@ -119,9 +122,10 @@ jobs: steps: - name: Review Instructuons (PLEASE READ) run: | - echo "Please do the following before approving release for prod." - echo "Go to https://test.pypi.org/project/aws-secretsmanager-caching/" - echo "Check the page for completeness. There should be a new version published, and two artifacts in the "Download files" section: a wheel (.whl) and a source distribution (.tar.gz)" + echo "Please do the following before approving release for prod. + Go to https://test.pypi.org/project/aws-secretsmanager-caching/ + Check the page for completeness. There should be a new version published, and two artifacts in the "Download files" section: a wheel (.whl) and a source distribution (.tar.gz)" >> $GITHUB_STEP_SUMMARY + pypi-publish: needs: READ-PLEASE From 725eef2b3bbc0afb09c61f2d7eba4e006cc78e94 Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Tue, 22 Sep 2026 00:17:50 -0700 Subject: [PATCH 15/16] Fix typo --- .github/workflows/create-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 0a33cc0..2b49e2c 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -124,7 +124,7 @@ jobs: run: | echo "Please do the following before approving release for prod. Go to https://test.pypi.org/project/aws-secretsmanager-caching/ - Check the page for completeness. There should be a new version published, and two artifacts in the "Download files" section: a wheel (.whl) and a source distribution (.tar.gz)" >> $GITHUB_STEP_SUMMARY + Check the page for completeness. There should be a new version published, and two artifacts in the "Release files" section: a wheel (.whl) and a source distribution (.tar.gz)" >> $GITHUB_STEP_SUMMARY pypi-publish: From 0bc2c8ab019fa9879fb6f8cd294c246cfdbc9d82 Mon Sep 17 00:00:00 2001 From: Ryan Li Date: Tue, 22 Sep 2026 11:02:16 -0700 Subject: [PATCH 16/16] Address Comments --- .github/workflows/create-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 2b49e2c..c7d49e8 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -12,7 +12,7 @@ on: concurrency: group: ${{ github.workflow }} - cancel-in-progress: true + cancel-in-progress: false jobs: verify-input: @@ -35,7 +35,7 @@ jobs: TAG="v$VERSION" # Fail if the tag already exists - if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then + if git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null 2>&1; then echo "Error: Tag $TAG already exists. Aborting." exit 1 fi