diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2fed27a..2251091 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -19,12 +19,18 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Set up QEMU uses: docker/setup-qemu-action@v1 + with: + platforms: all - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + with: + version: latest - name: Login to DockerHub uses: docker/login-action@v1 @@ -33,16 +39,16 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Get Version - id: version - uses: oprypin/find-latest-tag@v1 - with: - repository: xjasonlyu/tun2socks + id: shell + run: | + echo ::set-output name=version::$(git describe --tags --abbrev=0) - name: Build and Push uses: docker/build-push-action@v2 with: + context: . push: true platforms: linux/amd64,linux/arm64 tags: | xjasonlyu/tun2socks:latest - xjasonlyu/tun2socks:${{ steps.version.outputs.tag }} + xjasonlyu/tun2socks:${{ steps.shell.outputs.version }} diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ad7168e..3294fd5 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -25,6 +25,8 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Cache go module uses: actions/cache@v2 diff --git a/Dockerfile b/Dockerfile index 883092b..00a3fdf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,17 @@ FROM golang:alpine AS builder -WORKDIR /app -COPY . /app +WORKDIR /tun2socks-src +COPY . /tun2socks-src RUN apk add --no-cache make git \ && go mod download \ && make docker \ - && /app/bin/tun2socks-docker -v + && mv ./bin/tun2socks-docker /tun2socks FROM alpine:latest COPY ./scripts/entrypoint.sh /entrypoint.sh -COPY --from=builder /app/bin/tun2socks-docker /usr/bin/tun2socks +COPY --from=builder /tun2socks /usr/bin/tun2socks RUN apk add --update --no-cache iptables iproute2 \ && chmod +x /entrypoint.sh diff --git a/Makefile b/Makefile index 922b840..20a32bc 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ NAME = "tun2socks" TAGS = "" BUILD_FLAGS = "-v" -VERSION = $(shell git describe --tags --abbrev=0) +VERSION = $(shell git describe --tags --abbrev=0 || echo "unknown version") BUILD_TIME = $(shell date -u '+%FT%TZ') LDFLAGS += -w -s -buildid=