Skip to content

Commit 78fe024

Browse files
committed
playground: trigger playground releases from Go releases
This change includes configuration to build and deploy new releases of the Go playground when a new tag of Go is released to Github. The trigger is configured to filter tags to new, non-rc, non-beta releases of Go. This first commit simply implements releasing the current version of Go configured for the playground. Changes to the build process to ensure we're releasing the latest version of Go will be in a follow-up commit. Updates golang/go#32606 Change-Id: I3b518fd3f02efcd8f510fd865f3370bea19f0e9b Reviewed-on: https://go-review.googlesource.com/c/playground/+/183037 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
1 parent c4ae04c commit 78fe024

File tree

3 files changed

+81
-9
lines changed

3 files changed

+81
-9
lines changed

Diff for: Makefile

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
.PHONY: docker test
1+
CLOUDBUILD_TRIGGER_ID := $(shell jq -r .id cloudbuild_trigger.json)
2+
CLOUDBUILD_TRIGGER_JSON := cloudbuild_trigger.json
3+
GCLOUD_ACCESS_TOKEN := $(shell gcloud auth print-access-token)
4+
5+
.PHONY: docker test update-cloudbuild-trigger
26

37
docker:
48
docker build -t golang/playground .
@@ -9,3 +13,9 @@ test:
913
# Then run the slower tests, which happen as one of the
1014
# Dockerfile RUN steps:
1115
docker build -t golang/playground .
16+
17+
update-cloudbuild-trigger:
18+
# The gcloud CLI doesn't yet support updating a trigger.
19+
curl -H "Authorization: Bearer $(GCLOUD_ACCESS_TOKEN)" -H "Content-Type: application/json" \
20+
-d @$(CLOUDBUILD_TRIGGER_JSON) \
21+
-X PATCH https://cloudbuild.googleapis.com/v1/projects/golang-org/triggers/$(CLOUDBUILD_TRIGGER_ID)

Diff for: README.md

+20-8
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,31 @@ https://play.golang.org/
55

66
## Building
77

8-
```
8+
```bash
99
# build the image
1010
docker build -t playground .
1111
```
1212

1313
## Running
1414

15-
```
15+
```bash
1616
docker run --name=play --rm -d -p 8080:8080 playground
1717
# run some Go code
1818
cat /path/to/code.go | go run client.go | curl -s --upload-file - localhost:8080/compile
1919
```
2020

21-
# Deployment
21+
## Deployment
2222

23-
Building the playground Docker container takes more than the default 10 minute time limit of cloud build, so increase its timeout first (note, `app/cloud_build_timeout` is a global configuration value):
23+
Building the playground Docker container takes more than the default 10 minute time limit of cloud build, so increase
24+
its timeout first (note, `app/cloud_build_timeout` is a global configuration value):
2425

25-
```
26+
```bash
2627
gcloud config set app/cloud_build_timeout 1200 # 20 mins
2728
```
2829

2930
Alternatively, to avoid Cloud Build and build locally:
3031

31-
```
32+
```bash
3233
make docker
3334
docker tag playground:latest gcr.io/golang-org/playground:latest
3435
docker push gcr.io/golang-org/playground:latest
@@ -37,11 +38,22 @@ gcloud --project=golang-org --account=you@google.com app deploy app.yaml --image
3738

3839
Then:
3940

40-
```
41+
```bash
4142
gcloud --project=golang-org --account=you@google.com app deploy app.yaml
4243
```
4344

44-
# Contributing
45+
### Deployment Triggers
46+
47+
Playground releases are also triggered when new tags are pushed to Github. The Cloud Build trigger configuration is
48+
defined in [cloudbuild_trigger.json](cloudbuild_trigger.json).
49+
50+
Triggers can be updated by running the following Make target:
51+
52+
```bash
53+
make update-cloudbuild-trigger
54+
```
55+
56+
## Contributing
4557

4658
To submit changes to this repository, see
4759
https://golang.org/doc/contribute.html.

Diff for: cloudbuild_trigger.json

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"id": "5a2c9e25-a71a-4adf-a785-76c3eca2ac8a",
3+
"description": "Go repository release trigger for x/playground",
4+
"github": {
5+
"name": "go",
6+
"owner": "golang",
7+
"push": {
8+
"tag": "^go[0-9](\\.[0-9]+)+$"
9+
}
10+
},
11+
"build": {
12+
"steps": [
13+
{
14+
"name": "gcr.io/cloud-builders/git",
15+
"args": [
16+
"clone",
17+
"--depth",
18+
"1",
19+
"https://go.googlesource.com/playground"
20+
]
21+
},
22+
{
23+
"dir": "playground",
24+
"name": "gcr.io/cloud-builders/docker",
25+
"args": [
26+
"build",
27+
"-t",
28+
"gcr.io/$PROJECT_ID/playground",
29+
"."
30+
],
31+
"timeout": "1800s"
32+
},
33+
{
34+
"dir": "playground",
35+
"name": "gcr.io/cloud-builders/gcloud",
36+
"args": [
37+
"app",
38+
"deploy",
39+
"app.yaml",
40+
"--project=$PROJECT_ID",
41+
"--image-url=gcr.io/$PROJECT_ID/playground:latest"
42+
],
43+
"timeout": "1200s"
44+
}
45+
],
46+
"images": [
47+
"gcr.io/$PROJECT_ID/playground"
48+
]
49+
}
50+
}

0 commit comments

Comments
 (0)