diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 4a0bcd2..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Publish Docker image - -on: - release: - types: [published] - -jobs: - push_to_registry: - 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}" > 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 }} diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index cec14e1..67aa1bf 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,6 +1,3 @@ -# 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 @@ -8,8 +5,6 @@ on: jobs: build-and-run-tests: runs-on: ubuntu-latest - permissions: - contents: write steps: - uses: actions/checkout@v3 - name: Set up Go @@ -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}" @@ -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 }}