Skip to content

Commit

Permalink
Combine release and docker push
Browse files Browse the repository at this point in the history
  • Loading branch information
rthellend committed Jul 4, 2023
1 parent 5c24135 commit e0f27fe
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 45 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/docker.yml

This file was deleted.

54 changes: 45 additions & 9 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go
on:
- push
- pull_request
jobs:
build-and-run-tests:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up Go
Expand All @@ -24,14 +19,25 @@ jobs:
run: go test -v ./...
- name: Run go tests (-race)
run: go test -race -v ./...
- name: Build docker image
- name: Build test docker image
run: |
touch version.sh
docker build -t c2fmzq/tlsproxy:test .
docker run --rm --interactive c2fmzq/tlsproxy:test -v
create-release:
if: startsWith(github.ref, 'refs/tags/v')
needs: build-and-run-tests
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: Build release binaries
if: startsWith(github.ref, 'refs/tags/v')
run: |
export CGO_ENABLED=0
flag="-ldflags=-s -w -X main.Version=${GITHUB_REF_NAME}"
Expand All @@ -42,10 +48,40 @@ jobs:
- name: Create release
# https://github.com/softprops/action-gh-release/tree/v0.1.15
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
if: startsWith(github.ref, 'refs/tags/v')
with:
draft: true
draft: false
generate_release_notes: true
fail_on_unmatched_files: true
files: |
tlsproxy-linux-*
push_to_registry:
if: startsWith(github.ref, 'refs/tags/v')
needs:
- build-and-run-tests
- create-release
name: Push docker image to docker hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Log in to docker hub
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get release version
run: echo "VERSION=${GITHUB_REF_NAME}" > version.sh
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175
with:
images: c2fmzq/tlsproxy
- name: Build and push docker image
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit e0f27fe

Please sign in to comment.