Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: add release automation files #119

Merged
merged 199 commits into from
May 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
199 commits
Select commit Hold shift + click to select a range
0ce6f64
doc: restructure
Shabirmean May 5, 2022
9219322
doc: fix region tag
Shabirmean May 5, 2022
04d2a36
doc: fix region tags
Shabirmean May 5, 2022
98d47b4
cleanup: update the skaffold file
Shabirmean May 5, 2022
57156a7
cleanup: add project suffix to the pom
Shabirmean May 5, 2022
043aa08
cleanup: fix path error in cloudbuild yaml
Shabirmean May 5, 2022
4749277
fix: update the cloudbuild yamls
Shabirmean May 5, 2022
de087f7
cleanup: add the mvnwrapper
Shabirmean May 5, 2022
8ad84d8
lint: add correct license year
Shabirmean May 5, 2022
fc20d43
fix: update the header
Shabirmean May 5, 2022
be14d10
fix: clpoudbuil yaml
Shabirmean May 5, 2022
fca0867
ci: add dir for deploy step
Shabirmean May 5, 2022
88a4f84
ci: revert cloudbuild changes
Shabirmean May 5, 2022
d455ae0
cleanup: maintain point-of-sale-app folder as is in main
Shabirmean May 6, 2022
5a3bee9
header: fix year
Shabirmean May 6, 2022
c7fbcfc
cleanup: remove and add
Shabirmean May 6, 2022
69e9771
fix: header check error
Shabirmean May 6, 2022
b67499e
test: find directory
Shabirmean May 6, 2022
53ea578
test: find directory
Shabirmean May 6, 2022
a12f98f
test: find directory
Shabirmean May 6, 2022
0ffaa1b
cleanup: move maven wrapper to the root
Shabirmean May 6, 2022
2cf31ef
cleanup: add relativePath to parent pom
Shabirmean May 6, 2022
17d7737
cleanup: update the push to main yaml
Shabirmean May 6, 2022
125e792
Merge branch 'restructure1' into restructure2
Shabirmean May 6, 2022
b1703a1
fix: the path issue in the apiserver pom
Shabirmean May 6, 2022
174d32d
Merge branch 'v2-sql' into restructure2
Shabirmean May 6, 2022
6f05b9c
release: add initial releaser code
Shabirmean May 6, 2022
462aa8d
release: fix str error
Shabirmean May 6, 2022
3b087ae
cleanup: get xml parser working
Shabirmean May 6, 2022
743019a
cleanuP: fix pom linting
Shabirmean May 6, 2022
0df552b
cleanup: add extra linebreak
Shabirmean May 6, 2022
7d28575
Merge branch 'v2-sql' into restructure1
Shabirmean May 6, 2022
5a63b46
fix: merge conflict
Shabirmean May 6, 2022
b405ded
Merge branch 'restructure1' into restructure3
Shabirmean May 6, 2022
514d306
cleanup: linting in ui pom
Shabirmean May 6, 2022
cdba0ba
improvement: add logic to update package.json
Shabirmean May 6, 2022
3bdc013
lint: reformat the pom
Shabirmean May 6, 2022
1a7f75f
lint: remove extra space
Shabirmean May 6, 2022
8f3fae2
chore(release): 0.1.0-SNAPSHOT
Shabirmean May 6, 2022
843fa58
Revert "chore(release): 0.1.0-SNAPSHOT"
Shabirmean May 6, 2022
fdb238f
chore(release): 0.1.0-SNAPSHOT
Shabirmean May 6, 2022
ed14000
Revert "chore(release): 0.1.0-SNAPSHOT"
Shabirmean May 6, 2022
4d7627a
cleanup: add changlog packagejson
Shabirmean May 7, 2022
91389ee
fix: add code to update release pkg json
Shabirmean May 7, 2022
171c174
fix: indent on pkf json
Shabirmean May 7, 2022
f4b011c
fix: indent on pkf json
Shabirmean May 7, 2022
1e21372
process: add release trigger
Shabirmean May 7, 2022
fb00f69
fix: escape env subs
Shabirmean May 7, 2022
41d3c36
chore: add branch name
Shabirmean May 7, 2022
9f2c635
chore: add pip install step
Shabirmean May 7, 2022
fec6bcf
chore: add git branch
Shabirmean May 7, 2022
263c495
chore: add remote
Shabirmean May 7, 2022
dec111c
test: show remote
Shabirmean May 7, 2022
f692b04
test: show remote
Shabirmean May 7, 2022
8542ea0
test: show remote
Shabirmean May 7, 2022
a3d6a8c
test: show remote
Shabirmean May 7, 2022
92ed687
test: show remote
Shabirmean May 7, 2022
e32dc05
test: show remote
Shabirmean May 7, 2022
00e36d9
release: update version before release
Shabirmean May 7, 2022
214bb2a
Revert "release: update version before release"
Shabirmean May 7, 2022
703de96
cleanup: remove username from git
Shabirmean May 7, 2022
0860659
test: show remote
Shabirmean May 7, 2022
d481879
test: set branch
Shabirmean May 7, 2022
6f23639
test: set branch
Shabirmean May 7, 2022
f2bc291
test: set branch
Shabirmean May 7, 2022
b3cf2ed
test: set branch
Shabirmean May 7, 2022
a9d87ae
test: set branch
Shabirmean May 7, 2022
a198c30
test: set branch
Shabirmean May 7, 2022
db838c5
release: update version before release
Shabirmean May 7, 2022
5722656
Revert "release: update version before release"
Shabirmean May 7, 2022
2cf05bd
test: set branch
Shabirmean May 7, 2022
c6590f6
release: update version before release
Shabirmean May 7, 2022
7775bb3
cleanup: add clarifying comment
Shabirmean May 7, 2022
b216a21
Merge branch 'restructure3' of https://github.com/GoogleCloudPlatform…
Shabirmean May 7, 2022
8b16346
Revert "release: update version before release"
Shabirmean May 7, 2022
b04b94a
chore: set github email secret
Shabirmean May 7, 2022
f2649c4
release: update version before release
Shabirmean May 7, 2022
347f67f
Revert "release: update version before release"
Shabirmean May 7, 2022
ff14e7f
release: update version before release
Shabirmean May 7, 2022
369b714
chore: add publish yaml
Shabirmean May 7, 2022
34ffa2e
Merge branch 'restructure3' of https://github.com/GoogleCloudPlatform…
Shabirmean May 7, 2022
49e68f6
Revert "release: update version before release"
Shabirmean May 7, 2022
110a1bc
release: update version before release
Shabirmean May 7, 2022
8c190eb
Revert "release: update version before release"
Shabirmean May 7, 2022
bb498da
chore: add build step for deploying images
Shabirmean May 7, 2022
50d2114
chore: add python step to publish yaml
Shabirmean May 7, 2022
c076a4b
chore: update releaser to print version
Shabirmean May 7, 2022
ad1aaf5
chore: rearrange code
Shabirmean May 7, 2022
550eb9c
release: update version before release
Shabirmean May 7, 2022
8ed044a
chore: fix version error
Shabirmean May 7, 2022
fdd71aa
Merge branch 'restructure3' of https://github.com/GoogleCloudPlatform…
Shabirmean May 7, 2022
6ac652f
Revert "release: update version before release"
Shabirmean May 7, 2022
65bd83f
release: update version before release
Shabirmean May 7, 2022
721673b
Revert "release: update version before release"
Shabirmean May 7, 2022
299a413
chore: fix substution variable
Shabirmean May 7, 2022
3fe4f54
release: update version before release
Shabirmean May 7, 2022
7f933cb
Revert "release: update version before release"
Shabirmean May 9, 2022
8ed9dc8
chore: fix the version and deps
Shabirmean May 9, 2022
ec7b888
release: update version before release
Shabirmean May 9, 2022
5d54689
Revert "release: update version before release"
Shabirmean May 9, 2022
2903135
chore: fix the version and deps
Shabirmean May 9, 2022
abbdbd4
release: update version before release
Shabirmean May 9, 2022
5f517d0
Revert "release: update version before release"
Shabirmean May 9, 2022
aead726
chore: fix the version and deps
Shabirmean May 9, 2022
ececb4d
release: update version before release
Shabirmean May 9, 2022
cc39916
Revert "release: update version before release"
Shabirmean May 9, 2022
54e904b
chore: fix the version and deps
Shabirmean May 9, 2022
4208bd6
release: update version before release
Shabirmean May 9, 2022
3f41935
Revert "release: update version before release"
Shabirmean May 9, 2022
1cda3ad
chore: fix the version and deps
Shabirmean May 9, 2022
9642318
release: update version before release
Shabirmean May 9, 2022
ac001ef
Revert "release: update version before release"
Shabirmean May 9, 2022
73463b2
chore: fix the version and deps
Shabirmean May 9, 2022
9aebc49
release: update version before release
Shabirmean May 9, 2022
172a4fc
Revert "release: update version before release"
Shabirmean May 9, 2022
6986454
chore: fix the version and deps
Shabirmean May 9, 2022
0039752
release: update version before release
Shabirmean May 9, 2022
3a2a760
Revert "release: update version before release"
Shabirmean May 9, 2022
02145a5
cleanup: rearrange yamls
Shabirmean May 9, 2022
fcbfc01
improv: add yaml update logic
Shabirmean May 9, 2022
dbcbac0
chore: add logic to update all yamls
Shabirmean May 9, 2022
5e20bcb
chore: add new lines
Shabirmean May 9, 2022
3577cd8
chore: reorder the updates
Shabirmean May 9, 2022
2318356
release: update version before release
Shabirmean May 9, 2022
e190173
chore: updated release script
Shabirmean May 9, 2022
02c4300
chore: uncomment the file edit
Shabirmean May 9, 2022
8481826
chore: rearrange the prints
Shabirmean May 9, 2022
d624a82
chore: add new argument
Shabirmean May 9, 2022
4f53672
chore: update the releaser to take patch as the next release version
Shabirmean May 9, 2022
983488f
chore: add logic to set SNAPSHOT version
Shabirmean May 9, 2022
1f89701
chore: fix incorrect variable bug
Shabirmean May 9, 2022
024c302
chore: fix releaser release versioning
Shabirmean May 9, 2022
463b7ba
chore: update release yaml files
Shabirmean May 9, 2022
75791dc
chore: complete the release yamls
Shabirmean May 9, 2022
6109fb1
Merge branch 'restructure3' of https://github.com/GoogleCloudPlatform…
Shabirmean May 9, 2022
bfc17d0
chore: save merge conflict resolution
Shabirmean May 9, 2022
4ff59b4
chore: set root pom to SNAPSHOT
Shabirmean May 9, 2022
924e2a3
chore: fix bash error
Shabirmean May 9, 2022
7d5aad9
release: update version before release
Shabirmean May 9, 2022
1f42ce0
chore: update commit msg checks
Shabirmean May 9, 2022
aa2c1f9
chore: add formatting
Shabirmean May 9, 2022
2578ef8
Revert "release: update version before release"
Shabirmean May 9, 2022
6060176
release: update version before release
Shabirmean May 9, 2022
326ed4f
chore: fix versions
Shabirmean May 9, 2022
e950c9f
Merge branch 'restructure3' of https://github.com/GoogleCloudPlatform…
Shabirmean May 9, 2022
d9aa2a4
chore: fix commit message
Shabirmean May 9, 2022
20f362a
release: update version before release
Shabirmean May 9, 2022
a8d65f9
chore: fix formatting
Shabirmean May 9, 2022
e47ed2f
Merge branch 'restructure3' of https://github.com/GoogleCloudPlatform…
Shabirmean May 9, 2022
60cdd21
Revert "release: update version before release"
Shabirmean May 9, 2022
f60edcb
chore: add email token to build file
Shabirmean May 9, 2022
ee086cc
release: update version before release
Shabirmean May 9, 2022
fdf2c83
Revert "release: update version before release"
Shabirmean May 9, 2022
0ed9c17
chore add deploy script
Shabirmean May 9, 2022
0fcd324
chore: fix branch error
Shabirmean May 9, 2022
4473cb5
release: update version before release
Shabirmean May 9, 2022
b52cb58
release: update version before release
Shabirmean May 9, 2022
67f7c64
Merge branch 'restructure3' of https://github.com/GoogleCloudPlatform…
Shabirmean May 9, 2022
a437020
release: update version before release
Shabirmean May 9, 2022
a88198e
Revert "release: update version before release"
Shabirmean May 9, 2022
aa75570
chore: fix version.txt error
Shabirmean May 9, 2022
c6e699e
chore: fix deploy ci
Shabirmean May 9, 2022
801b623
chore: update print message
Shabirmean May 9, 2022
46d5fbd
chore: enhance comment message
Shabirmean May 9, 2022
0b82562
chore(release): 0.1.0
Shabirmean May 9, 2022
91df771
chore(release): 0.1.1
Shabirmean May 9, 2022
c8dd2b3
chore: fix comment msg
Shabirmean May 9, 2022
da904cb
chore: remove mvn install
Shabirmean May 9, 2022
9a4ba70
chore: reorganize the deploy yaml
Shabirmean May 9, 2022
864fbfa
chore: add gh release step
Shabirmean May 9, 2022
69d6629
Merge branch 'v2-sql' into restructure3
Shabirmean May 9, 2022
1cb0874
chore: rename common service fiel names
Shabirmean May 9, 2022
863f4e1
chore: update the skaffold file to have services
Shabirmean May 9, 2022
e33eb81
chore: fix region tag
Shabirmean May 9, 2022
8db90fa
chore: force
Shabirmean May 9, 2022
724da80
chore: fix bash err
Shabirmean May 9, 2022
e57bfdf
release: update version before release
Shabirmean May 9, 2022
7f54c9a
release: bump version to next snapshot
Shabirmean May 9, 2022
af71f31
chore: update release messafe
Shabirmean May 10, 2022
0de9712
Merge branch 'restructure3' of https://github.com/GoogleCloudPlatform…
Shabirmean May 10, 2022
60bfee5
Revert "release: bump version to next snapshot"
Shabirmean May 10, 2022
362b6ba
Revert "release: update version before release"
Shabirmean May 10, 2022
2792141
chore: add readme for release
Shabirmean May 10, 2022
ba14047
doc: improve release doc
Shabirmean May 10, 2022
f1e7ed8
doc: add more release steps
Shabirmean May 10, 2022
98d90e5
doc: add more release steps
Shabirmean May 10, 2022
c6a45c4
doc: add more release steps
Shabirmean May 10, 2022
5c3adea
doc: add more release steps
Shabirmean May 10, 2022
c89ca82
doc: add more release steps
Shabirmean May 10, 2022
3312a5e
doc: add more release steps
Shabirmean May 10, 2022
7e336f4
doc: add more release steps
Shabirmean May 10, 2022
5b81e4c
chore: remove branch ref
Shabirmean May 10, 2022
744dd3f
chore: update the README
Shabirmean May 10, 2022
330f7f1
chore: rename relese yaml
Shabirmean May 10, 2022
b1fc892
doc: add release link to the main README
Shabirmean May 10, 2022
cdc4588
doc: update doc size
Shabirmean May 10, 2022
a2ee7a9
doc: add note to click to enlarge
Shabirmean May 10, 2022
b7af7f5
doc: note about Googler release
Shabirmean May 10, 2022
61895d4
doc: fix hyperlonk
Shabirmean May 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
156 changes: 156 additions & 0 deletions .github/cloudbuild/pos-check-for-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

