Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Commit fefc22c

Browse files
committed
chore: Add buildspecs for release orchestration
1 parent 24d30f2 commit fefc22c

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

buildspec.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ phases:
44
install:
55
runtime-versions:
66
golang: 1.13
7+
78
build:
89
commands:
10+
# Run tests
911
- make install-tools
1012
- make
1113
- make integration-test

buildspec_push_release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
runtime-versions:
6+
ruby: 2.6
7+
commands:
8+
# TODO: Upgrade to final v2 dpl production version
9+
# https://github.com/travis-ci/dpl/tree/v2.0.0.alpha.2#github-releases
10+
- "gem install dpl:'<2.0.0'"
11+
- git config credential.helper "store --file=.git/credentials"
12+
- echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials
13+
14+
build:
15+
commands:
16+
# Push changelog update and new version tag
17+
- export NEW_VERSION=`cat VERSION`
18+
- export GIT_COMMIT_ID=`git rev-parse HEAD`
19+
- git push origin HEAD:mainline
20+
- git push origin v$NEW_VERSION
21+
22+
# Determine the artifacts to publish
23+
- echo 'Artifacts to publish to the release target:'
24+
- cat ./$GIT_COMMIT_ID.manifest
25+
- export DPL_FILE_FLAGS=""
26+
- |-
27+
for artifact in `cat ./$GIT_COMMIT_ID.manifest`
28+
do
29+
export DPL_FILE_FLAGS="$DPL_FILE_FLAGS --file=$artifact --file=$artifact.md5 --file=$artifact.sha256"
30+
done
31+
- echo $DPL_FILE_FLAGS
32+
33+
# Create a GitHub release for the new version
34+
- dpl --provider=releases --skip-cleanup --api_key=$GITHUB_TOKEN --target_commitish=$GIT_COMMIT_ID --name='img2lambda v$NEW_VERSION' --repo=awslabs/aws-lambda-container-image-converter $DPL_FILE_FLAGS
35+
finally:
36+
- rm -f .git/credentials

buildspec_stage_release.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
version: 0.2
2+
3+
phases:
4+
install:
5+
runtime-versions:
6+
golang: 1.13
7+
nodejs: 10
8+
commands:
9+
- npm install -g standard-version@^7.0.0
10+
- git config user.name "Release Automation"
11+
- git config user.email $COMMIT_EMAIL_ADDRESS
12+
13+
build:
14+
commands:
15+
# Prevent generating a new release if there are no new commits
16+
- export CURRENT_VERSION=`cat VERSION`
17+
- export COMMITS_TO_RELEASE=`git log --pretty=oneline v$CURRENT_VERSION..HEAD | wc -l`
18+
- |-
19+
if [ $COMMITS_TO_RELEASE -eq 0 ]
20+
then
21+
echo No changes to release!
22+
echo Current release: $CURRENT_VERSION
23+
exit 1
24+
fi
25+
26+
# Generate a new version number, changelog entry, and version tag, based on conventional commits since the last release
27+
- standard-version
28+
29+
# Print information about the release for review. Prevent major version bumps (these warrant extra scrutiny)
30+
- export NEW_VERSION=`cat VERSION`
31+
- export GIT_COMMIT_ID=`git rev-parse HEAD`
32+
- echo "Commit ID to release: $GIT_COMMIT_ID"
33+
- |-
34+
if echo "$NEW_VERSION" | grep -q "^1\."
35+
then
36+
echo New version: v$NEW_VERSION
37+
echo Previous version: v$CURRENT_VERSION
38+
echo Changes to release:
39+
git log --pretty=oneline v$CURRENT_VERSION..v$NEW_VERSION
40+
else
41+
echo Uh oh, new major version! v$NEW_VERSION
42+
exit 1
43+
fi
44+
45+
# Build release binaries
46+
- make stage-release-binaries
47+
- echo "Built artifacts:"
48+
- ls -lah ./bin/release-$NEW_VERSION
49+
- ./bin/release-$NEW_VERSION/linux-amd64-img2lambda --version
50+
51+
# Generate release manifest
52+
- export MANIFESTFILE="$GIT_COMMIT_ID.manifest"
53+
- echo bin/release-$NEW_VERSION/linux-amd64-img2lambda >> $MANIFESTFILE
54+
- echo bin/release-$NEW_VERSION/darwin-amd64-img2lambda >> $MANIFESTFILE
55+
- echo bin/release-$NEW_VERSION/windows-amd64-img2lambda.exe >> $MANIFESTFILE
56+
57+
artifacts:
58+
files:
59+
- '**/*'

0 commit comments

Comments
 (0)