Skip to content

Commit 3c50448

Browse files
authored
Merge pull request #37 from salesforce/add/publish-automation
Add publishing automation; support Python 3.8
2 parents 73ac7de + 75d5bb6 commit 3c50448

23 files changed

+115
-23
lines changed

.github/workflows/ci.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ on: [push, pull_request]
55
jobs:
66
ci:
77
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ['3.7', '3.8', '3.9']
811
steps:
912
- uses: actions/checkout@v2
1013

1114
- name: Setup Python
12-
uses: actions/setup-python@v1
15+
uses: actions/setup-python@v2
1316
with:
14-
python-version: 3.9
17+
python-version: ${{ matrix.python-version }}
1518

1619
- name: Install dependencies
1720
run: |

.github/workflows/publish.yml

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [ published ]
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ['3.7', '3.8', '3.9']
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Setup Python
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: ${{ matrix.python-version }}
20+
21+
- name: Install dependencies
22+
run: |
23+
make setup-dev
24+
25+
- name: Run pytest (unit tests) and bandit (security test)
26+
run: |
27+
make test
28+
29+
- name: Install the package to make sure nothing is randomly broken
30+
run: |
31+
make install
32+
33+
publish-package:
34+
needs: test
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@master
38+
- name: Set up Python 3.7
39+
uses: actions/setup-python@v2
40+
with:
41+
python-version: 3.7
42+
43+
44+
- name: Install dependencies
45+
run: |
46+
pip install -r requirements.txt
47+
pip install -r requirements-dev.txt
48+
- name: create python package
49+
run: |
50+
git config --local user.email "[email protected]"
51+
git config --local user.name "GitHub Action"
52+
git fetch --tags
53+
git pull origin main
54+
pip install setuptools wheel twine
55+
python -m setup sdist bdist_wheel
56+
- name: Publish package
57+
uses: pypa/gh-action-pypi-publish@master
58+
with:
59+
user: __token__
60+
password: ${{ secrets.PYPI_PASSWORD }}
61+
62+
63+
update-brew:
64+
needs: publish-package
65+
runs-on: ubuntu-latest
66+
steps:
67+
- uses: actions/checkout@master
68+
- name: Set up Python 3.7
69+
uses: actions/setup-python@v2
70+
with:
71+
python-version: 3.7
72+
- name: publish brew
73+
run: |
74+
sleep 5m
75+
git config --local user.email "[email protected]"
76+
git config --local user.name "GitHub Action"
77+
pip install homebrew-pypi-poet
78+
pip install endgame -U
79+
git fetch origin
80+
git checkout --track origin/main
81+
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`)
82+
echo "latest tag: $latest_tag"
83+
git pull origin $latest_tag
84+
mkdir -p "HomebrewFormula" && touch "HomebrewFormula/endgame.rb"
85+
poet -f endgame > HomebrewFormula/endgame.rb
86+
git add .
87+
git commit -m "update brew formula" endgame/bin/cli.py HomebrewFormula/endgame.rb || echo "No brew changes to commit"
88+
git push -u origin main

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ packer_cache/
6767

6868
#### Repository specific
6969
.notes/*
70-
**/private.tf
70+
**/private.tf
71+
.python-version

endgame/bin/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.1"
1+
__version__ = "0.1.2"

endgame/command/list_resources.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def get_all_resources_for_all_services(profile: str, region: str, current_accoun
122122

123123

124124
def get_all_resources(translated_service: str, profile: str, provided_service: str, region: str,
125-
current_account_id: str, cloak: bool = False) -> list[ListResourcesResponse]:
125+
current_account_id: str, cloak: bool = False) -> [ListResourcesResponse]:
126126
"""Get resource objects for every resource under an AWS service"""
127127
results = []
128128
client = get_boto3_client(profile=profile, service=translated_service, region=region, cloak=cloak)

endgame/exposure_via_resource_policies/acm_pca.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
180180
self.resource_type = "certificate-authority"
181181

182182
@property
183-
def resources(self) -> list[ListResourcesResponse]:
183+
def resources(self) -> [ListResourcesResponse]:
184184
"""Get a list of these resources"""
185185
resources = []
186186

endgame/exposure_via_resource_policies/cloudwatch_logs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
173173
self.resource_type = "resource-policy"
174174

175175
@property
176-
def resources(self) -> list[ListResourcesResponse]:
176+
def resources(self) -> [ListResourcesResponse]:
177177
"""Get a list of these resources"""
178178
resources = []
179179

endgame/exposure_via_resource_policies/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,5 @@ def __str__(self):
134134

135135
@property
136136
@abstractmethod
137-
def resources(self) -> list[ListResourcesResponse]:
137+
def resources(self) -> [ListResourcesResponse]:
138138
raise NotImplementedError("Must override property 'resources'")

endgame/exposure_via_resource_policies/ecr.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
8383
self.resource_type = "repository"
8484

8585
@property
86-
def resources(self) -> list[ListResourcesResponse]:
86+
def resources(self) -> [ListResourcesResponse]:
8787
"""Get a list of these resources"""
8888
resources = []
8989

endgame/exposure_via_resource_policies/efs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
8181
self.resource_type = "file-system"
8282

8383
@property
84-
def resources(self) -> list[ListResourcesResponse]:
84+
def resources(self) -> [ListResourcesResponse]:
8585
"""Get a list of these resources"""
8686
resources = []
8787

endgame/exposure_via_resource_policies/elasticsearch.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
8181
self.resource_type = "domain"
8282

8383
@property
84-
def resources(self) -> list[ListResourcesResponse]:
84+
def resources(self) -> [ListResourcesResponse]:
8585
"""Get a list of these resources"""
8686
resources = []
8787

endgame/exposure_via_resource_policies/glacier_vault.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
8080
self.resource_type = "vaults"
8181

8282
@property
83-
def resources(self) -> list[ListResourcesResponse]:
83+
def resources(self) -> [ListResourcesResponse]:
8484
"""Get a list of these resources"""
8585
resources = []
8686

endgame/exposure_via_resource_policies/iam.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
8484
self.resource_type = "role"
8585

8686
@property
87-
def resources(self) -> list[ListResourcesResponse]:
87+
def resources(self) -> [ListResourcesResponse]:
8888
"""Get a list of these resources"""
8989
resources = []
9090

endgame/exposure_via_resource_policies/kms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
9797
self.current_account_id = current_account_id
9898

9999
@property
100-
def resources(self) -> list[ListResourcesResponse]:
100+
def resources(self) -> [ListResourcesResponse]:
101101
"""Get a list of these resources"""
102102

103103
# https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/kms.html#KMS.Paginator.ListKeys

endgame/exposure_via_resource_policies/lambda_function.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
132132
self.resource_type = "function"
133133

134134
@property
135-
def resources(self) -> list[ListResourcesResponse]:
135+
def resources(self) -> [ListResourcesResponse]:
136136
"""Get a list of these resources"""
137137
resources = []
138138

endgame/exposure_via_resource_policies/lambda_layer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def layer_version_arns(self, layer_name):
177177
return resources
178178

179179
@property
180-
def resources(self) -> list[ListResourcesResponse]:
180+
def resources(self) -> [ListResourcesResponse]:
181181
"""Get a list of these resources"""
182182
resources = []
183183

endgame/exposure_via_resource_policies/s3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
8484
self.resource_type = "bucket"
8585

8686
@property
87-
def resources(self) -> list[ListResourcesResponse]:
87+
def resources(self) -> [ListResourcesResponse]:
8888
"""Get a list of these resources"""
8989
response = self.client.list_buckets()
9090
resources = []

endgame/exposure_via_resource_policies/secrets_manager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
7676
self.resource_type = "secret"
7777

7878
@property
79-
def resources(self) -> list[ListResourcesResponse]:
79+
def resources(self) -> [ListResourcesResponse]:
8080
"""Get a list of these resources"""
8181
resources = []
8282

endgame/exposure_via_resource_policies/ses.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
132132
self.resource_type = "identity"
133133

134134
@property
135-
def resources(self) -> list[ListResourcesResponse]:
135+
def resources(self) -> [ListResourcesResponse]:
136136
"""Get a list of these resources"""
137137
resources = []
138138

endgame/exposure_via_resource_policies/sns.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
174174
self.resource_type = "topic"
175175

176176
@property
177-
def resources(self) -> list[ListResourcesResponse]:
177+
def resources(self) -> [ListResourcesResponse]:
178178
"""Get a list of these resources"""
179179
these_resources = []
180180

endgame/exposure_via_resource_policies/sqs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def __init__(self, client: boto3.Session.client, current_account_id: str, region
164164
self.resource_type = "queue"
165165

166166
@property
167-
def resources(self) -> list[ListResourcesResponse]:
167+
def resources(self) -> [ListResourcesResponse]:
168168
"""Get a list of these resources"""
169169
resources = []
170170

endgame/shared/policy_document.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __str__(self):
3535
def __repr__(self):
3636
return json.dumps(self.json)
3737

38-
def _statements(self, statement_structure) -> list[StatementDetail]:
38+
def _statements(self, statement_structure) -> [StatementDetail]:
3939
# Statement can be a list or a string, but we prefer strings for uniformity
4040
if not isinstance(statement_structure, list):
4141
statement_structure = [statement_structure] # pragma: no cover

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ def get_description():
4646
entry_points={"console_scripts": "endgame=endgame.bin.cli:main"},
4747
zip_safe=True,
4848
keywords="aws iam security",
49-
python_requires=">=3.9",
49+
python_requires=">=3.7",
5050
)

0 commit comments

Comments
 (0)