###########################################################
# This is a GCP CloudBuild Trigger config file. The trigger
# is for when a PR is open from a branch named release-x.
# x can be major, minor, or patch.
###########################################################

steps:
###########################################################
# Gating step to ensure we run it only once
###########################################################
- id: 'gate-ci'
name: 'python'
entrypoint: bash
args:
- -c
- |
touch /workspace/release.done
COMMIT_MSG=$(git log -1 --oneline --format=%s | sed 's/^.*: //')
if [[ $$COMMIT_MSG == 'update version before release' ]] || [[ $$COMMIT_MSG == 'bump version to next snapshot' ]]; then
echo "Commit message [$$COMMIT_MSG] indicates release version already being updated. Skip steps."
echo "RELEASE_COMPLETE" > /workspace/release.done
fi
# indicates that the step need not wait for any other step
waitFor: [ '-' ]

###########################################################
# Version bump on release PR
###########################################################
- id: 'bump-version'
name: 'python'
entrypoint: bash
args:
- -c
- |
STATUS=$(cat /workspace/release.done)
if [[ $$STATUS == 'RELEASE_COMPLETE' ]]; then
exit 0
fi

pip install -r .github/releases/requirements.txt
echo "PR openned on branch [$_HEAD_BRANCH] for pr-$_PR_NUMBER"
if [[ $_HEAD_BRANCH == 'release-minor' ]]; then
echo "Updating versions for a minor release"
python3 .github/releases/releaser.py -t minor

