Skip to content

Commit ee27f2f

Browse files
committed
adds automated versioning of SAR app
1 parent ad151d9 commit ee27f2f

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
packaged.yaml
22
.DS_Store
3+
samconfig.toml
4+
packaged*.yaml

build/transform.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import yaml, sys
2+
from os import path
3+
4+
5+
def main(template, package, build_no, commit):
6+
7+
# read template file
8+
with open(template) as input_file:
9+
template_doc = yaml.safe_load(input_file)
10+
11+
12+
print(template_doc)
13+
14+
# read package file
15+
with open(package) as package_file:
16+
package_doc = yaml.safe_load(package_file)
17+
18+
commit_short = commit[:6]
19+
sem_ver = ("%s+%s.%s" % (package_doc["version"], build_no, commit_short))
20+
21+
template_doc["Metadata"] = {
22+
"AWS::ServerlessRepo::Application": {
23+
"Name": package_doc["name"],
24+
"Description": package_doc["description"],
25+
"Author": package_doc["author"]["name"],
26+
"SpdxLicenseId": package_doc["license"],
27+
"HomePageUrl": package_doc["homepage"],
28+
"SourceCodeUrl": ("%s/tree/%s" % (package_doc["homepage"], commit_short)),
29+
"SemanticVersion": sem_ver
30+
}
31+
}
32+
33+
with open(path.join(path.dirname(input_file.name), 'packaged-versioned.yaml'), 'w') as output_file:
34+
yaml.dump(template_doc, output_file, sort_keys=False)
35+
36+
if __name__ == "__main__":
37+
template = sys.argv[1]
38+
package = sys.argv[2]
39+
build_no = sys.argv[3]
40+
commit = sys.argv[4]
41+
main(template, package, build_no, commit)

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "amazon-cloudfront-access-logs-queries",
3+
"version": "1.1.0",
4+
"description": "This is a sample implementation for the concepts described in the AWS blog post \"Analyzing your Amazon CloudFront access logs at scale\".",
5+
"author": {
6+
"name": "Steffen Grunwald"
7+
},
8+
"license": "MIT-0",
9+
"homepage": "https://github.com/aws-samples/amazon-cloudfront-access-logs-queries"
10+
}

0 commit comments

Comments
 (0)