Skip to content

Commit b0b576d

Browse files
committed
Add call to PR workflow
1 parent c78ac61 commit b0b576d

2 files changed

Lines changed: 28 additions & 77 deletions

File tree

Lines changed: 22 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions.
22
# After doing that, it will draft a release with the most up to date version
33

4-
name: Draft release
4+
name: Create New Release
55

66
on:
77
workflow_dispatch:
@@ -11,19 +11,14 @@ on:
1111
required: true
1212
type: string
1313

14-
permissions:
15-
contents: write
16-
1714
jobs:
18-
build:
15+
verify-input:
1916
runs-on: ubuntu-latest
20-
strategy:
21-
fail-fast: false
22-
matrix:
23-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
24-
17+
permissions:
18+
contents: read
2519
steps:
26-
- name: Verify inputs
20+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
21+
- name: Verify input
2722
env:
2823
VERSION: ${{ inputs.version }}
2924
run: |
@@ -33,75 +28,31 @@ jobs:
3328
exit 1
3429
fi
3530
36-
MAJOR="${BASH_REMATCH[1]}"
37-
MINOR="${BASH_REMATCH[2]}"
38-
PATCH="${BASH_REMATCH[3]}"
31+
TAG="v$VERSION"
3932
40-
# Latest released tag, newest first, ignoring anything not vX.Y.Z
41-
LATEST_TAG=$(git ls-remote --tags --refs --sort=-v:refname \
42-
"https://github.com/${GITHUB_REPOSITORY}.git" \
43-
| sed 's#.*refs/tags/##' \
44-
| grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' \
45-
| head -n1) || true
46-
47-
if [[ -z "$LATEST_TAG" ]]; then
48-
echo "::error::No existing tag matching vX.Y.Z found"
33+
# Fail if the tag already exists
34+
if git ls-remote --tags origin | grep -q "refs/tags/$TAG"; then
35+
echo "Error: Tag $TAG already exists. Aborting."
4936
exit 1
5037
fi
51-
echo "Latest released tag: $LATEST_TAG"
5238
53-
if [[ "$LATEST_TAG" == "v$VERSION" ]]; then
54-
echo "::error::v$VERSION is already released"
55-
exit 1
56-
fi
57-
58-
[[ "${LATEST_TAG#v}" =~ $SEMVER_REGEX ]]
59-
LATEST_MAJOR="${BASH_REMATCH[1]}"
60-
LATEST_MINOR="${BASH_REMATCH[2]}"
61-
LATEST_PATCH="${BASH_REMATCH[3]}"
39+
echo "Creating Tag $TAG ..."
6240
63-
if [[ "$MAJOR" -eq "$LATEST_MAJOR" && "$MINOR" -eq "$LATEST_MINOR" && "$PATCH" -eq $((LATEST_PATCH + 1)) ]]; then
64-
BUMP=patch
65-
elif [[ "$MAJOR" -eq "$LATEST_MAJOR" && "$MINOR" -eq $((LATEST_MINOR + 1)) && "$PATCH" -eq 0 ]]; then
66-
BUMP=minor
67-
elif [[ "$MAJOR" -eq $((LATEST_MAJOR + 1)) && "$MINOR" -eq 0 && "$PATCH" -eq 0 ]]; then
68-
BUMP=major
69-
else
70-
echo "::error::v$VERSION is not a valid bump from $LATEST_TAG"
71-
exit 1
72-
fi
73-
74-
echo "Releasing v$VERSION ($BUMP bump from $LATEST_TAG)"
75-
76-
- uses: actions/checkout@v4
77-
- name: Set up Python ${{ matrix.python-version }}
78-
uses: actions/setup-python@v5
79-
with:
80-
python-version: ${{ matrix.python-version }}
81-
- name: Install dependencies
82-
run: |
83-
python -m pip install --upgrade pip
84-
pip install -r requirements.txt -r dev-requirements.txt
85-
pip install -e .
86-
- name: Lint with flake8
87-
run: |
88-
# stop the build if there are Python syntax errors or undefined names
89-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
90-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
91-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
92-
- name: Lint with PyLint
93-
run: pylint --rcfile=.pylintrc src/aws_secretsmanager_caching
94-
- name: Check formatting with Ruff
95-
uses: astral-sh/ruff-action@v3
96-
- name: Test with pytest
97-
run: |
98-
pytest test/unit/
41+
run-test:
42+
permissions:
43+
contents: read
44+
id-token: write
45+
needs: verify-input
46+
uses: ./.github/workflows/python-package.yml
9947

10048
draft-release:
101-
needs: build
49+
needs: run-test
10250
runs-on: ubuntu-latest
51+
permissions:
52+
contents: write
53+
environment: release
10354
steps:
104-
- uses: actions/checkout@v4
55+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
10556
- name: Draft release v${{ inputs.version }}
10657
env:
10758
GH_TOKEN: ${{ github.token }}
@@ -113,5 +64,4 @@ jobs:
11364
--target "$GITHUB_SHA"
11465
11566
echo "Drafted release v$VERSION"
116-
gh release view "v$VERSION" --json url -q .url
11767

.github/workflows/python-package.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
branches: [master]
99
pull_request:
1010
branches: [master]
11+
workflow_call:
1112

1213
permissions:
1314
contents: read
@@ -22,9 +23,9 @@ jobs:
2223
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2324

2425
steps:
25-
- uses: actions/checkout@v4
26+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262
2627
- name: Set up Python ${{ matrix.python-version }}
27-
uses: actions/setup-python@v5
28+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
2829
with:
2930
python-version: ${{ matrix.python-version }}
3031
- name: Install dependencies
@@ -41,14 +42,14 @@ jobs:
4142
- name: Lint with PyLint
4243
run: pylint --rcfile=.pylintrc src/aws_secretsmanager_caching
4344
- name: Check formatting with Ruff
44-
uses: astral-sh/ruff-action@v3
45+
uses: astral-sh/ruff-action@4919ec5cf1f49eff0871dbcea0da843445b837e6
4546
with:
4647
version: "0.15.22"
4748
- name: Test with pytest
4849
run: |
4950
pytest test/unit/
5051
- name: Upload coverage to Codecov
51-
uses: codecov/codecov-action@v5
52+
uses: codecov/codecov-action@0fb7174895f61a3b6b78fc075e0cd60383518dac
5253
with:
53-
fail_ci_if_error: true
54+
fail_ci_if_error: false # REMEMBER TO FIX (SET LIKE THIS FOR TESTING)
5455
use_oidc: true

0 commit comments

Comments
 (0)