elif [[ $_HEAD_BRANCH == 'release-patch' ]]; then
echo "Updating versions for a patch release"
python3 .github/releases/releaser.py -t patch

elif [[ $_HEAD_BRANCH == 'release-major' ]]; then
echo "Updating versions for a major release"
python3 .github/releases/releaser.py -t major

else
echo "Nothing to do since it's not a 'release' PR"
echo "RELEASE_COMPLETE" > /workspace/release.done
fi

VERSION=$(python3 .github/releases/releaser.py -p true)
echo "$$VERSION" > release-version.txt
# indicates that the step need not wait for any other step
waitFor: [ 'gate-ci' ]

###########################################################
# Push the version changes to the repo
###########################################################
- id: 'push-changes-to-repo'
name: 'gcr.io/cloud-builders/git'
secretEnv: [ 'GITHUB_TOKEN', 'GITHUB_EMAIL' ]
entrypoint: bash
args:
- -c
- |
STATUS=$(cat /workspace/release.done)
if [[ $$STATUS == 'RELEASE_COMPLETE' ]]; then
exit 0
fi

# we do this so that the deploy triggers can know the PR number
echo "$_PR_NUMBER" > release-pr.number

git config user.email "$$GITHUB_EMAIL"
xtineskim marked this conversation as resolved.
Show resolved Hide resolved
git config user.name "Anthos DPE"

