Skip to content

Commit 69dc9bf

Browse files
authored
chore: Add a workflow to update the versionString on release PRs (GoogleCloudPlatform#471)
* chore: Add workflow to update versionString on release PRs * stricter regex for sed * add path filter * remove version from dockerfiles * Update update-versions.yml
1 parent 6ae517b commit 69dc9bf

4 files changed

Lines changed: 33 additions & 9 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
name: update-version
3+
on:
4+
pull_request:
5+
branches: [master]
6+
paths:
7+
- 'version.txt'
8+
9+
jobs:
10+
update-version-in-pr:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
with:
16+
ref: ${{ github.head_ref }}
17+
18+
- if: github.actor == "release-please[bot]"
19+
name: find-and-replace-version
20+
run: |
21+
VERSION=$(cat version.txt)
22+
sed -i -r 's/(var versionString = ")[0-9]+.[0-9]+.[0-9]+(-dev)?/\1'"$VERSION"'/' cmd/cloud_sql_proxy/cloud_sql_proxy.go
23+
git config user.name "release-please[bot]"
24+
git config user.email "55107282+release-please[bot]@users.noreply.github.com"
25+
git add cmd/cloud_sql_proxy/cloud_sql_proxy.go
26+
git commit -m "Update version"
27+
git push origin ${{ github.head_ref }}
28+
29+
30+

Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
# Use the latest stable golang 1.x to compile to a binary
1616
FROM golang:1 as build
1717

18-
ARG VERSION="1.18.1-dev"
19-
2018
WORKDIR /go/src/cloudsql-proxy
2119
COPY . .
2220

2321
RUN go get ./...
24-
RUN go build -ldflags "-X main.versionString=$VERSION -X main.metadataString=container" -o cloud_sql_proxy ./cmd/cloud_sql_proxy
22+
RUN go build -ldflags "-X main.metadataString=container" -o cloud_sql_proxy ./cmd/cloud_sql_proxy
2523

2624
# Final Stage
2725
FROM gcr.io/distroless/base-debian10:nonroot

Dockerfile.alpine

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
# Use the latest stable golang 1.x to compile to a binary
1616
FROM golang:1 as build
1717

18-
ARG VERSION="1.18.1-dev"
19-
2018
WORKDIR /go/src/cloudsql-proxy
2119
COPY . .
2220

2321
RUN go get ./...
24-
RUN go build -ldflags "-X main.versionString=$VERSION -X main.metadataString=container.alpine" -o cloud_sql_proxy ./cmd/cloud_sql_proxy
22+
RUN go build -ldflags "-X main.metadataString=container.alpine" -o cloud_sql_proxy ./cmd/cloud_sql_proxy
2523

2624
# Final stage
2725
FROM alpine:3

Dockerfile.buster

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
# Use the latest stable golang 1.x to compile to a binary
1616
FROM golang:1 as build
1717

18-
ARG VERSION="1.18.1-dev"
19-
2018
WORKDIR /go/src/cloudsql-proxy
2119
COPY . .
2220

2321
RUN go get ./...
24-
RUN go build -ldflags "-X main.versionString=$VERSION -X main.metadataString=container.buster" -o cloud_sql_proxy ./cmd/cloud_sql_proxy
22+
RUN go build -ldflags "-X main.metadataString=container.buster" -o cloud_sql_proxy ./cmd/cloud_sql_proxy
2523

2624
# Final stage
2725
FROM debian:buster

0 commit comments

Comments
 (0)