Skip to content

Commit

Permalink
chore(ci): release version automatically by tag
Browse files Browse the repository at this point in the history
  • Loading branch information
nettoclaudio committed Jan 12, 2023
1 parent 5034325 commit 5857e1e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,36 @@ jobs:
with:
push: true
tags: tsuru/deploy-agent:latest

release:
if: github.event_name != 'pull_request' && github.repository == 'tsuru/deploy-agent' && startsWith(github.ref, 'refs/tags/')
needs:
- lint
- test
runs-on: ubuntu-latest
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: docker login
uses: azure/docker-login@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}

- uses: actions/setup-go@v3
with:
go-version: '1.19'

- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: goreleaser/goreleaser-action@v2
with:
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
16 changes: 16 additions & 0 deletions Dockerfile.goreleaser
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG alpine_version=3.16
FROM alpine:${alpine_version}
COPY ./deploy-agent /usr/local/bin/deploy-agent
ARG docker_credential_gcr_version=2.1.6
ARG grpc_health_probe_version=0.4.14
RUN set -ex \
&& apk add --no-cache --update curl tar \
&& curl -fsSL "https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/v${docker_credential_gcr_version}/docker-credential-gcr_linux_amd64-${docker_credential_gcr_version}.tar.gz" \
| tar -xzf- docker-credential-gcr \
&& mv docker-credential-gcr /usr/local/bin/ \
&& docker-credential-gcr version \
&& docker-credential-gcr configure-docker --include-artifact-registry \
&& curl -fsSL -o /usr/local/bin/grpc_health_probe "https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v${grpc_health_probe_version}/grpc_health_probe-linux-amd64" \
&& chmod +x /usr/local/bin/grpc_health_probe
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/deploy-agent"]
30 changes: 30 additions & 0 deletions goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
builds:
- id: deploy-agent
binary: deploy-agent
flags:
- -trimpath
goos:
- linux
- darwin
goarch:
- amd64
- arm64
goarm:
- 7

dockers:
- id: deploy-agent-linux-amd64
dockerfile: Dockerfile.goreleaser
goos: linux
goarch: amd64
build_flag_templates:
- --pull
- --label=org.opencontainers.image.created={{ .Date }}
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.version={{ .Version }}
image_templates:
- tsuru/deploy-agent:{{ .Tag }}
- tsuru/deploy-agent:v{{ .Major }}
- tsuru/deploy-agent:v{{ .Major }}.{{ .Minor }}
- tsuru/deploy-agent:latest

0 comments on commit 5857e1e

Please sign in to comment.