# as per: https://stackoverflow.com/a/67886960/3396045
git remote set-branches --add origin $_HEAD_BRANCH
git fetch 'origin'
git checkout --track origin/$_HEAD_BRANCH

git add -A
git commit -m "release: update version before release"
git push -u https://$$GITHUB_TOKEN@github.com/GoogleCloudPlatform/point-of-sale.git $_HEAD_BRANCH
waitFor: [ 'bump-version' ]

###########################################################
# Comment about the release status on the release PR
###########################################################
- id: 'comment-release-status-to-github'
name: 'us-docker.pkg.dev/point-of-sale-ci/third-party-images/github-cli:mar-22'
secretEnv: [ 'GITHUB_TOKEN' ]
entrypoint: bash
args:
- -c
- |
STATUS=$(cat /workspace/release.done)
if [[ $$STATUS == 'RELEASE_COMPLETE' ]]; then
exit 0
fi

COMMIT_MSG=$(git log -1 --oneline --format=%s | sed 's/^.*: //')
if [[ $$COMMIT_MSG != 'update version before release' ]]; then
echo "Commit message [$$COMMIT_MSG] is not a release commit. Skipping step."
exit 0
fi

RELEASE_TYPE='patch'
if [[ $_HEAD_BRANCH == 'release-minor' ]]; then
RELEASE_TYPE='minor'
elif [[ $_HEAD_BRANCH == 'release-major' ]]; then
RELEASE_TYPE='major'
fi

LAST_COMMIT=$(cat .git/refs/heads/$_HEAD_BRANCH)
cat <<EOF > /workspace/gh-comment.txt -
:zap: Release Status :zap: </br>
- **Version updated**: Version in the `pom.xml/package.json` has been updated to the next **$$RELEASE_TYPE** release version.
- **Publish Artifacts:** Check the most recent commit ($$LAST_COMMIT) for correctness and run the ["pos-publish-release-artifacts"](https://console.cloud.google.com/cloud-build/triggers;region=global?project=point-of-sale-ci) trigger against this branch **[$BRANCH_NAME]** to upload the artifacts _(Jars and Images)_ to Artifact registry.
EOF
gh pr comment $_PR_NUMBER --repo $_HEAD_REPO_URL --body-file /workspace/gh-comment.txt
# waitFor: commented out, so this step waits for all previous steps

availableSecrets:
inline:
- kmsKeyName: 'projects/$PROJECT_ID/locations/global/keyRings/$_GHTOKEN_KEYRING_NAME/cryptoKeys/$_GHTOKEN_KEY_NAME'
envMap:
GITHUB_TOKEN: 'CiQAuVI6Z93rj1B1R4yer3G1VzEmW7aHtjATP2jOtyJjkW5qOR8SUQBHWet7zXRDJQTBSvFZuXXsOBIxtvf0VDM610Tjgb5XJY8hbIuBxhsMfDy3+/p2ojVnYmE+Mg9NDg5FGZhlJlB/+PBMCumkbMovTXD582u17A=='
xtineskim marked this conversation as resolved.
Show resolved Hide resolved
- kmsKeyName: 'projects/$PROJECT_ID/locations/global/keyRings/$_GHEMAIL_KEYRING_NAME/cryptoKeys/$_GHEMAIL_KEY_NAME'
envMap:
GITHUB_EMAIL: 'CiQA/ThyQ4p/sDUR2fsc4Q2GgF/PntA048keplEhVQTrmgESLfcSOACXDXFpPP/ASB9nwBao91OK4677dEaGsJQjVKkStDpHtY1ZtF7qefjxq1qK93BSezLllJX/rHbY'
logsBucket: 'gs://pos-cloudbuild-logs'
options:
logging: GCS_ONLY
45 changes: 45 additions & 0 deletions .github/cloudbuild/pos-deploy-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

###########################################################
# This is a GCP CloudBuild Trigger config file. The trigger
# is to be used to build and publish the latest release
# artifacts to repostiories (container-image and maven).
# The trigger associated to this cloudbuild confiuration
# needs to be manually RUN pointing to the release-branch
###########################################################

steps:
###########################################################
# Deploy the latest release manifests to the main cluster
###########################################################
- id: 'deploy-to-k8s-main'
name: 'gcr.io/k8s-skaffold/skaffold:v1.36.0'
entrypoint: bash
args:
- -c
- |
gcloud container clusters get-credentials --zone $_MAIN_CLUSTER_ZONE $_MAIN_CLUSTER
kubectl create namespace $_MAIN_NS-db
kubectl create namespace $_MAIN_NS-inmemory
kubectl apply -f /workspace/namespace.yaml

skaffold run -p release -f=skaffold.yaml --namespace=$_MAIN_NS-db
skaffold run -p release,inmemory -f=skaffold.yaml --namespace=$_MAIN_NS-inmemory
# waitFor: commented out, so this step waits for all previous steps

timeout: 1800s
logsBucket: 'gs://pos-cloudbuild-logs'
options:
logging: GCS_ONLY
162 changes: 162 additions & 0 deletions .github/cloudbuild/pos-publish-release-artifacts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

###########################################################
# This is a GCP CloudBuild Trigger config file. The trigger
# is to be used to build and publish the latest release
# artifacts to repostiories (container-image and maven).
# The trigger associated to this cloudbuild confiuration
# needs to be manually RUN pointing to the release-branch
###########################################################

steps:
###########################################################
# publish jars to artifact registry
###########################################################
- id: 'publish-jars'
name: gcr.io/google.com/cloudsdktool/cloud-sdk
entrypoint: bash
args:
- -c
- |
echo "Deploying the maven jars..."
./mvnw deploy
# indicates that the step need not wait for any other step
waitFor: [ '-' ]

###########################################################
# skaffold deploy to kubernetes cluster
###########################################################
- id: 'publish-images'
name: 'gcr.io/k8s-skaffold/skaffold:v1.36.0'
entrypoint: bash
args:
- -c
- |
VERSION=$(cat /workspace/release-version.txt)
echo "Publishing images with tag v$$VERSION..."
./mvnw install
skaffold build -p dev -f=skaffold.yaml --default-repo=us-docker.pkg.dev/$PROJECT_ID/$_POS_IMAGE_REPO --tag=v$$VERSION
# waitFor: commented out, so this step waits for all previous steps

###########################################################
# Create a Github release artifact
###########################################################
- id: 'create-github-release'
name: 'us-docker.pkg.dev/point-of-sale-ci/third-party-images/github-cli:mar-22'
secretEnv: [ 'GITHUB_TOKEN', 'GITHUB_EMAIL' ]
entrypoint: bash
args:
- -c
- |
VERSION=$(cat /workspace/release-version.txt)

git config user.email "$$GITHUB_EMAIL"
git config user.name "Anthos DPE"

# as per: https://stackoverflow.com/a/67886960/3396045
git remote set-branches --add origin $BRANCH_NAME
git fetch 'origin'
git checkout --track origin/$BRANCH_NAME

git tag v$$VERSION -a "Release: v$$VERSION"
git push -u https://$$GITHUB_TOKEN@github.com/GoogleCloudPlatform/point-of-sale.git $BRANCH_NAME --tags

gh release create v$$VERSION -t "Release v$$VERSION" -F CHANGELOG.md -d
# waitFor: commented out, so this step waits for all previous steps

- id: 'update-to-next-snapshot'
name: 'python'
entrypoint: bash
args:
- -c
- |
pip install -r .github/releases/requirements.txt
if [[ $BRANCH_NAME == 'release-minor' ]]; then
python3 .github/releases/releaser.py -t minor -s true

elif [[ $BRANCH_NAME == 'release-patch' ]]; then
python3 .github/releases/releaser.py -t patch -s true

elif [[ $BRANCH_NAME == 'release-major' ]]; then
python3 .github/releases/releaser.py -t major -s true

else
echo "Nothing to do since it's not a 'release' PR"
exit 0
fi

VERSION=$(python3 .github/releases/releaser.py -p true)
echo "Next SNAPSHOT version is [$$VERSION]"
echo "$$VERSION" > /workspace/version-snapshot.txt
# waitFor: commented out, so this step waits for all previous steps

###########################################################
# Push the version changes and comment about the release
# status on the release PR
###########################################################
- id: 'push-comment-status-to-github'
name: 'us-docker.pkg.dev/point-of-sale-ci/third-party-images/github-cli:mar-22'
secretEnv: [ 'GITHUB_TOKEN', 'GITHUB_EMAIL' ]
entrypoint: bash
args:
- -c
- |
PR_NUMBER=$(cat release-pr.number)
VERSION=$(cat release-version.txt)
SNAPSHOT_VERSION=$(cat /workspace/version-snapshot.txt)

rm release-pr.number
rm release-version.txt
rm release.done
rm /workspace/version-snapshot.txt

git config user.email "$$GITHUB_EMAIL"
git config user.name "Anthos DPE"

# as per: https://stackoverflow.com/a/67886960/3396045
git remote set-branches --add origin $BRANCH_NAME
git fetch 'origin'
git checkout --track origin/$BRANCH_NAME

git add -A
git commit -m "release: bump version to next snapshot"
git push -u https://$$GITHUB_TOKEN@github.com/GoogleCloudPlatform/point-of-sale.git $BRANCH_NAME

LAST_COMMIT=$(cat .git/refs/heads/$BRANCH_NAME)
cat <<EOF > /workspace/gh-comment.txt -
:zap: Release Status :zap: </br>
- **Artifacts published**: [Maven JARs and Container images](https://console.cloud.google.com/artifacts/browse/point-of-sale-ci?project=point-of-sale-ci) for release version **v$$VERSION** have been published to Artifact Registry
- **Manifests updated**: [Release manifests](https://github.com/GoogleCloudPlatform/point-of-sale/tree/$BRANCH_NAME/k8-manifests/release) have been updated to use the version **v$$VERSION** images
- **Version bumped:** Version in the _pom.xml/package.json_ has been bumped ($$LAST_COMMIT) to the snapshot version of the next **patch** release **v$$SNAPSHOT_VERSION**
- **Github release created:** A draft [Github release](https://github.com/GoogleCloudPlatform/point-of-sale/releases) has been created. Inspect and **publish it**
- **Merge PR:** Inspect the latest changes and merge the PR to **main** to complete the release.

:rocket: Don't forget to run the ["pos-deploy-release"](https://console.cloud.google.com/cloud-build/triggers;region=global?project=point-of-sale-ci) trigger against the **main** to deploy the latest release!!!
EOF
gh pr comment $$PR_NUMBER --repo $_HEAD_REPO_URL --body-file /workspace/gh-comment.txt
# waitFor: commented out, so this step waits for all previous steps

availableSecrets:
inline:
- kmsKeyName: 'projects/$PROJECT_ID/locations/global/keyRings/$_GHTOKEN_KEYRING_NAME/cryptoKeys/$_GHTOKEN_KEY_NAME'
envMap:
GITHUB_TOKEN: 'CiQAuVI6Z93rj1B1R4yer3G1VzEmW7aHtjATP2jOtyJjkW5qOR8SUQBHWet7zXRDJQTBSvFZuXXsOBIxtvf0VDM610Tjgb5XJY8hbIuBxhsMfDy3+/p2ojVnYmE+Mg9NDg5FGZhlJlB/+PBMCumkbMovTXD582u17A=='
- kmsKeyName: 'projects/$PROJECT_ID/locations/global/keyRings/$_GHEMAIL_KEYRING_NAME/cryptoKeys/$_GHEMAIL_KEY_NAME'
envMap:
GITHUB_EMAIL: 'CiQA/ThyQ4p/sDUR2fsc4Q2GgF/PntA048keplEhVQTrmgESLfcSOACXDXFpPP/ASB9nwBao91OK4677dEaGsJQjVKkStDpHtY1ZtF7qefjxq1qK93BSezLllJX/rHbY'
timeout: 1800s
logsBucket: 'gs://pos-cloudbuild-logs'
options:
logging: GCS_ONLY
2 changes: 1 addition & 1 deletion .github/cloudbuild/pos-push-to-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ steps:

./mvnw install
skaffold run -p dev -f=skaffold.yaml --default-repo=us-docker.pkg.dev/$PROJECT_ID/$_POS_IMAGE_REPO --namespace=$_STAGING_NS-db --tag=$COMMIT_SHA-db
skaffold run -p dev,inmemory -f=skaffold.yaml --default-repo=us-docker.pkg.dev/$PROJECT_ID/$_POS_IMAGE_REPO --namespace=$_STAGING_NS-db --tag=$COMMIT_SHA-inmemory
skaffold run -p dev,inmemory -f=skaffold.yaml --default-repo=us-docker.pkg.dev/$PROJECT_ID/$_POS_IMAGE_REPO --namespace=$_STAGING_NS-inmemory --tag=$COMMIT_SHA-inmemory
EOF
# indicates that the step need not wait for any other step
waitFor: [ '-' ]
Expand Down